From 8bd1c00bf399ba7002fc21cd399c931e9d301bd8 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Wed, 19 Jan 2022 18:11:27 +0530 Subject: [utils] Handle `ss:xxx` in `parse_duration` Closes #2388 --- yt_dlp/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'yt_dlp/utils.py') diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index b7e718028..7adfb1e74 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -4094,9 +4094,14 @@ def parse_duration(s): return None days, hours, mins, secs, ms = [None] * 5 - m = re.match(r'(?:(?:(?:(?P[0-9]+):)?(?P[0-9]+):)?(?P[0-9]+):)?(?P[0-9]+)(?P\.[0-9]+)?Z?$', s) + m = re.match(r'''(?x) + (?P + (?:(?:(?P[0-9]+):)?(?P[0-9]+):)?(?P[0-9]+):)? + (?P(?(before_secs)[0-9]{1,2}|[0-9]+)) + (?P[.:][0-9]+)?Z?$ + ''', s) if m: - days, hours, mins, secs, ms = m.groups() + days, hours, mins, secs, ms = m.group('days', 'hours', 'mins', 'secs', 'ms') else: m = re.match( r'''(?ix)(?:P? @@ -4141,7 +4146,7 @@ def parse_duration(s): if days: duration += float(days) * 24 * 60 * 60 if ms: - duration += float(ms) + duration += float(ms.replace(':', '.')) return duration -- cgit v1.2.3