diff --git a/youtube_dl/extractor/tvplay.py b/youtube_dl/extractor/tvplay.py index bcfce2379..c3ccda2ab 100644 --- a/youtube_dl/extractor/tvplay.py +++ b/youtube_dl/extractor/tvplay.py @@ -312,32 +312,19 @@ class TVPlayIE(InfoExtractor): # TODO: webvtt in m3u8 subtitles = {} - sami_path = video.get('sami_path') - if sami_path: - lang = self._search_regex( - r'_([a-z]{2})\.xml', sami_path, 'lang', - default=compat_urlparse.urlparse(url).netloc.rsplit('.', 1)[-1]) - subtitles[lang] = [{ - 'url': sami_path, - }] - - subtitles_webvtt = video.get('subtitles_webvtt') - if subtitles_webvtt: - lang = self._search_regex( - r'_([a-z]{2})\.vtt', subtitles_webvtt, 'lang', - default=compat_urlparse.urlparse(url).netloc.rsplit('.', 1)[-1]) - subtitles[lang] = [{ - 'url': subtitles_webvtt, - }] - - subtitles_for_hearing_impaired = video.get('subtitles_for_hearing_impaired') - if subtitles_for_hearing_impaired: - lang = self._search_regex( - r'_([a-z]{2})_', subtitles_for_hearing_impaired, 'lang', - default=compat_urlparse.urlparse(url).netloc.rsplit('.', 1)[-1]) - subtitles[lang + '_sdh'] = [{ - 'url': subtitles_for_hearing_impaired, - }] + sub_paths = [ + video.get('sami_path'), + video.get('subtitles_webvtt'), + video.get('subtitles_for_hearing_impaired'), + ] + for path in sub_paths: + if path: + lang = self._search_regex( + r'_(.*)(\.)', path, 'lang', + default=compat_urlparse.urlparse(url).netloc.rsplit('.', 1)[-1]) + subtitles[lang] = [{ + 'url': path, + }] series = video.get('format_title') episode_number = int_or_none(video.get('format_position', {}).get('episode'))