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/FileDownloader.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'youtube_dl/FileDownloader.py') diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py index 53c2d1dce..487c9dadb 100644 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@ -79,6 +79,7 @@ class FileDownloader(object): writedescription: Write the video description to a .description file writeinfojson: Write the video description to a .info.json file writesubtitles: Write the video subtitles to a .srt file + onlysubtitles: Downloads only the subtitles of the video subtitleslang: Language of the subtitles to download test: Download only first bytes to test the downloader. keepvideo: Keep the video file after post-processing @@ -443,9 +444,13 @@ class FileDownloader(object): # that way it will silently go on when used with unsupporting IE try: srtfn = filename.rsplit('.', 1)[0] + u'.srt' + if self.params.get('subtitleslang', False): + srtfn = filename.rsplit('.', 1)[0] + u'.' + self.params['subtitleslang'] + u'.srt' self.report_writesubtitles(srtfn) with io.open(encodeFilename(srtfn), 'w', encoding='utf-8') as srtfile: srtfile.write(info_dict['subtitles']) + if self.params.get('onlysubtitles', False): + return except (OSError, IOError): self.trouble(u'ERROR: Cannot write subtitles file ' + descfn) return -- cgit v1.2.3