diff options
author | Felix Yan <felixonmars@archlinux.org> | 2023-02-07 03:24:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-07 00:54:47 +0530 |
commit | fbbb5508ea98ed8709847f5ecced7d70ff05e0ee (patch) | |
tree | 0955d60f32d73983e43645c268b714c26d395a3c /yt_dlp | |
parent | c77df98b1a477a020a57141464d10c0f4d0fdbc9 (diff) | |
download | hypervideo-pre-fbbb5508ea98ed8709847f5ecced7d70ff05e0ee.tar.lz hypervideo-pre-fbbb5508ea98ed8709847f5ecced7d70ff05e0ee.tar.xz hypervideo-pre-fbbb5508ea98ed8709847f5ecced7d70ff05e0ee.zip |
[extractor/huya] Support HD streams (#6172)
Authored by: felixonmars
Diffstat (limited to 'yt_dlp')
-rw-r--r-- | yt_dlp/extractor/huya.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/yt_dlp/extractor/huya.py b/yt_dlp/extractor/huya.py index b6e9eec24..c4965f9bc 100644 --- a/yt_dlp/extractor/huya.py +++ b/yt_dlp/extractor/huya.py @@ -1,5 +1,6 @@ import hashlib import random +import re from ..compat import compat_urlparse, compat_b64decode @@ -37,7 +38,7 @@ class HuyaLiveIE(InfoExtractor): }] _RESOLUTION = { - '蓝光4M': { + '蓝光': { 'width': 1920, 'height': 1080, }, @@ -76,11 +77,15 @@ class HuyaLiveIE(InfoExtractor): if re_secret: fm, ss = self.encrypt(params, stream_info, stream_name) for si in stream_data.get('vMultiStreamInfo'): + display_name, bitrate = re.fullmatch( + r'(.+?)(?:(\d+)M)?', si.get('sDisplayName')).groups() rate = si.get('iBitRate') if rate: params['ratio'] = rate else: params.pop('ratio', None) + if bitrate: + rate = int(bitrate) * 1000 if re_secret: params['wsSecret'] = hashlib.md5( '_'.join([fm, params['u'], stream_name, ss, params['wsTime']])) @@ -90,7 +95,7 @@ class HuyaLiveIE(InfoExtractor): 'tbr': rate, 'url': update_url_query(f'{stream_url}/{stream_name}.{stream_info.get("sFlvUrlSuffix")}', query=params), - **self._RESOLUTION.get(si.get('sDisplayName'), {}), + **self._RESOLUTION.get(display_name, {}), }) return { |