mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-12-17 05:28:54 +00:00
[FFmpegExtractAudioPP] Fix --no-overwrites not working for post-processed files
- Make --no-overwrites option also prevent overwriting of post-processed files - Fix buggy logic that checked for non-existent orig_path - Add overwrites parameter to FFmpegExtractAudioPP constructor - Add comprehensive tests for both --no-overwrites and --no-post-overwrites - Maintain backward compatibility with existing --no-post-overwrites behavior Fixes issue where --no-overwrites had no effect on extracted audio files
This commit is contained in:
@@ -441,11 +441,12 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
||||
SUPPORTED_EXTS = tuple(ACODECS.keys())
|
||||
FORMAT_RE = create_mapping_re(('best', *SUPPORTED_EXTS))
|
||||
|
||||
def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, nopostoverwrites=False):
|
||||
def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, nopostoverwrites=False, overwrites=None):
|
||||
FFmpegPostProcessor.__init__(self, downloader)
|
||||
self.mapping = preferredcodec or 'best'
|
||||
self._preferredquality = float_or_none(preferredquality)
|
||||
self._nopostoverwrites = nopostoverwrites
|
||||
self._overwrites = overwrites
|
||||
|
||||
def _quality_args(self, codec):
|
||||
if self._preferredquality is None:
|
||||
@@ -521,8 +522,13 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
||||
return [], information
|
||||
orig_path = prepend_extension(path, 'orig')
|
||||
temp_path = prepend_extension(path, 'temp')
|
||||
if (self._nopostoverwrites and os.path.exists(new_path)
|
||||
and os.path.exists(orig_path)):
|
||||
# Check if we should skip due to existing file
|
||||
# Respect both --no-overwrites and --no-post-overwrites
|
||||
should_skip_overwrite = (
|
||||
(self._nopostoverwrites or self._overwrites is False)
|
||||
and os.path.exists(new_path)
|
||||
)
|
||||
if should_skip_overwrite:
|
||||
self.to_screen(f'Post-process file {new_path} exists, skipping')
|
||||
return [], information
|
||||
|
||||
|
||||
Reference in New Issue
Block a user