1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-10-04 22:37:56 -04:00

[utils] Improve parse_count

This commit is contained in:
pukkandan
2021-12-24 03:02:50 +05:30
parent d43de6821c
commit 352d5da812
2 changed files with 17 additions and 2 deletions

View File

@@ -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):