1
0
mirror of https://github.com/wbt5/real-url.git synced 2025-06-16 15:59:57 +08:00

🎨 Improve KK直播

-优化代码
This commit is contained in:
wbt5 2021-11-21 18:04:44 +08:00
parent 58d4d88942
commit 8b7635d2fc
No known key found for this signature in database
GPG Key ID: 92D5C42E815A2BD6

14
kk.py
View File

@ -5,20 +5,24 @@ import requests
class KK:
def __init__(self, rid):
"""
KK直播
Args:
rid: 房间号
"""
self.rid = rid
self.s = requests.Session()
def get_real_url(self):
url = 'https://sapi.kktv1.com/meShow/entrance?parameter={}'
parameter = {'FuncTag': 10005043, 'userId': '{}'.format(self.rid), 'platform': 1, 'a': 1, 'c': 100101}
with requests.Session() as s:
res = s.get(url.format(parameter)).json()
parameter = {'FuncTag': 10005043, 'userId': f'{self.rid}', 'platform': 1, 'a': 1, 'c': 100101}
res = self.s.get(url.format(parameter)).json()
tagcode = res['TagCode']
if tagcode == '00000000':
if res.get('liveType', 0) == 1:
roomid = res['roomId']
parameter = {'FuncTag': 60001002, 'roomId': roomid, 'platform': 1, 'a': 1, 'c': 100101}
with requests.Session() as s:
res = s.get(url.format(parameter)).json()
res = self.s.get(url.format(parameter)).json()
real_url = res['liveStream']
return real_url
else: