-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzoom_auto_join.py
More file actions
284 lines (246 loc) · 11 KB
/
Copy pathzoom_auto_join.py
File metadata and controls
284 lines (246 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
import sys
import asyncio
import re
from playwright.async_api import async_playwright
from audio_record import record_vbcable_audio
async def join_zoom(meeting_url):
"""Join Zoom meeting automatically - works like Google Meet implementation"""
print(f"Joining Zoom meeting: {meeting_url}")
async with async_playwright() as p:
browser = await p.chromium.launch(headless=False, args=[
'--use-fake-ui-for-media-stream',
'--disable-infobars',
'--disable-extensions',
'--disable-notifications',
'--no-sandbox',
'--disable-web-security',
'--allow-running-insecure-content',
])
context = await browser.new_context(
viewport={'width': 1280, 'height': 720},
user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
)
page = await context.new_page()
try:
# Navigate to the meeting
print("Loading Zoom meeting page...")
await page.goto(meeting_url, wait_until='domcontentloaded', timeout=30000)
await page.wait_for_timeout(3000) # Wait for page to settle
# Step 1: Handle cookie consent if present
cookie_selectors = [
'button:has-text("Accept")',
'button:has-text("Accept All")',
'button:has-text("I Accept")',
'[data-testid="cookie-accept"]',
'.cookie-accept'
]
for selector in cookie_selectors:
try:
cookie_button = await page.query_selector(selector)
if cookie_button:
await cookie_button.click()
print("✓ Accepted cookies")
await page.wait_for_timeout(1000)
break
except:
continue
# Step 2: Find and click "Join from Your Browser" button
join_browser_selectors = [
'a:has-text("Join from Your Browser")',
'button:has-text("Join from Your Browser")',
'[data-testid="join-from-browser"]',
'.join-from-browser',
'a:has-text("launch meeting")',
'a:has-text("Launch Meeting")'
]
join_clicked = False
for selector in join_browser_selectors:
try:
join_button = await page.wait_for_selector(selector, timeout=5000)
if join_button:
await join_button.click()
print(f"✓ Clicked join button: {selector}")
join_clicked = True
break
except:
continue
if not join_clicked:
print("⚠️ Could not find 'Join from Your Browser' button")
print("Trying alternative approach...")
# Try to find any element with "join" in text
all_elements = await page.query_selector_all('a, button')
for element in all_elements:
try:
text = await element.text_content()
if text and any(keyword in text.lower() for keyword in ['join', 'launch', 'continue']):
await element.click()
print(f"✓ Clicked alternative join element: {text}")
join_clicked = True
break
except:
continue
if not join_clicked:
print("❌ Could not find any join button")
print("Meeting may require Zoom desktop app")
await page.screenshot(path="zoom_no_join_button.png")
print("Screenshot saved as 'zoom_no_join_button.png'")
return
# Step 3: Wait for meeting interface to load
print("Waiting for meeting interface...")
await page.wait_for_timeout(8000)
# Step 4: Handle name input if present
name_selectors = [
'input[type="text"][placeholder*="name"]',
'input[type="text"][aria-label*="name"]',
'input[name="name"]',
'input[placeholder*="Name"]',
'input[aria-label*="Name"]'
]
for selector in name_selectors:
try:
name_input = await page.query_selector(selector)
if name_input:
await name_input.fill("Auto Join")
print("✓ Filled in name: Auto Join")
break
except:
continue
# Step 5: Handle password input if present
password_selectors = [
'input[type="password"]',
'input[placeholder*="password"]',
'input[aria-label*="password"]',
'input[name="password"]'
]
for selector in password_selectors:
try:
password_input = await page.query_selector(selector)
if password_input:
# Try to extract password from URL
pwd_match = re.search(r'pwd=([^&]+)', meeting_url)
if pwd_match:
password = pwd_match.group(1)
await password_input.fill(password)
print("✓ Filled in password")
break
except:
continue
# Step 6: Click final join button
final_join_selectors = [
'button:has-text("Join")',
'button:has-text("Join Meeting")',
'button:has-text("Continue")',
'button:has-text("Enter")',
'.zm-btn-join',
'[data-testid="join-button"]'
]
final_join_clicked = False
for selector in final_join_selectors:
try:
final_button = await page.query_selector(selector)
if final_button:
await final_button.click()
print(f"✓ Clicked final join button: {selector}")
final_join_clicked = True
break
except:
continue
if not final_join_clicked:
print("⚠️ Could not find final join button, but continuing...")
# Step 7: Wait for meeting to load and handle audio/video
print("Waiting for meeting to load...")
await page.wait_for_timeout(10000)
# Step 8: Mute microphone and turn off video
print("Setting up audio/video...")
# Mute microphone
mic_selectors = [
'button[aria-label*="Mute"]',
'button[aria-label*="mute"]',
'button[data-testid="mute-button"]',
'.zm-btn-mute',
'[title*="Mute"]'
]
for selector in mic_selectors:
try:
mic_button = await page.query_selector(selector)
if mic_button:
await mic_button.click()
print("✓ Microphone muted")
break
except:
continue
# Turn off video
video_selectors = [
'button[aria-label*="Stop Video"]',
'button[aria-label*="Turn Off My Video"]',
'button[data-testid="video-button"]',
'.zm-btn-video',
'[title*="Stop Video"]'
]
for selector in video_selectors:
try:
video_button = await page.query_selector(selector)
if video_button:
await video_button.click()
print("✓ Video turned off")
break
except:
continue
# Step 9: Verify we're in the meeting
meeting_indicators = [
'button[aria-label*="Mute"]',
'button[aria-label*="Stop Video"]',
'.meeting-client',
'.meeting-client-inner',
'[data-testid="meeting-client"]'
]
in_meeting = False
for indicator in meeting_indicators:
try:
element = await page.query_selector(indicator)
if element:
in_meeting = True
break
except:
continue
if in_meeting:
print("🎉 Successfully joined Zoom meeting!")
# Record and transcribe initial audio
try:
print("Recording initial audio...")
audio = record_vbcable_audio()
from audio_transcribe import transcribe_audio_numpy
text = transcribe_audio_numpy(audio)
print("Initial transcription:", text)
from audio_transcribe import append_transcript
append_transcript(text)
except Exception as e:
print(f"⚠️ Error recording audio: {e}")
# Keep meeting open
print("Keeping meeting open for 1 hour...")
await asyncio.sleep(3600) # 1 hour
else:
print("⚠️ Could not confirm we're in the meeting")
print("Keeping browser open for manual inspection...")
await asyncio.sleep(30)
except Exception as e:
print(f"❌ Error joining Zoom meeting: {e}")
import traceback
traceback.print_exc()
# Take error screenshot
try:
await page.screenshot(path="zoom_error_screenshot.png")
print("Error screenshot saved as 'zoom_error_screenshot.png'")
except:
pass
# Keep browser open for debugging
print("Keeping browser open for debugging...")
await asyncio.sleep(30)
finally:
await browser.close()
if __name__ == "__main__":
if len(sys.argv) > 1:
meeting_url = sys.argv[1]
else:
meeting_url = input("Enter Zoom meeting URL: ")
asyncio.run(join_zoom(meeting_url))