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.
This commit is contained in:
Ismael Mejia 2013-02-22 03:13:28 +01:00 committed by Filippo Valsorda
parent ae608b8076
commit 553d097442
3 changed files with 54 additions and 54 deletions

View file

@ -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