mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-17 06:37:51 +01:00
Fix crash when subtitles are not found
This commit is contained in:
parent
fbbdf475b1
commit
0fb3756409
@ -282,8 +282,14 @@ class YoutubeIE(InfoExtractor):
|
|||||||
return (None, sub_lang, sub)
|
return (None, sub_lang, sub)
|
||||||
|
|
||||||
def _extract_subtitle(self, video_id):
|
def _extract_subtitle(self, video_id):
|
||||||
|
"""
|
||||||
|
Return a list with a tuple:
|
||||||
|
[(error_message, sub_lang, sub)]
|
||||||
|
"""
|
||||||
sub_lang_list = self._get_available_subtitles(video_id)
|
sub_lang_list = self._get_available_subtitles(video_id)
|
||||||
sub_format = self._downloader.params.get('subtitlesformat')
|
sub_format = self._downloader.params.get('subtitlesformat')
|
||||||
|
if isinstance(sub_lang_list,tuple): #There was some error, it didn't get the available subtitles
|
||||||
|
return [(sub_lang_list[0], None, None)]
|
||||||
if self._downloader.params.get('subtitleslang', False):
|
if self._downloader.params.get('subtitleslang', False):
|
||||||
sub_lang = self._downloader.params.get('subtitleslang')
|
sub_lang = self._downloader.params.get('subtitleslang')
|
||||||
elif 'en' in sub_lang_list:
|
elif 'en' in sub_lang_list:
|
||||||
@ -291,7 +297,7 @@ class YoutubeIE(InfoExtractor):
|
|||||||
else:
|
else:
|
||||||
sub_lang = list(sub_lang_list.keys())[0]
|
sub_lang = list(sub_lang_list.keys())[0]
|
||||||
if not sub_lang in sub_lang_list:
|
if not sub_lang in sub_lang_list:
|
||||||
return (u'WARNING: no closed captions found in the specified language "%s"' % sub_lang, None)
|
return [(u'WARNING: no closed captions found in the specified language "%s"' % sub_lang, None, None)]
|
||||||
|
|
||||||
subtitle = self._request_subtitle(sub_lang, sub_lang_list[sub_lang].encode('utf-8'), video_id, sub_format)
|
subtitle = self._request_subtitle(sub_lang, sub_lang_list[sub_lang].encode('utf-8'), video_id, sub_format)
|
||||||
return [subtitle]
|
return [subtitle]
|
||||||
|
Loading…
Reference in New Issue
Block a user