-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
97 lines (76 loc) · 2.41 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
#!/usr/bin/env python3
import pickle
import requests
import json
import time
from urllib import request
from urllib.error import HTTPError
from json import loads
PATH = 'YOUR_PATH' #Path where you stock stream id for doesnt spam discord
try:
id = pickle.load(open("{}/kick".format(PATH), "rb"))
except (OSError, IOError) as e:
foo = 3
pickle.dump(foo, open("{}/kick".format(PATH), "wb"))
#ENDPOINT YOUR CHANNEL
ENDPOINT = 'https://kick.com/api/v1/channels/YOUR_CHANNEL'
#USED FLARESOLVERR FOR BYPASS CLOUDFLARE https://github.com/FlareSolverr/FlareSolverr
api_url = "http://FLARESOLVERR_IP:PORT/v1"
headers = {"Content-Type": "application/json"}
data = {
"cmd": "request.get",
"url": ENDPOINT,
"maxTimeout": 60000
}
#GET DATA
r = requests.post(api_url, headers=headers, json=data)
reponse = loads(r.text)['solution']['response']
#CLEANING RESPONSE JSON
r1 = reponse
r2 = r1.replace("<html><head></head><body>", '')
r3 = r2
r4 = r3.replace("</body></html>", '')
#PAYLOAD DISCORD
payload = {
'username':"YOUR_NAME",
'content': "YOUR_MESSAGE",
'avatar_url': "BOT_AVATAR",
'embeds': [
{
'title': loads(r4)['livestream']['session_title'],
'description': 'DESCRIPTION',
'url': 'YOUR_KICK_URL',
"color": 834567, #color embed
'author': {'name': 'YOUR_NAME'},
'timestamp': loads(r4)['livestream']['created_at'],
"image": {"url": loads(r4)['livestream']['thumbnail']['url']},
"fields": [
{
"name": "Game",
"value": loads(r4)['livestream']['categories'][0]['name'],
"inline": True,
},
{
"name": "Viewers",
"value": loads(r4)['livestream']['viewers'],
"inline" : True,
}
]
},
]
}
#WEBHOOK DISCORD
WEBHOOK_URL = 'YOUR_WEBHOOK_URL'
headers = {
'Content-Type': 'application/json',
'user-agent': 'Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11'
}
req = request.Request(url=WEBHOOK_URL,
data=json.dumps(payload).encode('utf-8'),
headers=headers,
method='POST')
if loads(r4)['livestream'] is not None:
if loads(r4)['livestream']['id'] != id:
response = request.urlopen(req)
with open('{}/kick'.format(PATH), 'wb') as f:
pickle.dump(loads(r4)['livestream']['id'], f)