-
Notifications
You must be signed in to change notification settings - Fork 0
/
requesting.py
98 lines (87 loc) · 2.6 KB
/
requesting.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
import requests
from pprint import pprint
import configparser
config = configparser.ConfigParser()
config.read('settings.ini')
client_id = config['Twitch']['client_id']
client_secret = config['Twitch']['client_secret']
access_token = config['Twitch']['access_token']
token_oauth = config['Twitch']['token_oauth']
# header = {
# 'Authorization': f'Bearer {access_token}',
# 'Client-Id': client_id,
# }
# param = {
# 'login': 'fighting_sheep',
# }
# respond = requests.get('https://tmi.twitch.tv/group/user/pianoparrot/chatters', headers=header)
# print(respond.status_code)
# pprint(respond.json()['chatters']['viewers'] + respond.json()['chatters']['broadcaster'] + respond.json()['chatters']['moderators'])
# pprint(respond.json())
# header = {
# 'Authorization': f'Bearer {access_token}',
# 'Client-Id': client_id,
# }
# param = {
# 'broadcaster_id': '83984822'
# }
# respond = requests.get('https://api.twitch.tv/helix/channels', headers=header, params=param)
# print(respond.status_code)
# pprint(respond.json())
# header = {
# 'Authorization': f'Bearer {access_token}',
# 'Client-Id': client_id,
# }
#
# params = {
# 'login': 'pianoparrot',
# }
#
# response = requests.get('https://api.twitch.tv/helix/users', params=params, headers=header)
# print(response.status_code)
# pprint(response.json())
#
#
# header = {
# 'Authorization': f'Bearer {access_token}',
# 'Client-Id': client_id,
# }
#
# params = {
# 'broadcaster_id': '83984822',
# }
# respond = requests.get('https://api.twitch.tv/helix/channels/vips', headers=header, params=params)
# print(respond.status_code)
# pprint(respond.json())
# header = {
# 'Authorization': f'Bearer {access_token}',
# 'Client-Id': client_id,
# }
#
# params = {
# 'user_id': '50935127',
# 'broadcaster_id': '83984822',
# }
# respond = requests.post('https://api.twitch.tv/helix/channels/vips', headers=header, params=params)
# print(respond.status_code)
# pprint(respond.json())
def timeout_users(page=None):
header = {
'Authorization': f'Bearer {access_token}',
'Client-Id': client_id,
}
params = {
'broadcaster_id': '83984822',
'first': 100,
'after': page,
}
try:
respond = requests.get('https://api.twitch.tv/helix/moderation/banned', headers=header, params=params)
users = [user['user_login'] for user in respond.json()['data']]
if respond.json()['pagination']:
return users + timeout_users(respond.json()['pagination']['cursor'])
else:
return users
except ConnectionError as error:
print(error)
print(timeout_users())