Extract subtitles if available
This commit is contained in:
parent
c672f91e05
commit
d7c566568a
@ -46,6 +46,7 @@ class PictaBaseIE(InfoExtractor):
|
|||||||
if len(video["results"][0]["lista_reproduccion_canal"]) > 0
|
if len(video["results"][0]["lista_reproduccion_canal"]) > 0
|
||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
|
subtitle_url = try_get(video, lambda x: x["results"][0]["url_subtitulo"])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"id": try_get(video, lambda x: x["results"][0]["id"], compat_str) or video_id,
|
"id": try_get(video, lambda x: x["results"][0]["id"], compat_str) or video_id,
|
||||||
@ -57,7 +58,8 @@ class PictaBaseIE(InfoExtractor):
|
|||||||
"timestamp": timestamp,
|
"timestamp": timestamp,
|
||||||
"category": [category] if category else None,
|
"category": [category] if category else None,
|
||||||
"manifest_url": manifest_url,
|
"manifest_url": manifest_url,
|
||||||
"playlist_channel": playlist_channel
|
"playlist_channel": playlist_channel,
|
||||||
|
"subtitle_url": subtitle_url,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -123,6 +125,11 @@ class PictaIE(PictaBaseIE):
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
_LANGUAGES_CODES = ['es']
|
||||||
|
_LANG_ES = _LANGUAGES_CODES[0]
|
||||||
|
|
||||||
|
_SUBTITLE_FORMATS = ('srt', )
|
||||||
|
|
||||||
def _real_initialize(self):
|
def _real_initialize(self):
|
||||||
self.playlist_id = None
|
self.playlist_id = None
|
||||||
|
|
||||||
@ -134,6 +141,25 @@ class PictaIE(PictaBaseIE):
|
|||||||
assert m
|
assert m
|
||||||
return m.group('playlist_id')
|
return m.group('playlist_id')
|
||||||
|
|
||||||
|
def _get_subtitles(self, video):
|
||||||
|
sub_lang_list = {}
|
||||||
|
lang = self._LANG_ES
|
||||||
|
|
||||||
|
sub_url = video.get('subtitle_url', '')
|
||||||
|
|
||||||
|
if sub_url:
|
||||||
|
sub_formats = []
|
||||||
|
for ext in self._SUBTITLE_FORMATS:
|
||||||
|
sub_formats.append({
|
||||||
|
'url': sub_url,
|
||||||
|
'ext': ext,
|
||||||
|
})
|
||||||
|
sub_lang_list[lang] = sub_formats
|
||||||
|
if not sub_lang_list:
|
||||||
|
self._downloader.report_warning('video doesn\'t have subtitles')
|
||||||
|
return {}
|
||||||
|
return sub_lang_list
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
playlist_id = None
|
playlist_id = None
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
@ -183,8 +209,11 @@ class PictaIE(PictaBaseIE):
|
|||||||
raise ExtractorError("Cannot find video formats")
|
raise ExtractorError("Cannot find video formats")
|
||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
info["formats"] = formats
|
info["formats"] = formats
|
||||||
|
|
||||||
|
# subtitles
|
||||||
|
video_subtitles = self.extract_subtitles(info)
|
||||||
|
info["subtitles"] = video_subtitles
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user