mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-24 19:22:06 +00:00
changed YouTube closed captions URL; closes #382
This commit is contained in:
parent
363a4e1114
commit
dee5d76923
3 changed files with 6 additions and 3 deletions
BIN
youtube-dl
BIN
youtube-dl
Binary file not shown.
BIN
youtube-dl.exe
BIN
youtube-dl.exe
Binary file not shown.
|
@ -366,7 +366,8 @@ class YoutubeIE(InfoExtractor):
|
||||||
srt_list = urllib2.urlopen(request).read()
|
srt_list = urllib2.urlopen(request).read()
|
||||||
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
||||||
raise Trouble(u'WARNING: unable to download video subtitles: %s' % str(err))
|
raise Trouble(u'WARNING: unable to download video subtitles: %s' % str(err))
|
||||||
srt_lang_list = re.findall(r'lang_code="([\w\-]+)"', srt_list)
|
srt_lang_list = re.findall(r'name="([^"]*)"[^>]+lang_code="([\w\-]+)"', srt_list)
|
||||||
|
srt_lang_list = dict((l[1], l[0]) for l in srt_lang_list)
|
||||||
if not srt_lang_list:
|
if not srt_lang_list:
|
||||||
raise Trouble(u'WARNING: video has no closed captions')
|
raise Trouble(u'WARNING: video has no closed captions')
|
||||||
if self._downloader.params.get('subtitleslang', False):
|
if self._downloader.params.get('subtitleslang', False):
|
||||||
|
@ -374,14 +375,16 @@ class YoutubeIE(InfoExtractor):
|
||||||
elif 'en' in srt_lang_list:
|
elif 'en' in srt_lang_list:
|
||||||
srt_lang = 'en'
|
srt_lang = 'en'
|
||||||
else:
|
else:
|
||||||
srt_lang = srt_lang_list[0]
|
srt_lang = srt_lang_list.keys()[0]
|
||||||
if not srt_lang in srt_lang_list:
|
if not srt_lang in srt_lang_list:
|
||||||
raise Trouble(u'WARNING: no closed captions found in the specified language')
|
raise Trouble(u'WARNING: no closed captions found in the specified language')
|
||||||
request = urllib2.Request('http://video.google.com/timedtext?hl=en&lang=%s&v=%s' % (srt_lang, video_id))
|
request = urllib2.Request('http://www.youtube.com/api/timedtext?lang=%s&name=%s&v=%s' % (srt_lang, srt_lang_list[srt_lang], video_id))
|
||||||
try:
|
try:
|
||||||
srt_xml = urllib2.urlopen(request).read()
|
srt_xml = urllib2.urlopen(request).read()
|
||||||
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
||||||
raise Trouble(u'WARNING: unable to download video subtitles: %s' % str(err))
|
raise Trouble(u'WARNING: unable to download video subtitles: %s' % str(err))
|
||||||
|
if not srt_xml:
|
||||||
|
raise Trouble(u'WARNING: unable to download video subtitles')
|
||||||
video_subtitles = self._closed_captions_xml_to_srt(srt_xml.decode('utf-8'))
|
video_subtitles = self._closed_captions_xml_to_srt(srt_xml.decode('utf-8'))
|
||||||
except Trouble as trouble:
|
except Trouble as trouble:
|
||||||
self._downloader.trouble(trouble[0])
|
self._downloader.trouble(trouble[0])
|
||||||
|
|
Loading…
Reference in a new issue