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

🐛 Fix 秀色直播

-添加请求头修复返回502的问题
-优化代码
This commit is contained in:
wbt5 2021-11-21 01:14:04 +08:00
parent 41cb50bede
commit 8dbe5981e2
No known key found for this signature in database
GPG Key ID: 92D5C42E815A2BD6

View File

@ -10,10 +10,14 @@ class ShowSelf:
def __init__(self, rid):
self.rid = rid
self.headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/95.0.4638.69 Safari/537.36 '
}
self.s = requests.Session()
def get_real_url(self):
with requests.Session() as s:
res = s.get('https://service.showself.com/v2/custuser/visitor').json()
res = self.s.get('https://service.showself.com/v2/custuser/visitor', headers=self.headers).json()
uid = res['data']['uid']
accesstoken = sessionid = res['data']['sessionid']
params = {
@ -27,13 +31,13 @@ class ShowSelf:
'sessionid': sessionid,
'sessionId': sessionid
}
# 合并两个字典
data = dict(params, **payload)
data = urlencode(sorted(data.items(), key=lambda d: d[0])) + 'sh0wselfh5'
data = f'{urlencode(sorted(data.items(), key=lambda d: d[0]))}sh0wselfh5'
_ajaxData1 = hashlib.md5(data.encode('utf-8')).hexdigest()
payload['_ajaxData1'] = _ajaxData1
url = 'https://service.showself.com/v2/rooms/{}/members?{}'.format(self.rid, urlencode(params))
with requests.Session() as s:
res = s.post(url, json=payload)
url = f'https://service.showself.com/v2/rooms/{self.rid}/members?{urlencode(params)}'
res = self.s.post(url, json=payload, headers=self.headers)
if res.status_code == 200:
res = res.json()
statuscode = res['status']['statuscode']
@ -60,5 +64,5 @@ def get_real_url(rid):
if __name__ == '__main__':
rid = input('输入秀色直播房间号:\n')
print(get_real_url(rid))
r = input('输入秀色直播房间号:\n')
print(get_real_url(r))