-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
242 lines (213 loc) · 6.85 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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
import gif
import os
import pickle
import configparser
import time
import subprocess
ACCOUNTS_FILE = 'accounts.zoomgtadonotopenverysecret'
CONFIG_FILE = 'config.zoomgta.ini'
gif = gif.Gif()
cfg = configparser.ConfigParser()
current_account = 0
if os.path.exists(CONFIG_FILE) and os.path.getsize(CONFIG_FILE) > 0:
cfg.read(CONFIG_FILE)
try:
def_gif = cfg['General']['DefaultGifPath']
except:
def_gif = None
try:
def_delay = cfg['General']['DefaultDelay']
except:
def_delay = 1
try:
api_key = cfg['General']['api-key']
except:
api_key = ''
else:
def_gif = None
def_delay = 1
api_key = ''
if os.path.exists(ACCOUNTS_FILE) and os.path.getsize(ACCOUNTS_FILE) > 0:
accounts = pickle.load(open(ACCOUNTS_FILE, 'rb'))
else:
accounts = []
# start_gui = input('Start GUI? (y/n)')
# if start_gui == 'y':
# import gui
# exit(0)
# TODO: GUI
print('https://github.com/pozhiloy-enotik/zoom-gta')
def save_account(account):
accounts.append(account)
with open(ACCOUNTS_FILE, 'wb') as file:
pickle.dump(accounts, file)
def delete_account(number):
accounts.pop(number - 1)
with open(ACCOUNTS_FILE, 'wb') as file:
pickle.dump(accounts, file)
def save_config(dgif, ddelay):
if def_gif:
cfg['General']['DefaultGifPath'] = dgif
cfg['General']['DefaultDelay'] = ddelay
else:
try:
cfg.add_section('General')
except:
pass
cfg.set('General', 'DefaultGifPath', dgif)
cfg.set('General', 'DefaultDelay', ddelay)
with open(CONFIG_FILE, 'w') as configfile:
cfg.write(configfile)
def save_api(api):
if api_key:
cfg['General']['api-key'] = api
else:
try:
cfg.add_section('General')
except:
pass
cfg.set('General', 'api-key', api)
with open(CONFIG_FILE, 'w') as configfile:
cfg.write(configfile)
def get_captcha(file):
captcha = ''
print('Processing...')
result = gif.process_phantomjs(api_key)
if result == 2:
print('Enter your phantomjscloud api-key \n'
'Введи ключ(Читай faq):')
key = input().strip()
gif.process_phantomjs(key)
save_api(key)
try:
if "com.termux" in os.environ.get("PREFIX", ""): # If device is running Termux (thanks crinny)
path = f'/sdcard/{file}'
gif.get_captcha(path)
subprocess.run(
["am", "start", "--user", "0", "-a", "android.intent.action.VIEW", "-d", f'file://{path}', "-t",
"image/png", "--activity-clear-task"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
captcha = input('Enter captcha(saved as "captcha.png"):\n')
except FileNotFoundError:
pass
try:
if not captcha:
gif.get_captcha(file)
import gui
captcha = gui.start_gui(file)
except:
captcha = input(f'Enter captcha(saved as "{file}"):\n')
return str(captcha)
def re_log_in():
gif.make_session()
print('\nCookies expired')
email, password, auth_cookies = accounts[current_account]
captcha = get_captcha('captcha.png')
# print(captcha)
gif.get_temp_cookies()
result = gif.get_auth_cookies(email, password, captcha)
gif.process_cookies()
if result:
delete_account(current_account + 1)
save_account((email, password, gif.session.cookies))
return True
else:
exit(0)
def log_in():
global current_account
i = 1
gif.make_session()
while i <= len(accounts):
print(str(i) + '.', accounts[i - 1][0])
i += 1
choice = int(input(str(i) + '. ' + 'Add an account\n' +
str(i + 1) + '. ' + 'Delete an account\n'))
if choice == i:
email = input('Enter your e-mail:\n')
password = input('Enter your password:\n')
captcha = get_captcha('captcha.png')
# print(captcha)
gif.get_temp_cookies()
result = gif.get_auth_cookies(email, password, captcha)
gif.process_cookies()
if result:
save_account((email, password, gif.session.cookies))
current_account = len(accounts) - 1
return True
else:
exit(0)
elif choice == i + 1:
delete_account(int(input('Enter the number of the account\n')))
log_in()
return
else:
current_account = choice - 1
email, password, auth_cookies = accounts[choice - 1]
gif.session.cookies = auth_cookies
gif.get_temp_cookies()
gif.process_cookies()
def upload():
if not def_gif:
file = input('Enter the name of a .gif:\n')
else:
file = input('Enter the name of a .gif ( ' + def_gif + ' ) :\n')
if not file:
file = def_gif
path = os.path.join(os.path.curdir, file)
result = gif.process_image(path)
if result == 1:
print('Not a .gif')
return upload()
elif result == 2:
re_log_in()
return upload()
return file
def set_delay():
if not def_gif:
gif.delay = float(input('Enter the delay:\n').replace(',', '.'))
else:
inp = input('Enter the delay ( ' + str(def_delay) + ' ) :\n')
if inp == '':
gif.delay = float(def_delay)
else:
gif.delay = float(inp.replace(',', '.'))
return str(gif.delay)
log_in()
save_config(upload(), set_delay())
while True:
print('Starting... Press Ctrl+C to stop')
length = len(gif.images)
i = 0
try:
while True:
if i == length:
i = 0
status = gif.change_picture(0, 0, f'{gif.w}', f'{gif.h}', gif.images[i])
if status['status']:
print('Frame:', i+1)
i += 1
else:
if status["errorMessage"] == 503 or status["errorMessage"] == 403 or status["errorMessage"] == 502:
print('Too many requests. Waiting for 10 seconds')
time.sleep(10)
else:
print('Frame', i, f'skipped. An error occurred: "{status["errorMessage"]}"')
except KeyboardInterrupt:
print('Stopped')
a = int(input('1. Start\n'
'2. Change account\n'
'3. Change gif\n'
'4. Change delay\n'
'5. Exit\n'))
if a == 1:
pass
elif a == 2:
log_in()
elif a == 3:
upload()
elif a == 4:
set_delay()
elif a == 5:
exit()