1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-04 17:34:32 +01:00

[YoutubeDL] Use the InfoExtractor._download_webpage method for getting the subtitles

It handles encodings better, for example for 'http://www.npo.nl/nos-journaal/14-02-2015/POW_00942207'
This commit is contained in:
Jaime Marquínez Ferrándiz 2015-02-28 14:03:27 +01:00
parent bd3749ed69
commit 0f2c0d335b

View File

@ -1300,17 +1300,18 @@ class YoutubeDL(object):
# subtitles download errors are already managed as troubles in relevant IE # subtitles download errors are already managed as troubles in relevant IE
# that way it will silently go on when used with unsupporting IE # that way it will silently go on when used with unsupporting IE
subtitles = info_dict['requested_subtitles'] subtitles = info_dict['requested_subtitles']
ie = self.get_info_extractor(info_dict['extractor_key'])
for sub_lang, sub_info in subtitles.items(): for sub_lang, sub_info in subtitles.items():
sub_format = sub_info['ext'] sub_format = sub_info['ext']
if sub_info.get('data') is not None: if sub_info.get('data') is not None:
sub_data = sub_info['data'] sub_data = sub_info['data']
else: else:
try: try:
uf = self.urlopen(sub_info['url']) sub_data = ie._download_webpage(
sub_data = uf.read().decode('utf-8') sub_info['url'], info_dict['id'], note=False)
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err: except ExtractorError as err:
self.report_warning('Unable to download subtitle for "%s": %s' % self.report_warning('Unable to download subtitle for "%s": %s' %
(sub_lang, compat_str(err))) (sub_lang, compat_str(err.cause)))
continue continue
try: try:
sub_filename = subtitles_filename(filename, sub_lang, sub_format) sub_filename = subtitles_filename(filename, sub_lang, sub_format)