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

[utils] Do not fail in float_or_none on non-numeric data

This commit is contained in:
Sergey M․ 2015-10-14 22:36:37 +06:00
parent 1812afb7b3
commit caf80631f0

View file

@ -1392,7 +1392,12 @@ def str_to_int(int_str):
def float_or_none(v, scale=1, invscale=1, default=None):
return default if v is None else (float(v) * invscale / scale)
if v is None:
return default
try:
return float(v) * invscale / scale
except ValueError:
return default
def parse_duration(s):