-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeet.py
156 lines (134 loc) · 5.07 KB
/
meet.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
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
import re
import datetime
from time import sleep
import pyautogui as pya
from datetime import time
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
def openclass(index, timet):
# The line with current class link
t = timet[index]
st = t[1:6]
et = t[7:12]
link = t[14:]
index = index + 1
# Open current class
browser.get(link)
sleep(10)
# Block Video
browser.find_element_by_css_selector(
'#yDmH0d > c-wiz > div > div > div:nth-child(4) > div.crqnQb > div > div.vgJExf > div > div > div.oORaUb.NONs6c > div.mFzCLe > div.EhAUAc > div.GOH7Zb > div > div > span > span > div > div > svg').click()
sleep(1)
# Block Audio
browser.find_element_by_css_selector(
'#yDmH0d > c-wiz > div > div > div:nth-child(4) > div.crqnQb > div > div.vgJExf > div > div > div.oORaUb.NONs6c > div.mFzCLe > div.EhAUAc > div.ZB88ed > div > div > div > span > span').click()
sleep(3)
# Calculate start time and end time of current class
sth = st[:2]
stm = st[3:]
eth = et[:2]
etm = et[3:]
stime = time(hour=int(sth), minute=int(stm))
etime = time(hour=int(eth), minute=int(etm))
# Get current time
hh = datetime.datetime.now().hour
mm = datetime.datetime.now().minute
ttime = time(hour=hh, minute=mm)
# Check if class has ended or we can still attend it
if etime > ttime:
while stime > ttime:
sleep(30)
hh = datetime.datetime.now().hour
mm = datetime.datetime.now().minute
ttime = time(hour=hh, minute=mm)
else:
return index
# Join class
browser.minimize_window()
browser.maximize_window()
sleep(5)
x, y = pya.locateCenterOnScreen(r"D:\JoinNow.png")#TODO: Change with your own loaction of JoinNow pic
pya.moveTo(x, y, 1)
pya.click()
# Wait for class to end
# Get current time
hh = datetime.datetime.now().hour
mm = datetime.datetime.now().minute
ttime = time(hour=hh, minute=mm)
# Check if class has ended or we can still atttend it
while etime > ttime:
sleep(300)
hh = datetime.datetime.now().hour
mm = datetime.datetime.now().minute
ttime = time(hour=hh, minute=mm)
# To end the class
browser.minimize_window()
browser.maximize_window()
sleep(5)
pya.moveRel(400, -200, 1)
if (browser.find_element_by_css_selector(
'#ow3 > div.T4LgNb > div > div:nth-child(4) > div.crqnQb > div.rG0ybd.LCXT6 > div.q2u11 > div.s1GInc.zCbbgf > div') is not None):
browser.find_element_by_css_selector(
'#ow3 > div.T4LgNb > div > div:nth-child(4) > div.crqnQb > div.rG0ybd.LCXT6 > div.q2u11 > div.s1GInc.zCbbgf > div').click()
else:
browser.get("http:\\google.com")
return index
# Disabling notifications and allowing access to mic and camera
opt = Options()
opt.add_argument("--disable-infobars")
opt.add_argument("start-maximized")
opt.add_argument("--disable-extensions")
opt.add_experimental_option("prefs", {
"profile.default_content_setting_values.media_stream_mic": 1,
"profile.default_content_setting_values.media_stream_camera": 1,
"profile.default_content_setting_values.geolocation": 1,
"profile.default_content_setting_values.notifications": 2
})
# initializing the browser
chromedriver = r"C:\Users\Dell\Downloads\chromedriver" #TODO: Change with your own loaction for driver
browser = webdriver.Chrome(options=opt, executable_path=chromedriver)
browser.maximize_window()
# opening home page
browser.get("http:\\google.com")
sleep(3) # waiting for it to load
# logging into google account
browser.find_element_by_css_selector('#gb_70').click()
sleep(5)
# Enter email
browser.find_element_by_css_selector('#identifierId').send_keys('<Your-email-id>')
browser.find_element_by_css_selector('#identifierNext > div > button > div.VfPpkd-RLmnJb').click()
sleep(10)
# Enter password
browser.find_element_by_css_selector('#password > div.aCsJod.oJeWuf > div > div.Xb9hP > input').send_keys('<Your-password>')
browser.find_element_by_css_selector('#passwordNext > div > button > div.VfPpkd-RLmnJb').click()
sleep(5)
# Opening new tab
action = ActionChains(browser)
find = browser.find_element_by_link_text('About')
action.key_down(Keys.CONTROL).click(find).key_up(Keys.CONTROL).perform()
browser.switch_to.window(browser.window_handles[-1])
sleep(7)
# Reading the time table and making a list
file = open(r'D:\timetable.txt', "r")#TODO: Change with your own loaction for timetable
tt = file.readlines()
for i in range(len(tt)):
tt[i] = tt[i].strip('\n')
# Calculate the day
i = -1
day = datetime.datetime.today().weekday()
if day == 0:
i = tt.index("Monday") + 1
if day == 1:
i = tt.index("Tuesday") + 1
if day == 2:
i = tt.index("Wednesday") + 1
if day == 3:
i = tt.index("Thursday") + 1
if day == 4:
i = tt.index("Friday") + 1
# Checking if classes for the day have ended
day = re.compile(r'(Mon|Tues|Wednes|Thurs|Fri|Satur)day')
while not re.match(day, tt[i]):
i = openclass(i, tt)