mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-01 02:37:29 +01:00
[extractor/huya] Fix stream extraction (#4798)
Closes #4658 Authored by: ohaiibuzzle
This commit is contained in:
parent
c4b2df872d
commit
5135ed3d4a
@ -6,7 +6,6 @@
|
|||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
js_to_json,
|
|
||||||
str_or_none,
|
str_or_none,
|
||||||
try_get,
|
try_get,
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
@ -55,11 +54,7 @@ class HuyaLiveIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id=video_id)
|
webpage = self._download_webpage(url, video_id=video_id)
|
||||||
json_stream = self._search_regex(r'"stream":\s+"([a-zA-Z0-9+=/]+)"', webpage, 'stream', default=None)
|
stream_data = self._search_json(r'stream:\s+', webpage, 'stream', video_id=video_id, default=None)
|
||||||
if not json_stream:
|
|
||||||
raise ExtractorError('Video is offline', expected=True)
|
|
||||||
stream_data = self._parse_json(compat_b64decode(json_stream).decode(), video_id=video_id,
|
|
||||||
transform_source=js_to_json)
|
|
||||||
room_info = try_get(stream_data, lambda x: x['data'][0]['gameLiveInfo'])
|
room_info = try_get(stream_data, lambda x: x['data'][0]['gameLiveInfo'])
|
||||||
if not room_info:
|
if not room_info:
|
||||||
raise ExtractorError('Can not extract the room info', expected=True)
|
raise ExtractorError('Can not extract the room info', expected=True)
|
||||||
@ -67,6 +62,8 @@ def _real_extract(self, url):
|
|||||||
screen_type = room_info.get('screenType')
|
screen_type = room_info.get('screenType')
|
||||||
live_source_type = room_info.get('liveSourceType')
|
live_source_type = room_info.get('liveSourceType')
|
||||||
stream_info_list = stream_data['data'][0]['gameStreamInfoList']
|
stream_info_list = stream_data['data'][0]['gameStreamInfoList']
|
||||||
|
if not stream_info_list:
|
||||||
|
raise ExtractorError('Video is offline', expected=True)
|
||||||
formats = []
|
formats = []
|
||||||
for stream_info in stream_info_list:
|
for stream_info in stream_info_list:
|
||||||
stream_url = stream_info.get('sFlvUrl')
|
stream_url = stream_info.get('sFlvUrl')
|
||||||
|
Loading…
Reference in New Issue
Block a user