aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/huya.py
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2022-12-01 23:33:30 +0800
committerJesús <heckyel@hyperbola.info>2022-12-01 23:33:30 +0800
commitef1a420d6de7876b7b6732abc8ab78351c5a2bfc (patch)
tree9ba7d8409aa5baa696f5fb10db5d395c2f050276 /yt_dlp/extractor/huya.py
parent16e8548f6a720a78679e417a20a300db2036bf6c (diff)
parentddf1e22d48530819d60220d0bdc36e20f5b8483b (diff)
downloadhypervideo-pre-ef1a420d6de7876b7b6732abc8ab78351c5a2bfc.tar.lz
hypervideo-pre-ef1a420d6de7876b7b6732abc8ab78351c5a2bfc.tar.xz
hypervideo-pre-ef1a420d6de7876b7b6732abc8ab78351c5a2bfc.zip
update from upstream 2022-12-01 UTC+8
Diffstat (limited to 'yt_dlp/extractor/huya.py')
-rw-r--r--yt_dlp/extractor/huya.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/yt_dlp/extractor/huya.py b/yt_dlp/extractor/huya.py
index 9dd5e41b3..b6e9eec24 100644
--- a/yt_dlp/extractor/huya.py
+++ b/yt_dlp/extractor/huya.py
@@ -6,7 +6,6 @@ from ..compat import compat_urlparse, compat_b64decode
from ..utils import (
ExtractorError,
int_or_none,
- js_to_json,
str_or_none,
try_get,
unescapeHTML,
@@ -55,11 +54,7 @@ class HuyaLiveIE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)
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)
- 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)
+ stream_data = self._search_json(r'stream:\s', webpage, 'stream', video_id=video_id, default=None)
room_info = try_get(stream_data, lambda x: x['data'][0]['gameLiveInfo'])
if not room_info:
raise ExtractorError('Can not extract the room info', expected=True)
@@ -67,6 +62,8 @@ class HuyaLiveIE(InfoExtractor):
screen_type = room_info.get('screenType')
live_source_type = room_info.get('liveSourceType')
stream_info_list = stream_data['data'][0]['gameStreamInfoList']
+ if not stream_info_list:
+ raise ExtractorError('Video is offline', expected=True)
formats = []
for stream_info in stream_info_list:
stream_url = stream_info.get('sFlvUrl')
@@ -96,8 +93,6 @@ class HuyaLiveIE(InfoExtractor):
**self._RESOLUTION.get(si.get('sDisplayName'), {}),
})
- self._sort_formats(formats)
-
return {
'id': video_id,
'title': title,