+ def _extract_subtitles(self, mdoc, mtvn_id):
+ subtitles = {}
+ FORMATS = {
+ 'scc': 'cea-608',
+ 'eia-608': 'cea-608',
+ 'xml': 'ttml',
+ }
+ subtitles_format = FORMATS.get(
+ self._downloader.params.get('subtitlesformat'), 'ttml')
+ for transcript in mdoc.findall('.//transcript'):
+ if transcript.get('kind') != 'captions':
+ continue
+ lang = transcript.get('srclang')
+ for typographic in transcript.findall('./typographic'):
+ captions_format = typographic.get('format')
+ if captions_format == subtitles_format:
+ subtitles[lang] = compat_str(typographic.get('src'))
+ break
+ if self._downloader.params.get('listsubtitles', False):
+ self._list_available_subtitles(mtvn_id, subtitles)
+ return self.extract_subtitles(mtvn_id, subtitles)
+