1
0
mirror of https://github.com/wbt5/real-url.git synced 2025-06-17 08:25:25 +08:00

🐛 Fix 一直播

-修复获取方式
-优化代码
This commit is contained in:
wbt5 2021-11-20 23:00:49 +08:00
parent 3d0b32c531
commit 2db1b08b74
No known key found for this signature in database
GPG Key ID: 92D5C42E815A2BD6

View File

@ -7,33 +7,24 @@ import re
class YiZhiBo: class YiZhiBo:
def __init__(self, rid): def __init__(self, rid):
"""
一直播需要传入直播间的完整地址
Args:
rid:完整地址
"""
self.rid = rid self.rid = rid
self.s = requests.Session()
def get_real_url(self): def get_real_url(self):
try: try:
scid = re.findall(r'/l/(\S*).html', self.rid)[0] res = self.s.get(self.rid).text
flvurl = 'http://alcdn.f01.xiaoka.tv/live/{}.flv'.format(scid) play_url, status_code = re.findall(r'play_url:"(.*?)"[\s\S]*status:(\d+),', res)[0]
m3u8url = 'http://al01.alcdn.hls.xiaoka.tv/live/{}.m3u8'.format(scid) if status_code == '10':
rtmpurl = 'rtmp://alcdn.r01.xiaoka.tv/live/live/{}'.format(scid) return play_url
real_url = { else:
'flvurl': flvurl, raise Exception('未开播')
'm3u8url': m3u8url, except Exception:
'rtmpurl': rtmpurl raise Exception('获取错误')
}
except:
raise Exception('链接错误')
return real_url
def get_status(self):
try:
scid = re.findall(r'/l/(\S*).html', self.rid)[0]
response = requests.get(
url='https://m.yizhibo.com/www/live/get_live_video?scid=' + str(scid)).json()
status_code = response.get('data').get('info').get('status')
status = '直播中' if status_code == 10 else '未开播'
except:
raise Exception('链接错误')
return status
def get_real_url(rid): def get_real_url(rid):