mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-25 04:35:52 +01:00
[outtmpl] Handle hard-coded file extension better
When we know that the user-provided extension is the correct final one, replace it with intermediate extension during download
This commit is contained in:
parent
dbcea0585f
commit
6a0546e313
@ -1222,9 +1222,16 @@ def _prepare_filename(self, info_dict, tmpl_type='default'):
|
|||||||
try:
|
try:
|
||||||
outtmpl = self._outtmpl_expandpath(self.outtmpl_dict.get(tmpl_type, self.outtmpl_dict['default']))
|
outtmpl = self._outtmpl_expandpath(self.outtmpl_dict.get(tmpl_type, self.outtmpl_dict['default']))
|
||||||
filename = self.evaluate_outtmpl(outtmpl, info_dict, True)
|
filename = self.evaluate_outtmpl(outtmpl, info_dict, True)
|
||||||
|
if not filename:
|
||||||
|
return None
|
||||||
|
|
||||||
force_ext = OUTTMPL_TYPES.get(tmpl_type)
|
if tmpl_type in ('default', 'temp'):
|
||||||
if filename and force_ext is not None:
|
final_ext, ext = self.params.get('final_ext'), info_dict.get('ext')
|
||||||
|
if final_ext and ext and final_ext != ext and filename.endswith(f'.{final_ext}'):
|
||||||
|
filename = replace_extension(filename, ext, final_ext)
|
||||||
|
else:
|
||||||
|
force_ext = OUTTMPL_TYPES[tmpl_type]
|
||||||
|
if force_ext:
|
||||||
filename = replace_extension(filename, force_ext, info_dict.get('ext'))
|
filename = replace_extension(filename, force_ext, info_dict.get('ext'))
|
||||||
|
|
||||||
# https://github.com/blackjack4494/youtube-dlc/issues/85
|
# https://github.com/blackjack4494/youtube-dlc/issues/85
|
||||||
|
Loading…
Reference in New Issue
Block a user