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

Commit

Permalink
Code clean up and live count optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
pixincreate authored Apr 24, 2021
1 parent d9d4d56 commit 1e64785
Showing 1 changed file with 40 additions and 12 deletions.
52 changes: 40 additions & 12 deletions Source/Automeet.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,44 @@ def live_count(): # Print Live count of participants
print(f'{"Live count of participants: " + live_count.number_of_participants + " "}\r', end='', flush=True) # Prints the live count
time.sleep(0.5)

except NoSuchElementException: # An exception if Network change is detected.
try:
connection_lost = driver.find_element_by_class_name("RkzbPb").text
if "You lost your network connection. Trying to reconnect." in connection_lost:
try:
WebDriverWait(driver, 180).until(expected_conditions.presence_of_element_located((By.CLASS_NAME, "crqnQb")))
except TimeoutException:
print("Please check your Internet connection and Re-Start the Automeet.")
exit_now()
except NoSuchElementException:
live_count()
pass

def exit_checker():
try:
# Several Participants left the meeting or recording Stopped.
try:
live_count.left_or_rec_stop = driver.find_element_by_class_name("aGJE1b").text
exit_checker.left_or_rec_stop = driver.find_element_by_class_name("aGJE1b").text
except NoSuchElementException:
pass
except StaleElementReferenceException:
try:
live_count.left_or_rec_stop = driver.find_element_by_class_name("aGJE1b").text
exit_checker.left_or_rec_stop = driver.find_element_by_class_name("aGJE1b").text
except NoSuchElementException:
pass
except WebDriverException as e:
if "not connected to DevTools" in e:
print("Please check your Internet connection and Re-Start the Automeet.")
exit_now()

# Your host ended the meeting for everyone.
try:
exit_checker.host_end_meeting = driver.find_element_by_class_name("CRFCdf").text
except NoSuchElementException:
pass
except StaleElementReferenceException:
try:
exit_checker.host_end_meeting = driver.find_element_by_class_name("CRFCdf").text
except NoSuchElementException:
pass
except WebDriverException as e:
Expand All @@ -246,7 +276,7 @@ def live_count(): # Print Live count of participants

def end_class(did_host_end): # Ends the current session
live_count.max_count = 0
live_count.left_or_rec_stop = ""
exit_checker.left_or_rec_stop = ""
time.sleep(10)
if not did_host_end:
# Clicks leave call button
Expand Down Expand Up @@ -323,20 +353,18 @@ def exit_now(): # Exits the script
"profile.default_content_setting_values.geolocation": 2,
"profile.default_content_setting_values.notifications": 2})

driverPath = 'chromedriver.exe'

try:
try:
# For Chrome
driver = webdriver.Chrome(executable_path=resource_path(driverPath), options=options)
driver = webdriver.Chrome(executable_path=resource_path('chromedriver.exe'), options=options)
except WebDriverException:
try:
# For 64 Bit Brave
options.binary_location = "C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe"
except WebDriverException:
# For 32 Bit Brave
options.binary_location = "C:\\Program Files (x86)\\BraveSoftware\\Brave-Browser\\Application\\brave.exe"
driver = webdriver.Chrome(options=options, executable_path=resource_path(driverPath))
driver = webdriver.Chrome(options=options, executable_path=resource_path('chromedriver.exe'))
except FileNotFoundError:
print("Webdriver seems to be outdated, download the LATEST VERSION of AUTOMEET from here: "
"'https://github.com/pixincreate/Automeet/releases/latest'", end='\n')
Expand Down Expand Up @@ -379,7 +407,7 @@ def exit_now(): # Exits the script
# Declarations
lastClass = False
live_count.max_count = 0
live_count.left_or_rec_stop = live_count.rec_button = scheduledTimeInSeconds = classTime = classTitle = ""
exit_checker.left_or_rec_stop = exit_checker.host_end_meeting = live_count.rec_button = scheduledTimeInSeconds = classTime = classTitle = ""

# Deleting the user data, i.e., taken in the beginning
del USERNAME, PASSWORD
Expand Down Expand Up @@ -520,9 +548,9 @@ def exit_now(): # Exits the script
# Ends session when either of the condition is satisfied
while True:
live_count()

exit_checker()
try:
if "Your host ended the meeting for everyone" in driver.find_element_by_class_name("CRFCdf"):
if "Your host ended the meeting for everyone" in exit_checker.host_end_meeting:
print('Meeting will end now as Host ended the meeting.', end='\r', flush=True)
host_ended = 1
end_class(host_ended)
Expand All @@ -532,12 +560,12 @@ def exit_now(): # Exits the script
host_ended = 0
end_class(host_ended)
break
elif "Several participants left the meeting." in live_count.left_or_rec_stop:
elif "Several participants left the meeting." in exit_checker.left_or_rec_stop:
print('Meeting will end now as Several participants left the meeting.', end='\r', flush=True)
host_ended = 0
end_class(host_ended)
break
elif "stopped recording" in live_count.left_or_rec_stop:
elif "stopped recording" in exit_checker.left_or_rec_stop:
print('Meeting will end now as the recording stopped.', end='\r', flush=True)
host_ended = 0
end_class(host_ended)
Expand Down

0 comments on commit 1e64785

Please sign in to comment.