From f89b3e2d7ab7a6e28fc1d9975aa4e998b165c090 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sun, 20 Jun 2021 04:15:19 +0530 Subject: [PATCH] Skip fixup of existing files and add `--fixup force` to force it --- yt_dlp/YoutubeDL.py | 5 ++++- yt_dlp/options.py | 5 +++-- yt_dlp/postprocessor/ffmpeg.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 37af2f3fb..b4ac1f00a 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -2690,7 +2690,10 @@ class YoutubeDL(object): return elif fixup_policy == 'warn': do_fixup = False - assert fixup_policy in ('detect_or_warn', None) + elif fixup_policy != 'force': + assert fixup_policy in ('detect_or_warn', None) + if not info_dict.get('__real_download'): + do_fixup = False def ffmpeg_fixup(cndn, msg, cls): if not cndn: diff --git a/yt_dlp/options.py b/yt_dlp/options.py index 0d1960d9f..b26d43d2a 100644 --- a/yt_dlp/options.py +++ b/yt_dlp/options.py @@ -1230,11 +1230,12 @@ def parseOpts(overrideArguments=None): postproc.add_option( '--fixup', metavar='POLICY', dest='fixup', default=None, - choices=('never', 'ignore', 'warn', 'detect_or_warn'), + choices=('never', 'ignore', 'warn', 'detect_or_warn', 'force'), help=( 'Automatically correct known faults of the file. ' 'One of never (do nothing), warn (only emit a warning), ' - 'detect_or_warn (the default; fix file if we can, warn otherwise)')) + 'detect_or_warn (the default; fix file if we can, warn otherwise), ' + 'force (try fixing even if file already exists')) postproc.add_option( '--prefer-avconv', '--no-prefer-ffmpeg', action='store_false', dest='prefer_ffmpeg', diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 49685951e..4685288a7 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -665,7 +665,7 @@ class FFmpegFixupPostProcessor(FFmpegPostProcessor): def _fixup(self, msg, filename, options): temp_filename = prepend_extension(filename, 'temp') - self.to_screen('{msg} of "{filename}"') + self.to_screen(f'{msg} of "{filename}"') self.run_ffmpeg(filename, temp_filename, options) os.remove(encodeFilename(filename))