mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-08-26 17:21:48 +02:00
[youtube] convert subtitles with --skip-download
This commit is contained in:
parent
84da5d84b0
commit
57df9f53e0
@ -105,6 +105,7 @@
|
|||||||
FFmpegFixupStretchedPP,
|
FFmpegFixupStretchedPP,
|
||||||
FFmpegMergerPP,
|
FFmpegMergerPP,
|
||||||
FFmpegPostProcessor,
|
FFmpegPostProcessor,
|
||||||
|
FFmpegSubtitlesConvertorPP,
|
||||||
get_postprocessor,
|
get_postprocessor,
|
||||||
)
|
)
|
||||||
from .version import __version__
|
from .version import __version__
|
||||||
@ -1846,6 +1847,29 @@ def dl(name, info):
|
|||||||
(sub_lang, error_to_compat_str(err)))
|
(sub_lang, error_to_compat_str(err)))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if self.params.get('skip_download', False):
|
||||||
|
if self.params.get('convertsubtitles', False):
|
||||||
|
subconv = FFmpegSubtitlesConvertorPP(self, format=self.params.get('convertsubtitles'))
|
||||||
|
filename_real_ext = os.path.splitext(filename)[1][1:]
|
||||||
|
filename_wo_ext = (
|
||||||
|
os.path.splitext(filename)[0]
|
||||||
|
if filename_real_ext == info_dict['ext']
|
||||||
|
else filename)
|
||||||
|
afilename = '%s.%s' % (filename_wo_ext, self.params.get('convertsubtitles'))
|
||||||
|
if subconv.available:
|
||||||
|
info_dict.setdefault('__postprocessors', [])
|
||||||
|
# info_dict['__postprocessors'].append(subconv)
|
||||||
|
if os.path.exists(encodeFilename(afilename)):
|
||||||
|
self.to_screen(
|
||||||
|
'[download] %s has already been downloaded and '
|
||||||
|
'converted' % afilename)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
self.post_process(filename, info_dict)
|
||||||
|
except (PostProcessingError) as err:
|
||||||
|
self.report_error('postprocessing: %s' % str(err))
|
||||||
|
return
|
||||||
|
|
||||||
if self.params.get('writeinfojson', False):
|
if self.params.get('writeinfojson', False):
|
||||||
infofn = replace_extension(filename, 'info.json', info_dict.get('ext'))
|
infofn = replace_extension(filename, 'info.json', info_dict.get('ext'))
|
||||||
if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(infofn)):
|
if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(infofn)):
|
||||||
|
@ -315,6 +315,7 @@ def parse_retries(retries):
|
|||||||
else match_filter_func(opts.match_filter))
|
else match_filter_func(opts.match_filter))
|
||||||
|
|
||||||
ydl_opts = {
|
ydl_opts = {
|
||||||
|
'convertsubtitles': opts.convertsubtitles,
|
||||||
'usenetrc': opts.usenetrc,
|
'usenetrc': opts.usenetrc,
|
||||||
'username': opts.username,
|
'username': opts.username,
|
||||||
'password': opts.password,
|
'password': opts.password,
|
||||||
|
Loading…
Reference in New Issue
Block a user