aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/InfoExtractors.py
diff options
context:
space:
mode:
authorIsmael Mejia <iemejia@gmail.com>2013-02-21 22:12:36 +0100
committerIsmael Mejia <iemejia@gmail.com>2013-02-21 22:12:36 +0100
commitcdb130b09a16865b81fd34d19b74fa634d45cad7 (patch)
treebd82790267b51435a4bfe6eddda77b4c2f32af15 /youtube_dl/InfoExtractors.py
parent2e5d60b7db7020b726cd54ee4cad8f2afbd1479d (diff)
downloadyoutube-dl-cdb130b09a16865b81fd34d19b74fa634d45cad7.tar.xz
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)
Diffstat (limited to 'youtube_dl/InfoExtractors.py')
-rwxr-xr-xyoutube_dl/InfoExtractors.py7
1 files changed, 6 insertions, 1 deletions
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: