aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/FileDownloader.py
diff options
context:
space:
mode:
authorIsmael Mejia <iemejia@gmail.com>2013-02-22 03:13:28 +0100
committerFilippo Valsorda <filippo.valsorda@gmail.com>2013-03-20 08:41:53 +0100
commit553d097442ad5ee62d227de2e2703a2377dcf40f (patch)
treec2878bc4ee4d3fec91e4146a87c4c8bb177c8d48 /youtube_dl/FileDownloader.py
parentae608b8076497d70e2a95e5e939c1fb31e2dde53 (diff)
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.
Diffstat (limited to 'youtube_dl/FileDownloader.py')
-rw-r--r--youtube_dl/FileDownloader.py26
1 files changed, 13 insertions, 13 deletions
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