mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-24 15:50:32 +01:00
More fixes on subtitles errors handling
This commit is contained in:
parent
0fb3756409
commit
6a205c8876
@ -265,6 +265,10 @@ def _list_available_subtitles(self, video_id):
|
|||||||
self.report_video_subtitles_available(video_id, sub_lang_list)
|
self.report_video_subtitles_available(video_id, sub_lang_list)
|
||||||
|
|
||||||
def _request_subtitle(self, sub_lang, sub_name, video_id, format):
|
def _request_subtitle(self, sub_lang, sub_name, video_id, format):
|
||||||
|
"""
|
||||||
|
Return tuple:
|
||||||
|
(error_message, sub_lang, sub)
|
||||||
|
"""
|
||||||
self.report_video_subtitles_request(video_id, sub_lang, format)
|
self.report_video_subtitles_request(video_id, sub_lang, format)
|
||||||
params = compat_urllib_parse.urlencode({
|
params = compat_urllib_parse.urlencode({
|
||||||
'lang': sub_lang,
|
'lang': sub_lang,
|
||||||
@ -276,9 +280,9 @@ def _request_subtitle(self, sub_lang, sub_name, video_id, format):
|
|||||||
try:
|
try:
|
||||||
sub = compat_urllib_request.urlopen(url).read().decode('utf-8')
|
sub = compat_urllib_request.urlopen(url).read().decode('utf-8')
|
||||||
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
||||||
return (u'WARNING: unable to download video subtitles: %s' % compat_str(err), None)
|
return (u'WARNING: unable to download video subtitles: %s' % compat_str(err), None, None)
|
||||||
if not sub:
|
if not sub:
|
||||||
return (u'WARNING: Did not fetch video subtitles', None)
|
return (u'WARNING: Did not fetch video subtitles', None, None)
|
||||||
return (None, sub_lang, sub)
|
return (None, sub_lang, sub)
|
||||||
|
|
||||||
def _extract_subtitle(self, video_id):
|
def _extract_subtitle(self, video_id):
|
||||||
|
Loading…
Reference in New Issue
Block a user