-
Notifications
You must be signed in to change notification settings - Fork 2
/
ZoomBuddy.py
180 lines (162 loc) · 5.2 KB
/
ZoomBuddy.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import webbrowser, subprocess, requests, json, csv, sys
from os import system, name, path, rename
from datetime import datetime
from time import sleep
VERSION = "1.0.5"
URL = "https://github.com/MNThomson/ZoomBuddy"
API_URL = 'https://api.github.com/repos/mnthomson/zoombuddy/releases/latest'
Update_URL = 'https://github.com/MNThomson/ZoomBuddy/releases/latest'
def main():
figlet()
update()
if len(sys.argv) == 1:
auto()
else:
manual()
def figlet():
#Figlet for ZoomBuddy
print("\
_____ ____ _ _\n\
|__ /___ ___ _ __ ___ | __ ) _ _ __| | __| |_ _\n\
/ // _ \\ / _ \\| '_ ` _ \\| _ \\| | | |/ _` |/ _` | | | |\n\
/ /| (_) | (_) | | | | | | |_) | |_| | (_| | (_| | |_| |\n\
/____\\___/ \\___/|_| |_| |_|____/ \\__,_|\\__,_|\\__,_|\\__, |")
print("v" + VERSION, end ="")
for i in range(1,41-len(VERSION)):
print(" ", end ="")
print("MNThomson |___/")
#Check for updates
def update():
try:
response = requests.get(API_URL).text
except:
return
data = json.loads(response)
CURRENT_VERSION = data['tag_name'].split("v")[1]
if (int(VERSION.replace('.','')) < int(CURRENT_VERSION.replace('.',''))):
print("Downloaded Version: v" + VERSION)
print("Current Version: v" + CURRENT_VERSION)
Choice = input('Would you like to update ZoomBuddy? (Y/N)')
if Choice.lower() == 'yes' or Choice.lower() == 'y':
#Yes to update
if getattr(sys, 'frozen', False):
print('Redircting...')
webbrowser.open(Update_URL)
sys.exit(0)
else:
print("Either run a git pull or reclone this repo.")
Choice = input('Would you like to be redirected to the Github page? (Y/N)')
if Choice.lower() == 'yes' or Choice.lower() == 'y':
#Yes to update
print('Redircting...')
webbrowser.open(Update_URL)
sys.exit(0)
system("cls||clear")
figlet()
#Open the ZoomData file with exceptions
def open_data():
#Open the ZoomData csv file and skip first line (since it's the formatting)
try:
file = open('ZoomData.csv', 'r')
csvfile = csv.reader(file)
next(csvfile)
return file, csvfile
except FileNotFoundError:
if path.isfile('EXAMPLE_ZoomData.csv'):
print("Found file named: EXAMPLE_ZoomData.csv")
Choice = input('Would you like to rename it to ZoomData.csv? (Y/N)')
if Choice.lower() == 'yes' or Choice.lower() == 'y':
print('Renaming...')
rename("EXAMPLE_ZoomData.csv", "ZoomData.csv")
print("Finished renaming. Please rerun ZoomBuddy!")
else:
print("ZoomData.csv Does Not Exist!")
print("Please read the setup instructions for ZoomData.csv")
Choice = input('Would you like to be redirected to the instructions page? (Y/N)')
if Choice.lower() == 'yes' or Choice.lower() == 'y':
print('Redircting...')
webbrowser.open(URL)
sleep(1)
sys.exit(0)
#Automatically join a meeting that is +-15 minutes
def auto():
#Open the ZoomData
file, csvfile = open_data()
#Get time and date
day = datetime.today().weekday()
time = int(datetime.now().strftime("%H"))*60 + int(datetime.now().strftime("%M"))
#Iterate through ZoomData.csv to find the specified class
for row in csvfile:
try:
classtime = int(row[day+4].split(":")[0]) * 60 + int(row[day+4].split(":")[1])
if (time>classtime-15) and (time<classtime+15):
meetingID=row[2]
#Check if password exists
try:
passWD=row[3]
except:
passWD=""
connect(meetingID, passWD)
except ValueError:
pass
print("No meetinges found for this time!")
manual()
#Show a popup to choose which meeting to join
def manual():
#Open the ZoomData
file, csvfile = open_data()
#Print out each possible option
print("Choose an option below:")
for row in csvfile:
print(row[0] + " [" + row[1] + "]")
file.seek(1)
#Get intended meeting
meetingname = input("Enter a Meeting: ")
#Find the specified meeting
for row in csvfile:
if (meetingname==row[1]):
meetingID=row[2]
#Check if password exists
try:
passWD=row[3]
except:
passWD=""
break
#Check if the input is not in the list
try:
meetingID
except NameError:
print("Input Invalid")
Choice = input('Try again? (Y/N)')
if Choice.lower() == 'yes' or Choice.lower() == 'y':
#Yes to update
system("cls||clear")
figlet()
manual()
else:
sys.exit(0)
sys.exit(1)
connect(meetingID, passWD)
#Connect to the meeting
def connect(meetingID, passWD):
#Command to join zoom meeting from Zoom binary
if sys.platform == "linux" or sys.platform == "linux2":
command = "/opt/zoom/zoom --url=zoommtg://zoom.us/join?confno=" + meetingID + "&pwd=" + passWD
print("Linux is currently under developement. Please open a Github issue if an error occurs")
elif sys.platform == "darwin":
command = "open zoommtg://zoom.us/join?confno=" + meetingID + "&pwd=" + passWD
print("MacOS is currently under developement. Please open a Github issue if an error occurs")
elif sys.platform == "win32":
command = "%appdata%\\Zoom\\bin\\Zoom.exe --url=zoommtg://zoom.us/join?confno=" + meetingID + "^&pwd=" + passWD
else:
print("Operating System unknown. Please manually set this is the python file")
sleep(5)
sys.exit(1)
#Execute command
try:
subprocess.run(command.split(), shell=True, timeout=1)
except subprocess.TimeoutExpired:
pass
sys.exit(0)
if __name__ == "__main__":
main()