diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2013-02-05 13:30:02 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2013-02-05 13:30:02 +0100 |
commit | fb778e66dfbcd5ffaf9cb9a7abfda4399c4b684a (patch) | |
tree | f29d8cfcf54b8ab40abd820acab894eb62f2a276 /youtube_dl/InfoExtractors.py | |
parent | 3a9918d37f9b5ac8afde9e556cce70aba3d74ecb (diff) |
Fix encoding in youtube subtitle download (Closes #669)
Diffstat (limited to 'youtube_dl/InfoExtractors.py')
-rwxr-xr-x | youtube_dl/InfoExtractors.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index 8d8c591f7..b99a6c505 100755 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -264,13 +264,18 @@ class YoutubeIE(InfoExtractor): srt_lang = list(srt_lang_list.keys())[0] if not srt_lang in srt_lang_list: return (u'WARNING: no closed captions found in the specified language', None) - request = compat_urllib_request.Request('http://www.youtube.com/api/timedtext?lang=%s&name=%s&v=%s' % (srt_lang, srt_lang_list[srt_lang], video_id)) + params = compat_urllib_parse.urlencode({ + 'lang': srt_lang, + 'name': srt_lang_list[srt_lang].encode('utf-8'), + 'v': video_id, + }) + url = 'http://www.youtube.com/api/timedtext?' + params try: - srt_xml = compat_urllib_request.urlopen(request).read().decode('utf-8') + srt_xml = compat_urllib_request.urlopen(url).read().decode('utf-8') 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) if not srt_xml: - return (u'WARNING: unable to download video subtitles', None) + return (u'WARNING: Did not fetch video subtitles', None) return (None, self._closed_captions_xml_to_srt(srt_xml)) def _print_formats(self, formats): |