-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaction.py
121 lines (102 loc) · 3.77 KB
/
action.py
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
# For google meet meetings!!
import requests
import time
from getpass import getpass
from webdriver_manager.chrome import ChromeDriverManager
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
"""
#------------------Flow that need to be followed-----------------#
1. Open chrome browser
2. Open the google login page
3. Enter the email password and get in
4. Go to the desired G-meet
5. After getting into meet keep an eye on the participants counts
and end the meet after the min. threshold
#----------------------------------------------------------------#
"""
# google meet link
url = 'https://meet.google.com/landing?authuser=1'
# get data from user!
print("#+"*10)
email = input("Enter your email address: ").strip()
password = getpass("Password: ")
meet_code = input("Google meet code(eg: abc-defg-hij): ").strip()
set_threshold = int(
input("Minimum count of participants after which you want to end the meet: "))
print("#+"*10)
time.sleep(1)
print("I have activated the system!!!!!\nEnjoy!")
# -----The following code snipet disables the microphone and video access from the browser----- #
opt = Options()
opt.add_argument("--disable-infobars")
opt.add_argument("start-maximized")
opt.add_argument("--disable-extensions")
# Pass the argument 1 to allow and 2 to block
opt.add_experimental_option("prefs", {
"profile.default_content_setting_values.media_stream_mic": 2,
"profile.default_content_setting_values.media_stream_camera": 2,
"profile.default_content_setting_values.geolocation": 2,
"profile.default_content_setting_values.notifications": 2
})
#------------------------------------------------------------------------------------------------#
# install n open driver
chrome = webdriver.Chrome(
ChromeDriverManager().install(), chrome_options=opt)
chrome.get(url)
time.sleep(2)
# put email
emailid = chrome.find_element_by_xpath('//*[@id="identifierId"]')
emailid.send_keys(email)
# time.sleep(2)
# press next button
next1 = chrome.find_element_by_xpath(
'//*[@id="identifierNext"]/div/button/span')
next1.click()
time.sleep(2)
# put password
pswd = chrome.find_element_by_xpath(
'//*[@id="password"]/div[1]/div/div[1]/input')
pswd.send_keys(password)
time.sleep(2)
# press next button
next2 = chrome.find_element_by_xpath(
'//*[@id="passwordNext"]/div/button/span')
next2.click()
time.sleep(3)
# enter meeting
chrome.get(f'https://meet.google.com/{meet_code}')
time.sleep(3)
# press dismiss for allow cam microphone msg
dismiss = chrome.find_element_by_xpath(
'//*[@id="yDmH0d"]/div[3]/div/div[2]/div[3]/div/span/span')
dismiss.click()
time.sleep(2)
# join meeting
join = chrome.find_element_by_xpath(
'//*[@id="yDmH0d"]/c-wiz/div/div/div[9]/div[3]/div/div/div[4]/div/div/div[2]/div/div[2]/div/div[1]/div[1]/span')
join.click()
# Now we are inside the meeting!
time.sleep(100)
# getting data
# from here we will get to know whether the ppl are leaving or not!
# finally automated to end call after a threshold
while True:
print('Working fine!!!!')
data = chrome.find_element_by_xpath(
'//*[@id="ow3"]/div[1]/div/div[9]/div[3]/div[10]/div[3]/div[2]/div/div/div[2]/div')
# num = data.get_attribute('value')
num = data.text
if int(num) < set_threshold:
# by default threshold is 3.. meaning, when the no. of ppl decreased by less than 3 it will end the call!!
end = chrome.find_element_by_xpath(
'//*[@id="ow3"]/div[1]/div/div[9]/div[3]/div[10]/div[2]/div/div[7]/span/button')
end.click()
print('SESSION ENDED!!! '*3)
end_call_pop = chrome.find_element_by_xpath(
'//*[@id="yDmH0d"]/div[3]/div/div[2]/div[2]/div[1]/span/span')
end_call_pop.click()
break
else:
time.sleep(2)