mirror of
https://github.com/wbt5/real-url.git
synced 2025-07-24 01:11:43 +08:00
🎨 Improve 来疯直播
-优化代码
This commit is contained in:
parent
8f9141bece
commit
a81a75fa8c
19
laifeng.py
19
laifeng.py
@ -9,19 +9,26 @@ import re
|
|||||||
class LaiFeng:
|
class LaiFeng:
|
||||||
|
|
||||||
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:
|
||||||
response_main = requests.get(url='http://v.laifeng.com/{}/m'.format(self.rid)).text
|
response_main = self.s.get(f'http://v.laifeng.com/{self.rid}/m').text
|
||||||
stream_name = re.findall(r"initAlias:'(.*)?'", response_main)[0]
|
stream_name = re.search(r"initAlias:'(.*)?'", response_main).group(1)
|
||||||
real_url = {}
|
real_url = {}
|
||||||
for stream_format in ['HttpFlv', 'Hls']:
|
for stream_format in ['HttpFlv', 'Hls']:
|
||||||
request_url = 'https://lapi.lcloud.laifeng.com/Play?AppId=101&CallerVersion=2.0&StreamName={}&Action=Schedule&Version=2.0&Format={}'.format(stream_name, stream_format)
|
request_url = f'https://lapi.lcloud.laifeng.com/Play?AppId=101&CallerVersion=2.0&StreamName' \
|
||||||
response = requests.get(url=request_url).json()
|
f'={stream_name}&Action=Schedule&Version=2.0&Format={stream_format}'
|
||||||
|
response = self.s.get(request_url).json()
|
||||||
real_url[stream_format] = response.get(stream_format)[0].get('Url')
|
real_url[stream_format] = response.get(stream_format)[0].get('Url')
|
||||||
except:
|
except Exception:
|
||||||
raise Exception('该直播间不存在或未开播')
|
raise Exception('该直播间不存在或未开播')
|
||||||
return real_url
|
return real_url
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user