Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
xtekky
GitHub Repository: xtekky/tiktok-viewbot
Path: blob/main/old/v1/to update/viewbot.py
620 views
1
#!usr/bin/env python
2
#-*- coding:utf-8 -*-
3
4
"""
5
@author: &! Tekky#1337
6
@file: viewbot.py
7
@time: 2024/07/29
8
"""
9
10
import os, requests, io, time, random, bs4, sys, datetime, re, base64, urllib.parse, json, threading, cursor
11
from pystyle import *
12
from PIL import Image
13
14
15
class Main:
16
def __init__(self):
17
cursor.hide()
18
19
self.blue = Col.light_blue
20
self.lblue = Colors.StaticMIX((Col.light_blue, Col.white, Col.white))
21
self.url = "https://zefoy.com/"
22
self.session = requests.session()
23
self.start = time.time()
24
self.videos = json.load(open("./config.json", "r"))["videos"]
25
26
def format(self, symbol, text):
27
return f""" {Col.Symbol(symbol, self.lblue, self.blue)} {self.lblue}{text}{Col.reset}"""
28
29
def gui(self):
30
os.system("cls" if os.name == "nt" else "clear")
31
txt = """\n██╗ ██╗██╗███████╗██╗ ██╗██████╗ ██████╗ ████████╗\n██║ ██║██║██╔════╝██║ ██║██╔══██╗██╔═══██╗╚══██╔══╝\n██║ ██║██║█████╗ ██║ █╗ ██║██████╔╝██║ ██║ ██║ \n╚██╗ ██╔╝██║██╔══╝ ██║███╗██║██╔══██╗██║ ██║ ██║ \n ╚████╔╝ ██║███████╗╚███╔███╔╝██████╔╝╚██████╔╝ ██║ \n ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝ ╚═════╝ ╚═════╝ ╚═╝\n By &! Tekky#1337\n\n\n\n\n"""
32
print(
33
Colorate.Vertical(
34
Colors.DynamicMIX((Col.light_blue, Col.cyan)), Center.XCenter(txt)
35
)
36
)
37
38
def title(self):
39
if os.system != "nt":
40
return
41
42
while True:
43
44
curr_time = str(
45
datetime.timedelta(
46
seconds = (
47
time.time()
48
- self.start
49
)
50
)
51
).split(".")[0]
52
try:
53
views = requests.post(
54
url = (
55
"https://api16-va.tiktokv.com/tiktok/v1/videos/detail/"
56
+ "?"
57
+ "aweme_ids=%5B{video}%5D&device_type=SM-G973N&app_name=musical_ly&channel=googleplay&device_platform=android&version_code=190303&os_version=7.1.2&aid=1233".format(
58
self.videos[0]
59
)
60
),
61
headers = {
62
"x-gorgon": "0",
63
},
64
).json()["aweme_details"][0]["statistics"]["play_count"]
65
66
os.system(
67
f"title Tekky © 2022 x Zviews ^| Views: {views} ^| Elapsed Time: {curr_time} ^| v2.1"
68
if os.name == "nt"
69
else ""
70
)
71
time.sleep(0.5)
72
except:
73
os.system(
74
f"title Tekky © 2022 x Zviews ^| Views: ERROR ^| Elapsed Time: {curr_time} ^| v2.1"
75
if os.name == "nt"
76
else ""
77
)
78
pass
79
80
def solve_captcha(self, sessid):
81
try:
82
# -- get captcha image --
83
response = self.session.get(
84
self.url + "a1ef290e2636bf553f39817628b6ca49.php",
85
headers={
86
"origin": "https://zefoy.com",
87
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36",
88
"x-requested-with": "XMLHttpRequest",
89
"cookie": f"PHPSESSID={sessid}",
90
},
91
params={
92
"_CAPTCHA": "",
93
"t": f"{round(random.random(), 8)} {int(time.time())}",
94
},
95
)
96
97
json_data = {
98
"requests": [{
99
"image": {
100
"content": str(base64.b64encode(response.content).decode())
101
},
102
"features": [{"type": "TEXT_DETECTION"}]
103
}]
104
}
105
106
req = requests.post(
107
url = 'https://content-vision.googleapis.com/v1/images:annotate',
108
headers = {
109
'x-origin': 'https://explorer.apis.google.com',
110
},
111
params = {
112
'alt': 'json',
113
'key': 'AIzaSyAa8yy0GdcGPHdtD083HiGGx_S0vMPScDM',
114
},
115
json = json_data
116
)
117
118
captcha_answer = req.json()['responses'][0]["textAnnotations"][0]["description"]
119
120
if captcha_answer == "" or captcha_answer is None:
121
self.solve_captcha(sessid)
122
123
captcha_answer = re.compile('[^a-zA-Z]').sub('', captcha_answer).lower()
124
125
# d = enchant.Dict("en_US")
126
# if d.check(captcha_answer) == True:
127
# pass
128
# else:
129
# try:
130
# captcha_answer = d.suggest(captcha_answer)[0]
131
# except:
132
# self.solve_captcha(sessid)
133
134
_response = self.session.post(
135
self.url,
136
data={
137
"captcha_secure": captcha_answer,
138
"r75619cf53f5a5d7aa6af82edfec3bf0": "",
139
},
140
headers={
141
"cookie": f"PHPSESSID={sessid}",
142
"origin": "https://zefoy.com",
143
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36",
144
"x-requested-with": "XMLHttpRequest",
145
},
146
)
147
alpha_key = re.findall('(?<=")[a-z0-9]{16}', _response.text)[0]
148
print(self.format("!", f"Solved captcha ! | {captcha_answer}"))
149
150
return alpha_key
151
except Exception as e:
152
print(self.format("!", f"Error: {e}"))
153
print(
154
self.format(
155
"!",
156
"Captcha Invalid | Check access to Zefoy",
157
)
158
)
159
self.solve_captcha(sessid)
160
161
def get_sessid(self):
162
sessid = self.session.get(
163
self.url,
164
headers={
165
"origin": "https://zefoy.com",
166
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36",
167
"x-requested-with": "XMLHttpRequest",
168
},
169
).cookies.values()[0]
170
return sessid
171
172
def decrypt(self, data):
173
return base64.b64decode(urllib.parse.unquote(data[::-1])).decode()
174
175
def decrypt_timer(self, data):
176
# decrypted = base64.b64decode(urllib.parse.unquote(data[::-1])).decode()
177
if len(re.findall(" \d{3}", data)) != 0:
178
timer = re.findall(" \d{3}", data)[0]
179
else:
180
timer = data.split("= ")[1].split("\n")[0]
181
182
return int(timer)
183
184
def views_loop(self, sessid, alpha_key):
185
while True:
186
try:
187
time.sleep(2)
188
aweme_id = random.choice(self.videos)
189
190
request = self.session.post(
191
self.url + "c2VuZC9mb2xsb3dlcnNfdGlrdG9V",
192
headers={
193
"cookie": f"PHPSESSID={sessid}",
194
"origin": "https://zefoy.com",
195
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36",
196
"x-requested-with": "XMLHttpRequest",
197
},
198
data={alpha_key: f"https://www.tiktok.com/@onlp/video/{aweme_id}"},
199
)
200
decryped_answer = self.decrypt(request.text)
201
202
if "This service is currently not working" in decryped_answer:
203
print(self.format("x", "Views not available in the moment"))
204
input()
205
sys.exit()
206
207
elif "Server too busy" in decryped_answer:
208
print(self.format("x", "Server busy ! (waiting 10s)"))
209
time.sleep(10)
210
continue
211
212
elif "function updatetimer()" in decryped_answer:
213
print("\r", end="")
214
timer = self.decrypt_timer(decryped_answer)
215
216
print(self.format("@", f"Timer: {timer} "), end="")
217
start = time.time()
218
219
while time.time() < start + timer:
220
print("\r", end="")
221
print(
222
self.format(
223
"@", f"Timer: {round((start + timer) - time.time())} "
224
),
225
end="",
226
)
227
time.sleep(1)
228
229
print(self.format("!", f"Sending views ..."))
230
continue
231
232
soup = bs4.BeautifulSoup(decryped_answer, "html.parser")
233
try:
234
beta_key = soup.find("input", {"type": "text"}).get("name")
235
except:
236
os.system("python " + sys.argv[0])
237
sys.exit(0)
238
239
time.sleep(1)
240
241
start = time.time()
242
send_views = requests.post(
243
self.url + "c2VuZC9mb2xsb3dlcnNfdGlrdG9V",
244
headers={
245
"cookie": f"PHPSESSID={sessid}",
246
"origin": "https://zefoy.com",
247
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36",
248
"x-requested-with": "XMLHttpRequest",
249
},
250
data={beta_key: aweme_id},
251
)
252
latency = round(time.time() - start, 2)
253
if latency > 3:
254
print(self.format("!", f"Sent views [id={aweme_id}]"))
255
256
decrypted_response = self.decrypt(send_views.text)
257
258
if "Too many requests. Please slow down." in decrypted_response:
259
print(self.format("x", "Ratelimited"))
260
time.sleep(120)
261
continue
262
263
timer = self.decrypt_timer(decrypted_response)
264
265
print(self.format("@", f"Timer: {timer} "), end="")
266
start = time.time()
267
268
while time.time() < start + timer:
269
print("\r", end="")
270
print(
271
self.format(
272
"@", f"Timer: {round((start + timer) - time.time())} "
273
),
274
end="",
275
)
276
time.sleep(1)
277
278
print("\r", end="")
279
print(self.format("!", f"Sending views ..."))
280
281
except:
282
os.system("python " + sys.argv[0])
283
sys.exit(0)
284
285
def main(self):
286
threading.Thread(
287
target = self.title,
288
daemon = True
289
).start()
290
291
self.gui()
292
sessid: str = self.get_sessid()
293
294
print(
295
self.format(
296
"!",
297
f"Sessid: {sessid}"
298
)
299
)
300
301
alpha_key: str = self.solve_captcha(sessid)
302
303
print(
304
"\n"
305
+ self.format(
306
"!",
307
f"Alpha Key: {alpha_key.upper()}"
308
)
309
)
310
311
self.views_loop(sessid, alpha_key)
312
313
314
if __name__ == "__main__":
315
Main().main()
316
317
318