From cdb130b09a16865b81fd34d19b74fa634d45cad7 Mon Sep 17 00:00:00 2001 From: Ismael Mejia Date: Thu, 21 Feb 2013 22:12:36 +0100 Subject: Added new option '--only-srt' to download only the subtitles of a video Improved option '--srt-lang' - it shows the argument in case of missing subtitles - added language suffix for non-english languages (e.g. video.it.srt) --- youtube_dl/InfoExtractors.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'youtube_dl/InfoExtractors.py') diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index e3998fbe8..51b263383 100755 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -228,6 +228,7 @@ class YoutubeIE(InfoExtractor): """Indicate the download will use the RTMP protocol.""" self._downloader.to_screen(u'[youtube] RTMP download detected') + def _extract_subtitles(self, video_id): self.report_video_subtitles_download(video_id) request = compat_urllib_request.Request('http://video.google.com/timedtext?hl=en&type=list&v=%s' % video_id) @@ -246,7 +247,7 @@ class YoutubeIE(InfoExtractor): else: 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) + return (u'WARNING: no closed captions found in the specified language "%s"' % srt_lang, None) params = compat_urllib_parse.urlencode({ 'lang': srt_lang, 'name': srt_lang_list[srt_lang].encode('utf-8'), @@ -483,6 +484,10 @@ class YoutubeIE(InfoExtractor): # closed captions video_subtitles = None + if self._downloader.params.get('subtitleslang', False): + self._downloader.params['writesubtitles'] = True + if self._downloader.params.get('onlysubtitles', False): + self._downloader.params['writesubtitles'] = True if self._downloader.params.get('writesubtitles', False): (srt_error, video_subtitles) = self._extract_subtitles(video_id) if srt_error: -- cgit v1.2.3