]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
changed YouTube closed captions URL; closes #382
authorFilippo Valsorda <filippo.valsorda@gmail.com>
Tue, 31 Jul 2012 13:56:35 +0000 (15:56 +0200)
committerFilippo Valsorda <filippo.valsorda@gmail.com>
Tue, 31 Jul 2012 13:56:35 +0000 (15:56 +0200)
youtube-dl
youtube-dl.exe
youtube_dl/InfoExtractors.py

index 9e1cd4ff3424b8a484d7e025ac5d72c9c376f4a2..f2268af227b0eee8548aa6d106861cc508879931 100755 (executable)
Binary files a/youtube-dl and b/youtube-dl differ
index 250d9f43e4f2c5c2c522bae0d0a7b6f124b6c4c3..2aa052ccf569ae513f627910c18e55675effe844 100755 (executable)
Binary files a/youtube-dl.exe and b/youtube-dl.exe differ
index 05c4f390f9ad58e424ae183b44c0ce426c2e191e..0835c447c1cf6955f17d246a461948be25bfa3fd 100644 (file)
@@ -366,7 +366,8 @@ class YoutubeIE(InfoExtractor):
                                        srt_list = urllib2.urlopen(request).read()
                                except (urllib2.URLError, httplib.HTTPException, socket.error), 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:
                                        raise Trouble(u'WARNING: video has no closed captions')
                                if self._downloader.params.get('subtitleslang', False):
@@ -374,14 +375,16 @@ class YoutubeIE(InfoExtractor):
                                elif 'en' in srt_lang_list:
                                        srt_lang = 'en'
                                else:
-                                       srt_lang = srt_lang_list[0]
+                                       srt_lang = srt_lang_list.keys()[0]
                                if not srt_lang in srt_lang_list:
                                        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:
                                        srt_xml = urllib2.urlopen(request).read()
                                except (urllib2.URLError, httplib.HTTPException, socket.error), 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'))
                        except Trouble as trouble:
                                self._downloader.trouble(trouble[0])