1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-25 19:52:11 +00:00

[utils] Do not fail in int_or_none on non-numeric data (Closes #7175)

This commit is contained in:
Sergey M․ 2015-10-14 22:35:01 +06:00
parent ab953c64a0
commit 1812afb7b3

View file

@ -1371,7 +1371,12 @@ def int_or_none(v, scale=1, default=None, get_attr=None, invscale=1):
v = getattr(v, get_attr, None)
if v == '':
v = None
return default if v is None else (int(v) * invscale // scale)
if v is None:
return default
try:
return int(v) * invscale // scale
except ValueError:
pass
def str_or_none(v, default=None):