-
Notifications
You must be signed in to change notification settings - Fork 70
/
main.py
84 lines (66 loc) · 3.44 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
from browser_cookie3 import chrome
from utils.api import Api
from random import choice
from threading import Thread, active_count
class TikReport:
def __init__(this, cookies: dict):
this.cookies = cookies
this.userInfo = None
this.selfInfo = None
this.reasons = ['9101', '91011', '9009', '90093', '90097', '90095', '90064', '90061', '90063', '9006', '9008', '90081', '90082', '9007', '1001', '1002', '1003', '1004', '9002', '90011', '90010', '9001', '9010', '9011', '90112', '90113', '9003', '90031', '90032', '90033', '90034', '90035', '90036', '9004', '9005', '9012', '910121', '910122', '91012', '91013', '910131', '910132', '910133', '910134', '910135', '91014', '9013', '9102']
def reportAccount(this):
for reason in this.reasons:
params = {
'secUid' : this.userInfo['userInfo']['user']['secUid'],
'nickname' : this.userInfo['userInfo']['user']['nickname'],
'object_id' : this.userInfo['userInfo']['user']['id'],
'owner_id' : this.userInfo['userInfo']['user']['id'],
'target' : this.userInfo['userInfo']['user']['id'],
'reporter_id' : this.selfInfo['data']['user_id'],
'reason' : reason,
'report_type' : 'user',
}
req = Api(cookies = this.cookies).tiktok_request('aweme/v2/aweme/feedback/', extra_params = params)
print(f'reported: user - {reason} - {req.json()["extra"]}')
def reportVideo(this, videoId: str):
params = {
'nickname' : this.userInfo['userInfo']['user']['nickname'],
'object_id' : videoId,
'object_owner_id' : this.userInfo['userInfo']['user']['id'],
'owner_id' : this.userInfo['userInfo']['user']['id'],
'reason' : choice(this.reasons),
'report_type' : 'video',
'reporter_id' : this.selfInfo['data']['user_id'],
'target' : videoId,
'video_id' : videoId,
'video_owner' : '[object Object]', # lol
}
return
def start(this, username: str):
this.userInfo = Api(cookies = this.cookies).user_info(username).json()
this.selfInfo = Api(cookies = this.cookies).account_info().json()
this.reportAccount()
if __name__ == '__main__':
threads = 10
cookies = {c.name: c.value for c in chrome(domain_name='tiktok.com')}
username = input('username: ')
if not cookies.get('sessionid'):
cookies['sessionid'] = input('sessionid: ')
TikReport(cookies).start(username)
secUid = Api(cookies = cookies).user_info(username).json()['userInfo']['user']['secUid']
video_list = []
cursor = 0
while True:
videos = Api(cookies = cookies).user_videos(secUid, 33, cursor).json()
for video in videos['itemList']:
if video not in video_list:
video_list.append(video['id'])
print(f'scraped: {len(video_list)} videos')
cursor = videos['cursor']
if not videos['hasMore']:
break
index = 0
while index < len(video_list):
if active_count() < threads:
Thread(target = TikReport(cookies).reportVideo, args = (video_list[index],)).start()
index += 1