-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
101 lines (82 loc) · 2.97 KB
/
main.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
import json
import sys
import webbrowser
import pyautogui
import time
import datetime
import calendar
import os
from map import update_links
import getlinks
def load_data():
file = open(getlinks.pwd + 'data.json','r')
data = file.read()
file.close()
data = json.loads(data)
return data
# Returns day name
def find_day():
date_and_time = datetime.datetime.now()
date = str(date_and_time.day) + ' ' + str(date_and_time.month) + ' ' + str(date_and_time.year)
date = datetime.datetime.strptime(date, '%d %m %Y').weekday()
day = calendar.day_name[date]
return day
# Prints time-table
def print_timetable():
# Edit subjects variable in print_time_table() method.
subjects = {'monday' : ['SE', 'DMDW', 'FE', 'CGALAB'],
'tuesday' : ['OOADLAB', 'CGA', 'OOAD', 'SE'],
'wednesday' : ['DMDW', 'FE', 'CGA', 'OOAD','PDC'],
'thursday' : ['CGA', 'OOAD', 'FE', 'DMDWLAB'],
'friday' : ['OOAD', 'CGA', 'SE' , 'SEMINAR', 'DMDW'],
'saturday' : ['SE', 'DMDW', 'FE'],
'sunday' : ['NO CLASS. SLEEP AGAIN']
}
day = find_day().lower()
time_table = subjects.get(day)
print('\n\t --->>> AUTOMATING GOOGLE CLASSROOM V 2.0 <<<---')
print('\n\t\t\tSNO.\tSUBJECT')
for i, j in enumerate(time_table):
print(f'\n\t\t\t{i + 1}\t{j}')
# Open the classes
def open_class (url):
webbrowser.open(url)
time.sleep(10)
try:
x, y = pyautogui.locateCenterOnScreen(getlinks.pwd + 'video_btn.png', grayscale=True)
pyautogui.click(x, y)
print('Meet link opened "SUCCESSFULLY"')
except (Exception):
print('Failed to join as "LINK NOT FOUND".')
# print help menu
def help():
print('\n\t --->>> AUTOMATING GOOGLE CLASSROOM V 2.0 <<<---')
print('\n\t COMMAND DESCRIPTION')
print('\n\t class -h To display this menu.')
print('\n\t class -t To display time-table.')
print('\n\t class [subject name] To join the link.')
print('\n\t class -u To update links.')
# Main function
def main():
if not os.path.isfile(getlinks.pwd + 'data.json'):
update_links()
try:
subject = sys.argv[1].upper()
data = load_data()
subjects = data.keys()
if subject in subjects:
open_class(data[subject])
elif subject == '-T':
print_timetable()
elif subject == '-H' or subject == '--HELP':
help()
elif subject == '-U':
update_links()
else:
print(f'\nCOMMAND NOT FOUND ---> {subject}')
print('Use "class -h" for help')
except(Exception):
print('\nINCORRECT COMMAND : no parameter found ')
print('Use "class -h" for help')
if __name__ == '__main__':
main()