Skip to content

Commit c36a32a

Browse files
authored
Merge pull request #579 from Aniket-508/main
Google Meet Schedular
2 parents 2c5d3c9 + e51436e commit c36a32a

File tree

3 files changed

+182
-0
lines changed

3 files changed

+182
-0
lines changed

google_meet_schedular/AutoMeet.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
from selenium import webdriver
2+
import time
3+
import re
4+
# from pynput.keyboard import Controller
5+
from notify_run import Notify
6+
7+
8+
class AutoMeet():
9+
usernameStr = None
10+
passwordStr = None
11+
url_meet = None
12+
options = None
13+
browser = None
14+
15+
def __init__(self, username_string, password_string, url_of_meet,):
16+
self.usernameStr = username_string
17+
self.passwordStr = password_string
18+
self.url_meet = url_of_meet
19+
self.options = webdriver.ChromeOptions()
20+
self.options.add_argument("--disable-infobars")
21+
self.options.add_argument("--window-size=800,600")
22+
self.options.add_experimental_option("prefs", {
23+
"profile.default_content_setting_values.media_stream_camera": 2,
24+
"profile.default_content_setting_values.media_stream_mic": 2,
25+
# "profile.default_content_setting_values.geolocation": 2,
26+
"profile.default_content_setting_values.notifications": 2
27+
})
28+
self.browser = webdriver.Chrome(chrome_options=self.options)
29+
30+
# ---------------Wrapper for Gmail ID And Non Gmail ID-----------------
31+
def automeetG(self):
32+
self.browser.get(('https://stackoverflow.com/'))
33+
# self.browser.find_element_by_xpath("/html/body/header/div/ol[2]/li[2]/a[2]").click()
34+
self.waiting_N_click("/html/body/header/div/ol[2]/li[2]/a[2]")
35+
# self.browser.find_element_by_xpath("//*[@id=\"openid-buttons\"]/button[1]").click()
36+
self.waiting_N_click("//*[@id=\"openid-buttons\"]/button[1]")
37+
username = self.browser.find_element_by_id('identifierId')
38+
username.send_keys(self.usernameStr)
39+
nextButton = self.browser.find_element_by_id('identifierNext')
40+
nextButton.click()
41+
time.sleep(15) # 5
42+
# keyboard = Controller()
43+
# keyboard.type(passwordStr)
44+
password = self.browser.find_element_by_xpath("//input[@class='whsOnd zHQkBf']")
45+
password.send_keys(self.passwordStr)
46+
# keyboard.type(passwordStr)
47+
signInButton = self.browser.find_element_by_id('passwordNext')
48+
signInButton.click()
49+
time.sleep(5) # 3
50+
self.browser.get(self.url_meet)
51+
time.sleep(10) # 6
52+
element = self.browser.find_element_by_class_name('Ce1Y1c')
53+
self.browser.execute_script("arguments[0].click();", element)
54+
try:
55+
self.browser.find_element_by_xpath('//*[@id="yDmH0d"]/div[3]/div/div[2]/div[3]/div').click()
56+
try:
57+
self.browser.find_element_by_xpath("//span[@class='NPEfkd RveJvd snByac' and contains(text(), \
58+
'Ask to join')]").click()
59+
except BaseException:
60+
self.browser.find_element_by_xpath("//span[@class='NPEfkd RveJvd snByac' and contains(text(), \
61+
'Join now')]").click()
62+
except BaseException:
63+
try:
64+
self.browser.find_element_by_xpath("//span[@class='NPEfkd RveJvd snByac' and contains(text(), \
65+
'Ask to join')]").click()
66+
except BaseException:
67+
self.browser.find_element_by_xpath("//span[@class='NPEfkd RveJvd snByac' and contains(text(), \
68+
'Join now')]").click()
69+
# time.sleep(15) # Wasnt here
70+
# self.browser.find_element_by_xpath("//*[@id=\"ow3\"]/div[1]/div/div[4]/div[3]/div[6]/div[3]/div/div[2]/div[3]/span/span").click()
71+
self.waiting_N_click("//*[@id=\"ow3\"]/div[1]/div/div[4]/div[3]/div[6]/div[3]/div/div[2]/div[3]/span/span")
72+
currentStudents = 0
73+
greatestStudents = 0
74+
text_temp = ""
75+
final_text = ""
76+
while True:
77+
time.sleep(25) # reduce it later
78+
text = self.browser.find_element_by_xpath("/html/body/div[1]/c-wiz/div[1]/div/div[4]/div[3]/div[3]/ \
79+
div/div[2]/div[2]/div[2]/span[2]/div/div[1]").text
80+
people = self.browser.find_element_by_xpath("/html/body/div[1]/c-wiz/div[1]/div/div[4]/div[3]/div[3]/ \
81+
div/div[2]/div[2]/div[1]/div[1]").text
82+
# print(people)
83+
# print(text)
84+
final_text = text.replace(text_temp, "")
85+
# print(final_text)
86+
text_temp = text
87+
link = re.findall(r"(http|ftp|https)://([\w-]+(?:(?:.[\w-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?",
88+
final_text)
89+
if ("http" in final_text):
90+
notify = Notify()
91+
notify.send(link[0][0] + "://" + link[0][1], link[0][0] + "://" + link[0][1])
92+
print(link[0][0] + "://" + link[0][1])
93+
people_int = re.findall(r'[0-9]+', people)
94+
# print(people_int[0])
95+
currentStudents = int(people_int[0])
96+
if currentStudents > greatestStudents:
97+
greatestStudents = currentStudents
98+
else:
99+
if currentStudents < greatestStudents / 2:
100+
self.browser.close()
101+
break
102+
103+
def waiting_N_click(self, path):
104+
try:
105+
self.browser.find_element_by_xpath(path).click()
106+
except BaseException:
107+
# print("1")
108+
time.sleep(2)
109+
self.waiting_N_click(path)

google_meet_schedular/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Google Meet Schedular
2+
3+
## 1. Installing all the dependencies
4+
```
5+
$ pip install requirements.txt
6+
```
7+
## 2. Setting up the driver
8+
- Check your Google Chrome version
9+
- Download suitable driver for your device from [here](https://chromedriver.chromium.org/downloads) and extract it anywhere you like
10+
- Now we add the path where you extracted into System Environment Variable
11+
Note : In case of other browsers, please check for their respective drivers according to browser version and follow the same steps
12+
## 3. Scheduling your meet
13+
- Create a new Python file in the same directory as AutoMeet.py and code the following :
14+
```
15+
from AutoMeet import AutoMeet
16+
17+
auto = AutoMeet("email ID","password","link")
18+
auto.automeetG()
19+
```
20+
- Replace email ID, password and link with your credentials and meeting link
21+
## Bonus1 (for a fixed schedule)
22+
```
23+
from AutoMeet import AutoMeet
24+
import time
25+
import datetime
26+
27+
getTime = str(datetime.datetime.today().time())
28+
currentTime = getTime[:2] + getTime[3:5]
29+
getDay = int(datetime.datetime.today().weekday())
30+
31+
times = [[1000, 1100], [1110, 1210], [1220, 1320]] #24hourformat
32+
ack = [False,False,False]
33+
34+
usrname = "your_email_Id"
35+
passwrd = "your_password"
36+
LEC1 = "google meet link"
37+
LEC2 = "google meet link"
38+
LEC3 = "google meet link"
39+
40+
monday = [LEC1, LEC2, LEC3]
41+
tuesday = [LEC2, LEC1, LEC3]
42+
wednesday = [LEC1, LEC2, LEC3]
43+
thursday = [LEC3, LEC1, LEC2]
44+
friday = [LEC2, LEC3, LEC1]
45+
46+
days = [monday, tuesday, wednesday, thursday, friday]
47+
48+
while True:
49+
getTime = str(datetime.datetime.today().time())
50+
currentTime = int(getTime[:2] + getTime[3:5])
51+
52+
day = days[getDay]
53+
for i in range(len(times)):
54+
if times[i][0] <= currentTime < times[i][1]:
55+
print(day[i])
56+
if not ack[i]:
57+
auto = AutoMeet(usrname,passwrd,"{}".format(day[i]))
58+
auto.automeetG()
59+
ack[i] = True
60+
61+
print("HOLD")
62+
time.sleep(30)
63+
```
64+
## Bonus2 (get notified)
65+
- Get notified of the url/links shared in your meet’s chatbox by opening terminal/CMD and enter :
66+
```
67+
$ notify-run register
68+
```
69+
- Scan the QR code in your phone and you will get the push notification
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
selenium >= 3.141.0
2+
pynput >= 1.7.3
3+
notify-run >= 0.0.14
4+
pause >= 0.3

0 commit comments

Comments
 (0)