diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-12-24 03:02:50 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-12-25 04:07:19 +0530 |
commit | 352d5da81219e2675ef8cac9383ab0dfbd161a19 (patch) | |
tree | 89909e6840010d4f2d737930a64aa8586a0a2ac2 /yt_dlp/utils.py | |
parent | d43de6821cdc30524d866578a5af86ce4ff76fb7 (diff) | |
download | hypervideo-pre-352d5da81219e2675ef8cac9383ab0dfbd161a19.tar.lz hypervideo-pre-352d5da81219e2675ef8cac9383ab0dfbd161a19.tar.xz hypervideo-pre-352d5da81219e2675ef8cac9383ab0dfbd161a19.zip |
[utils] Improve `parse_count`
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 2c5e6560a..cdc9a0ecf 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -2211,7 +2211,7 @@ def parse_count(s): if s is None: return None - s = s.strip() + s = re.sub(r'^[^\d]+\s', '', s).strip() if re.match(r'^[\d,.]+$', s): return str_to_int(s) @@ -2223,9 +2223,17 @@ def parse_count(s): 'M': 1000 ** 2, 'kk': 1000 ** 2, 'KK': 1000 ** 2, + 'b': 1000 ** 3, + 'B': 1000 ** 3, } - return lookup_unit_table(_UNIT_TABLE, s) + ret = lookup_unit_table(_UNIT_TABLE, s) + if ret is not None: + return ret + + mobj = re.match(r'([\d,.]+)(?:$|\s)', s) + if mobj: + return str_to_int(mobj.group(1)) def parse_resolution(s): |