From 5f9639c236da3c04dfff37f40c9aab99e43646a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Navr=C3=A1til?= Date: Thu, 31 Jan 2019 23:17:17 +0100 Subject: [PATCH] =?UTF-8?q?=C4=8CT=20currently=20uses=20WebVTT=20subtitles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So the extractor should save the subtitle file with correct extension and omit now unnecessary call of `_fix_subtitles` method. --- youtube_dl/extractor/ceskatelevize.py | 31 +++------------------------ 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/youtube_dl/extractor/ceskatelevize.py b/youtube_dl/extractor/ceskatelevize.py index 46380430f..1006e93ac 100644 --- a/youtube_dl/extractor/ceskatelevize.py +++ b/youtube_dl/extractor/ceskatelevize.py @@ -201,40 +201,15 @@ class CeskaTelevizeIE(InfoExtractor): return self.playlist_result(entries, playlist_id, playlist_title, playlist_description) def _get_subtitles(self, episode_id, subs): - original_subtitles = self._download_webpage( + vtt_subs = self._download_webpage( subs[0]['url'], episode_id, 'Downloading subtitles') - srt_subs = self._fix_subtitles(original_subtitles) return { 'cs': [{ - 'ext': 'srt', - 'data': srt_subs, + 'ext': 'vtt', + 'data': vtt_subs, }] } - @staticmethod - def _fix_subtitles(subtitles): - """ Convert millisecond-based subtitles to SRT """ - - def _msectotimecode(msec): - """ Helper utility to convert milliseconds to timecode """ - components = [] - for divider in [1000, 60, 60, 100]: - components.append(msec % divider) - msec //= divider - return '{3:02}:{2:02}:{1:02},{0:03}'.format(*components) - - def _fix_subtitle(subtitle): - for line in subtitle.splitlines(): - m = re.match(r'^\s*([0-9]+);\s*([0-9]+)\s+([0-9]+)\s*$', line) - if m: - yield m.group(1) - start, stop = (_msectotimecode(int(t)) for t in m.groups()[1:]) - yield '{0} --> {1}'.format(start, stop) - else: - yield line - - return '\r\n'.join(_fix_subtitle(subtitles)) - class CeskaTelevizePoradyIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ceskatelevize\.cz/porady/(?:[^/?#&]+/)*(?P[^/#?]+)'