From 553d097442ad5ee62d227de2e2703a2377dcf40f Mon Sep 17 00:00:00 2001 From: Ismael Mejia Date: Fri, 22 Feb 2013 03:13:28 +0100 Subject: Refactor subtitle options from srt to the more generic 'sub'. In order to be more consistent with different subtitle formats. From: * --write-srt to --write-sub * --only-srt to --only-sub * --all-srt to --all-subs * --srt-lang to --sub-lang' Refactored also all the mentions of srt for sub in all the source code. --- youtube_dl/FileDownloader.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'youtube_dl/FileDownloader.py') diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py index e496b8a8d..4549dd464 100644 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@ -78,7 +78,7 @@ class FileDownloader(object): updatetime: Use the Last-modified header to set output file timestamps. 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 + writesubtitles: Write the video subtitles to a file (default=srt) onlysubtitles: Downloads only the subtitles of the video allsubtitles: Downloads all the subtitles of the video subtitleslang: Language of the subtitles to download @@ -291,9 +291,9 @@ class FileDownloader(object): """ Report that the description file is being written """ self.to_screen(u'[info] Writing video description to: ' + descfn) - def report_writesubtitles(self, srtfn): + def report_writesubtitles(self, sub_filename): """ Report that the subtitles file is being written """ - self.to_screen(u'[info] Writing video subtitles to: ' + srtfn) + self.to_screen(u'[info] Writing video subtitles to: ' + sub_filename) def report_writeinfojson(self, infofn): """ Report that the metadata file has been written """ @@ -444,12 +444,12 @@ class FileDownloader(object): # subtitles download errors are already managed as troubles in relevant IE # that way it will silently go on when used with unsupporting IE subtitle = info_dict['subtitles'][0] - (srt_error, srt_lang, srt) = subtitle + (sub_error, sub_lang, sub) = subtitle try: - srtfn = filename.rsplit('.', 1)[0] + u'.' + srt_lang + u'.srt' - self.report_writesubtitles(srtfn) - with io.open(encodeFilename(srtfn), 'w', encoding='utf-8') as srtfile: - srtfile.write(srt) + sub_filename = filename.rsplit('.', 1)[0] + u'.' + sub_lang + u'.srt' + self.report_writesubtitles(sub_filename) + with io.open(encodeFilename(sub_filename), 'w', encoding='utf-8') as subfile: + subfile.write(sub) except (OSError, IOError): self.trouble(u'ERROR: Cannot write subtitles file ' + descfn) return @@ -459,12 +459,12 @@ class FileDownloader(object): if self.params.get('allsubtitles', False) and 'subtitles' in info_dict and info_dict['subtitles']: subtitles = info_dict['subtitles'] for subtitle in subtitles: - (srt_error, srt_lang, srt) = subtitle + (sub_error, sub_lang, sub) = subtitle try: - srtfn = filename.rsplit('.', 1)[0] + u'.' + srt_lang + u'.srt' - self.report_writesubtitles(srtfn) - with io.open(encodeFilename(srtfn), 'w', encoding='utf-8') as srtfile: - srtfile.write(srt) + sub_filename = filename.rsplit('.', 1)[0] + u'.' + sub_lang + u'.srt' + self.report_writesubtitles(sub_filename) + with io.open(encodeFilename(sub_filename), 'w', encoding='utf-8') as subfile: + subfile.write(sub) except (OSError, IOError): self.trouble(u'ERROR: Cannot write subtitles file ' + descfn) return -- cgit v1.2.3