aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2014-08-31 06:41:30 +0700
committerSergey M․ <dstftw@gmail.com>2014-08-31 06:41:30 +0700
commitca7b3246b69215c890193acaf4eab746bc19504e (patch)
treed039cbfe389645e396293eb1211500d0875066b2 /youtube_dl/utils.py
parent9c4c233b846bd9be4c48b788d6d2347af764f15d (diff)
[utils] Improve parse_duration
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 4f0210872..e07750434 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1332,8 +1332,10 @@ def parse_duration(s):
if s is None:
return None
+ s = s.strip()
+
m = re.match(
- r'(?:(?:(?P<hours>[0-9]+)[:h])?(?P<mins>[0-9]+)[:m])?(?P<secs>[0-9]+)s?(?::[0-9]+)?(?P<ms>\.[0-9]+)?$', s)
+ r'(?:(?:(?P<hours>[0-9]+)\s*(?:[:h]|hours?)\s*)?(?P<mins>[0-9]+)\s*(?:[:m]|mins?|minutes?)\s*)?(?P<secs>[0-9]+)(?P<ms>\.[0-9]+)?\s*(?:s|secs?|seconds?)?$', s)
if not m:
return None
res = int(m.group('secs'))