diff options
author | Sergey M․ <dstftw@gmail.com> | 2015-10-14 22:36:37 +0600 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2015-10-14 22:36:37 +0600 |
commit | caf80631f0c57b29187e2aa909fa1a3a6325d6e6 (patch) | |
tree | 7315861d36fd4c3448c3ef2a1f3580c908491892 /youtube_dl/utils.py | |
parent | 1812afb7b396f4954d5d1ca1cec1c3f2d67550c6 (diff) |
[utils] Do not fail in float_or_none on non-numeric data
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r-- | youtube_dl/utils.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 86c693358..83b44caaa 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -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): |