From d6343d6850a9826a35394e68a5642223e4581128 Mon Sep 17 00:00:00 2001 From: Forthrin Date: Wed, 10 Apr 2019 18:59:17 +0200 Subject: [PATCH 1/5] [nrk] Remove whitespace in XML subtitles causing problems for .srt files --- youtube_dl/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 71713f63a..79d17cd12 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -2831,7 +2831,7 @@ def dfxp2srt(dfxp_data): self._applied_styles.pop() def data(self, data): - self._out += data + self._out += data.strip() def close(self): return self._out.strip() From 3337739ba892550b347aba8676d937bc1eb07329 Mon Sep 17 00:00:00 2001 From: Forthrin Date: Wed, 10 Apr 2019 19:01:17 +0200 Subject: [PATCH 2/5] [nrk] Gracefully handle subtitle thousands with less than three digits --- youtube_dl/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 79d17cd12..eb4631b26 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -2729,9 +2729,9 @@ def parse_dfxp_time_expr(time_expr): if mobj: return float(mobj.group('time_offset')) - mobj = re.match(r'^(\d+):(\d\d):(\d\d(?:(?:\.|:)\d+)?)$', time_expr) + mobj = re.match(r'^(\d+):(\d\d):(\d\d)\.(\d{1,3})$', time_expr) if mobj: - return 3600 * int(mobj.group(1)) + 60 * int(mobj.group(2)) + float(mobj.group(3).replace(':', '.')) + return 3600 * int(mobj.group(1)) + 60 * int(mobj.group(2)) + int(mobj.group(3)) + float("%03d" % int(mobj.group(4))) / 1000 def srt_subtitles_timecode(seconds): From 04ff45650345bc77efaa3559c18c6cdb89e6a545 Mon Sep 17 00:00:00 2001 From: Sergey M Date: Sat, 13 Apr 2019 15:05:24 +0700 Subject: [PATCH 3/5] [streamango] add support for streamcherry.com (#20592) --- youtube_dl/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index eb4631b26..a225f40cf 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -2729,9 +2729,9 @@ def parse_dfxp_time_expr(time_expr): if mobj: return float(mobj.group('time_offset')) - mobj = re.match(r'^(\d+):(\d\d):(\d\d)\.(\d{1,3})$', time_expr) + mobj = re.match(r'^(\d+):(\d\d):(\d\d(?:(?:\.|:)\d+)?)$', time_expr) if mobj: - return 3600 * int(mobj.group(1)) + 60 * int(mobj.group(2)) + int(mobj.group(3)) + float("%03d" % int(mobj.group(4))) / 1000 + return 3600 * int(mobj.group(1)) + 60 * int(mobj.group(2)) + float(mobj.group(3).replace(':', '.')) def srt_subtitles_timecode(seconds): @@ -2831,7 +2831,11 @@ def dfxp2srt(dfxp_data): self._applied_styles.pop() def data(self, data): +<<<<<<< HEAD self._out += data.strip() +======= + self._out += data +>>>>>>> [streamango] add support for streamcherry.com (#20592) def close(self): return self._out.strip() From ce846a024d82110c7130db2bfbd877c874f3e764 Mon Sep 17 00:00:00 2001 From: Forthrin Date: Wed, 10 Apr 2019 18:59:17 +0200 Subject: [PATCH 4/5] [nrk] Remove whitespace in XML subtitles causing problems for .srt files --- youtube_dl/utils.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index a225f40cf..71713f63a 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -2831,11 +2831,7 @@ def dfxp2srt(dfxp_data): self._applied_styles.pop() def data(self, data): -<<<<<<< HEAD - self._out += data.strip() -======= self._out += data ->>>>>>> [streamango] add support for streamcherry.com (#20592) def close(self): return self._out.strip() From 4c226a581fb17f89da9d083cfc1d5e4ac567588b Mon Sep 17 00:00:00 2001 From: Forthrin Date: Wed, 10 Apr 2019 19:01:17 +0200 Subject: [PATCH 5/5] [nrk] Gracefully handle subtitle thousands with less than three digits --- test/test_utils.py | 2 ++ youtube_dl/utils.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/test_utils.py b/test/test_utils.py index ca6d832a4..9fb5ae431 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -1154,6 +1154,8 @@ ffmpeg version 2.4.4 Copyright (c) 2000-2014 the FFmpeg ...'''), '2.4.4') self.assertEqual(parse_dfxp_time_expr('00:00:01'), 1.0) self.assertEqual(parse_dfxp_time_expr('00:00:01.100'), 1.1) self.assertEqual(parse_dfxp_time_expr('00:00:01:100'), 1.1) + self.assertEqual(parse_dfxp_time_expr('00:00:01:10'), 1.01) # [nrk] + self.assertEqual(parse_dfxp_time_expr('00:00:01:1'), 1.001) # [nrk] def test_dfxp2srt(self): dfxp_data = ''' diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 71713f63a..3d74c0d49 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -2729,9 +2729,13 @@ def parse_dfxp_time_expr(time_expr): if mobj: return float(mobj.group('time_offset')) - mobj = re.match(r'^(\d+):(\d\d):(\d\d(?:(?:\.|:)\d+)?)$', time_expr) + mobj = re.match(r'^(\d+):(\d\d):(\d\d)$', time_expr) if mobj: - return 3600 * int(mobj.group(1)) + 60 * int(mobj.group(2)) + float(mobj.group(3).replace(':', '.')) + return 3600 * int(mobj.group(1)) + 60 * int(mobj.group(2)) + int(mobj.group(3)) + + mobj = re.match(r'^(\d+):(\d\d):(\d\d)(?:\.|:)(\d{1,3})$', time_expr) + if mobj: + return 3600 * int(mobj.group(1)) + 60 * int(mobj.group(2)) + int(mobj.group(3)) + float("%03d" % int(mobj.group(4))) / 1000 def srt_subtitles_timecode(seconds):