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
+ allsubtitles: Downloads all 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
"""Report download progress."""
if self.params.get('noprogress', False):
return
- if self.params.get('newline', True):
+ if self.params.get('progress_with_newline', False):
self.to_screen(u'[download] %s of %s at %s ETA %s' %
(percent_str, data_len_str, speed_str, eta_str))
- else: self.to_screen(u'\r[download] %s of %s at %s ETA %s' %
+ else:
+ self.to_screen(u'\r[download] %s of %s at %s ETA %s' %
(percent_str, data_len_str, speed_str, eta_str), skip_eol=True)
self.to_cons_title(u'youtube-dl - %s of %s at %s ETA %s' %
(percent_str.strip(), data_len_str.strip(), speed_str.strip(), eta_str.strip()))
title = info_dict['title']
matchtitle = self.params.get('matchtitle', False)
if matchtitle:
- matchtitle = matchtitle.decode('utf8')
if not re.search(matchtitle, title, re.IGNORECASE):
return u'[download] "' + title + '" title did not match pattern "' + matchtitle + '"'
rejecttitle = self.params.get('rejecttitle', False)
if rejecttitle:
- rejecttitle = rejecttitle.decode('utf8')
if re.search(rejecttitle, title, re.IGNORECASE):
return u'"' + title + '" title matched reject pattern "' + rejecttitle + '"'
return None
if self.params.get('writesubtitles', False) and 'subtitles' in info_dict and info_dict['subtitles']:
# 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
try:
- srtfn = filename.rsplit('.', 1)[0] + u'.srt'
+ 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(info_dict['subtitles'])
+ srtfile.write(srt)
except (OSError, IOError):
self.trouble(u'ERROR: Cannot write subtitles file ' + descfn)
return
+ if self.params.get('onlysubtitles', False):
+ return
+
+ 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
+ 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)
+ except (OSError, IOError):
+ self.trouble(u'ERROR: Cannot write subtitles file ' + descfn)
+ return
+ if self.params.get('onlysubtitles', False):
+ return
if self.params.get('writeinfojson', False):
infofn = filename + u'.info.json'