diff options
| author | Ismael Mejia <iemejia@gmail.com> | 2013-02-21 22:12:36 +0100 | 
|---|---|---|
| committer | Ismael Mejia <iemejia@gmail.com> | 2013-02-21 22:12:36 +0100 | 
| commit | cdb130b09a16865b81fd34d19b74fa634d45cad7 (patch) | |
| tree | bd82790267b51435a4bfe6eddda77b4c2f32af15 /youtube_dl/FileDownloader.py | |
| parent | 2e5d60b7db7020b726cd54ee4cad8f2afbd1479d (diff) | |
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/FileDownloader.py')
| -rw-r--r-- | youtube_dl/FileDownloader.py | 5 | 
1 files changed, 5 insertions, 0 deletions
| 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 | 
