mirror of
https://github.com/wbt5/real-url.git
synced 2025-07-27 19:10:32 +08:00
🐛 Fix 龙珠直播
-将获取的流媒体格式改为HLS -优化代码
This commit is contained in:
parent
e7c495a3c3
commit
8f9141bece
17
longzhu.py
17
longzhu.py
@ -7,15 +7,22 @@ import re
|
|||||||
class LongZhu:
|
class LongZhu:
|
||||||
|
|
||||||
def __init__(self, rid):
|
def __init__(self, rid):
|
||||||
|
"""
|
||||||
|
龙珠直播,获取hls格式的播放地址
|
||||||
|
Args:
|
||||||
|
rid: 直播房间号
|
||||||
|
"""
|
||||||
self.rid = rid
|
self.rid = rid
|
||||||
|
self.s = requests.Session()
|
||||||
|
|
||||||
def get_real_url(self):
|
def get_real_url(self):
|
||||||
try:
|
try:
|
||||||
response = requests.get('http://star.longzhu.com/' + str(self.rid)).text
|
res = self.s.get(f'http://star.longzhu.com/{self.rid}').text
|
||||||
roomId = re.findall(r'roomid":(\d+)', response)[0]
|
roomId = re.search(r'roomid":(\d+)', res).group(1)
|
||||||
response = requests.get('http://livestream.longzhu.com/live/getlivePlayurl?roomId={}&utmSr=&platform=h5&device=ios'.format(roomId)).json()
|
res = self.s.get(f'http://livestream.longzhu.com/live/getlivePlayurl?roomId={roomId}&utmSr=&platform=h5'
|
||||||
real_url = response.get('playLines')[0].get('urls')[0].get('securityUrl')
|
f'&device=ios').json()
|
||||||
except:
|
real_url = res.get('playLines')[0].get('urls')[-1].get('securityUrl')
|
||||||
|
except Exception:
|
||||||
raise Exception('直播间不存在或未开播')
|
raise Exception('直播间不存在或未开播')
|
||||||
return real_url
|
return real_url
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user