X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fsubtitles.py;fp=youtube_dl%2Fextractor%2Fsubtitles.py;h=9a3c54b65a271bba680397a950b0ad06701f7fed;hb=7fad1c6328b02ba9f23d37f374a05255abfe38a6;hp=5ae8b3b167ea9d39055c3c0c0bf37ff954c7d0d1;hpb=d82134c3395c0912157c7ccae9f21d4b3375910b;p=youtube-dl diff --git a/youtube_dl/extractor/subtitles.py b/youtube_dl/extractor/subtitles.py index 5ae8b3b16..9a3c54b65 100644 --- a/youtube_dl/extractor/subtitles.py +++ b/youtube_dl/extractor/subtitles.py @@ -1,12 +1,8 @@ -import socket - from .common import InfoExtractor from ..utils import ( - compat_http_client, - compat_urllib_error, - compat_urllib_request, compat_str, + ExtractorError, ) @@ -52,8 +48,8 @@ class SubtitlesInfoExtractor(InfoExtractor): def _request_subtitle_url(self, sub_lang, url): """ makes the http request for the subtitle """ try: - sub = compat_urllib_request.urlopen(url).read().decode('utf-8') - except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err: + sub = self._download_webpage(url, None, note=False) + except ExtractorError as err: self._downloader.report_warning(u'unable to download video subtitles for %s: %s' % (sub_lang, compat_str(err))) return if not sub: @@ -88,5 +84,3 @@ class SubtitlesInfoExtractor(InfoExtractor): elif self._downloader.params.get('writeautomaticsub', False): video_subtitles = self._request_automatic_caption(video_id, video_webpage) return video_subtitles - -