Skip to content
This repository was archived by the owner on Jul 4, 2024. It is now read-only.

Commit fd4b701

Browse files
authored
Update Automeet.py
1 parent 56b3da2 commit fd4b701

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

Source/Automeet.py

+27-19
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def login(username, password): # Logs in the user
9393
del username, password
9494
exit_now()
9595
try:
96-
WebDriverWait(driver, 60).until(lambda webpage: "https://stackoverflow.com/" in webpage.current_url)
96+
WebDriverWait(driver, 6).until(lambda webpage: "https://stackoverflow.com/" in webpage.current_url)
9797
print('\nLogin Successful!\n')
9898
except TimeoutException:
9999
print('\nUsername/Password seems to be incorrect, please re-check\nand Re-Run the program.')
@@ -249,7 +249,7 @@ def end_class(): # Ends the current session
249249
driver.find_element_by_xpath("//div[@aria-label='Leave call']").click()
250250

251251
double_quotes = "\""
252-
print(f"{'The meeting ' + double_quotes + classTitle + double_quotes + ' ended now. '}\r", end='', flush=True)
252+
print(f"{'The meeting ' + double_quotes + classTitle + double_quotes + ' ended now. '}\r", end='', flush=True)
253253
print(end='\n\n')
254254
time.sleep(3)
255255
# Returns to the Home Screen
@@ -356,21 +356,30 @@ def exit_now(): # Exits the script
356356
print('Activity Logs:\n--------------', end='\n')
357357

358358
for i in range(0, len(time_table())):
359-
classTitle = time_table()[i][1].upper()
360-
classTime = time_table()[i][0].strftime("%I:%M %p")
361-
scheduledTimeInSeconds = int((dt.datetime.strptime(classTime, "%I:%M %p") - dt.datetime(1900, 1, 1)).total_seconds())
362-
363359
try:
364-
classTimeNextSession = time_table()[i + 1][0].strftime("%I:%M %p")
365-
scheduledTimeInSecondsForNextSession = int((dt.datetime.strptime(classTimeNextSession, "%I:%M %p")
366-
- dt.datetime(1900, 1, 1)).total_seconds())
367-
if (scheduledTimeInSecondsForNextSession - present_time()) < 240 and (present_time() - scheduledTimeInSeconds) > 600:
368-
classTitle = time_table()[i + 1][1].upper()
369-
i += 1
360+
classTitle = time_table()[i][1].upper()
361+
classTime = time_table()[i][0].strftime("%I:%M %p")
362+
scheduledTimeInSeconds = int((dt.datetime.strptime(classTime, "%I:%M %p") - dt.datetime(1900, 1, 1)).total_seconds())
363+
try:
364+
classTimeNextSession = time_table()[i + 1][0].strftime("%I:%M %p")
365+
scheduledTimeInSecondsForNextSession = int((dt.datetime.strptime(classTimeNextSession, "%I:%M %p")
366+
- dt.datetime(1900, 1, 1)).total_seconds())
367+
if (scheduledTimeInSecondsForNextSession - present_time()) < 240 and (present_time() - scheduledTimeInSeconds) > 600:
368+
classTitle = time_table()[i + 1][1].upper()
369+
i += 1
370+
except IndexError:
371+
lastClass = True
372+
driver.execute_script("alert('This is the last session for today.')")
373+
auto_close_popup_message()
370374
except IndexError:
371-
lastClass = True
372-
driver.execute_script("alert('This is the last session for today.')")
373-
auto_close_popup_message()
375+
try:
376+
driver.execute_script("alert('This was the last session for today. Tab closes in 5 seconds.')")
377+
auto_close_popup_message()
378+
except JavascriptException:
379+
pass
380+
print('\nLast session ended.\n')
381+
time.sleep(5)
382+
exit_now()
374383

375384
# Joining the class 90 seconds before the scheduled time.
376385
if ((scheduledTimeInSeconds - present_time()) <= 90) or "\nNOW" in time_table()[i][2].text.upper():
@@ -385,10 +394,9 @@ def exit_now(): # Exits the script
385394
# When waiting time to class is more than 1m 30s
386395
driver.execute_script("alert('Will join 1m 30s before the session starts.')")
387396
auto_close_popup_message()
388-
waitingTime = (scheduledTimeInSeconds - 90) - present_time()
389-
timer(waitingTime)
390397
try:
391-
time.sleep((scheduledTimeInSeconds - 90) - present_time())
398+
waitingTime = (scheduledTimeInSeconds - 90) - present_time()
399+
timer(waitingTime)
392400
except ValueError:
393401
pass
394402
print('Joining \"' + classTitle + '\" now...', end=' ', flush=True)
@@ -468,7 +476,7 @@ def exit_now(): # Exits the script
468476
print('Meeting will end now as Several participants left the meeting.', end='\r', flush=True)
469477
end_class()
470478
break
471-
elif ("stopped recording" in live_count.left_or_rec_stop) and ((present_time() - scheduledTimeInSeconds) > 600):
479+
elif "stopped recording" in live_count.left_or_rec_stop:
472480
print('Meeting will end now as the recording stopped.', end='\r', flush=True)
473481
end_class()
474482
break

0 commit comments

Comments
 (0)