diff options
author | Sergey M․ <dstftw@gmail.com> | 2015-10-14 22:35:01 +0600 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2015-10-14 22:35:01 +0600 |
commit | 1812afb7b396f4954d5d1ca1cec1c3f2d67550c6 (patch) | |
tree | 993f68c7922dc45d56b507647404ff72b9a297ff /youtube_dl/utils.py | |
parent | ab953c64a0e8b8558e95d0318110c0885a4eec3d (diff) |
[utils] Do not fail in int_or_none on non-numeric data (Closes #7175)
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 1dc3153fd..86c693358 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -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): |