mirror of
https://github.com/wbt5/real-url.git
synced 2025-06-17 08:25:25 +08:00
修复哔哩哔哩直播
This commit is contained in:
parent
e8816f7d0c
commit
e4e1e94a87
15
bilibili.py
15
bilibili.py
@ -23,15 +23,12 @@ def get_real_url(rid):
|
||||
live_status = room[0]
|
||||
room_id = room[1]
|
||||
if live_status:
|
||||
room_url = 'https://api.live.bilibili.com/room/v1/Room/playUrl?cid=' +str(room_id) + '&platform=h5&otype=json&quality=4'
|
||||
response = requests.get(url=room_url).json()
|
||||
durl = response.get('data').get('durl', 0)
|
||||
if durl:
|
||||
result = durl[0].get('url')
|
||||
pattern = r'.com/live-[\S]*/([\s\S]*.m3u8)'
|
||||
pattern_result = re.findall(pattern, result, re.I)[0]
|
||||
real_url = 'https://cn-hbxy-cmcc-live-01.live-play.acgvideo.com/live-bvc/' + pattern_result
|
||||
else:
|
||||
try:
|
||||
room_url = 'https://api.live.bilibili.com/xlive/web-room/v1/index/getRoomPlayInfo?room_id={}&play_url=1&mask=1&qn=0&platform=web'.format(room_id)
|
||||
response = requests.get(url=room_url).json()
|
||||
durl = response.get('data').get('play_url').get('durl', 0)
|
||||
real_url = durl[-1].get('url')
|
||||
except:
|
||||
real_url = '疑似部分国外IP无法GET到正确数据,待验证'
|
||||
else:
|
||||
real_url = '未开播或直播间不存在'
|
||||
|
Loading…
x
Reference in New Issue
Block a user