@@ -93,7 +93,7 @@ def login(username, password): # Logs in the user
93
93
del username , password
94
94
exit_now ()
95
95
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 )
97
97
print ('\n Login Successful!\n ' )
98
98
except TimeoutException :
99
99
print ('\n Username/Password seems to be incorrect, please re-check\n and Re-Run the program.' )
@@ -249,7 +249,7 @@ def end_class(): # Ends the current session
249
249
driver .find_element_by_xpath ("//div[@aria-label='Leave call']" ).click ()
250
250
251
251
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 )
253
253
print (end = '\n \n ' )
254
254
time .sleep (3 )
255
255
# Returns to the Home Screen
@@ -356,21 +356,30 @@ def exit_now(): # Exits the script
356
356
print ('Activity Logs:\n --------------' , end = '\n ' )
357
357
358
358
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
-
363
359
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 ()
370
374
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 ('\n Last session ended.\n ' )
381
+ time .sleep (5 )
382
+ exit_now ()
374
383
375
384
# Joining the class 90 seconds before the scheduled time.
376
385
if ((scheduledTimeInSeconds - present_time ()) <= 90 ) or "\n NOW" in time_table ()[i ][2 ].text .upper ():
@@ -385,10 +394,9 @@ def exit_now(): # Exits the script
385
394
# When waiting time to class is more than 1m 30s
386
395
driver .execute_script ("alert('Will join 1m 30s before the session starts.')" )
387
396
auto_close_popup_message ()
388
- waitingTime = (scheduledTimeInSeconds - 90 ) - present_time ()
389
- timer (waitingTime )
390
397
try :
391
- time .sleep ((scheduledTimeInSeconds - 90 ) - present_time ())
398
+ waitingTime = (scheduledTimeInSeconds - 90 ) - present_time ()
399
+ timer (waitingTime )
392
400
except ValueError :
393
401
pass
394
402
print ('Joining \" ' + classTitle + '\" now...' , end = ' ' , flush = True )
@@ -468,7 +476,7 @@ def exit_now(): # Exits the script
468
476
print ('Meeting will end now as Several participants left the meeting.' , end = '\r ' , flush = True )
469
477
end_class ()
470
478
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 :
472
480
print ('Meeting will end now as the recording stopped.' , end = '\r ' , flush = True )
473
481
end_class ()
474
482
break
0 commit comments