projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1812afb
)
[utils] Do not fail in float_or_none on non-numeric data
author
Sergey M․
<dstftw@gmail.com>
Wed, 14 Oct 2015 16:36:37 +0000
(22:36 +0600)
committer
Sergey M․
<dstftw@gmail.com>
Wed, 14 Oct 2015 16:36:37 +0000
(22:36 +0600)
youtube_dl/utils.py
patch
|
blob
|
history
diff --git
a/youtube_dl/utils.py
b/youtube_dl/utils.py
index 86c693358539451efc6fe4253382ff60427349c6..83b44caaa9a82c0df00eeec5a6cc643a8ad90363 100644
(file)
--- 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):