mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 14:14:54 +01:00
[EmbedThumbnail] Do not obey -k
This commit is contained in:
parent
94aa064497
commit
43d7f5a5d0
|
@ -3307,6 +3307,17 @@ def filter_requested_info(info_dict, actually_filter=True):
|
||||||
''' Alias of sanitize_info for backward compatibility '''
|
''' Alias of sanitize_info for backward compatibility '''
|
||||||
return YoutubeDL.sanitize_info(info_dict, actually_filter)
|
return YoutubeDL.sanitize_info(info_dict, actually_filter)
|
||||||
|
|
||||||
|
def _delete_downloaded_files(self, *files_to_delete, info={}, msg=None):
|
||||||
|
for filename in set(filter(None, files_to_delete)):
|
||||||
|
if msg:
|
||||||
|
self.to_screen(msg % filename)
|
||||||
|
try:
|
||||||
|
os.remove(filename)
|
||||||
|
except OSError:
|
||||||
|
self.report_warning(f'Unable to delete file {filename}')
|
||||||
|
if filename in info.get('__files_to_move', []): # NB: Delete even if None
|
||||||
|
del info['__files_to_move'][filename]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def post_extract(info_dict):
|
def post_extract(info_dict):
|
||||||
def actual_post_extract(info_dict):
|
def actual_post_extract(info_dict):
|
||||||
|
@ -3339,14 +3350,8 @@ def run_pp(self, pp, infodict):
|
||||||
for f in files_to_delete:
|
for f in files_to_delete:
|
||||||
infodict['__files_to_move'].setdefault(f, '')
|
infodict['__files_to_move'].setdefault(f, '')
|
||||||
else:
|
else:
|
||||||
for old_filename in set(files_to_delete):
|
self._delete_downloaded_files(
|
||||||
self.to_screen('Deleting original file %s (pass -k to keep)' % old_filename)
|
*files_to_delete, info=infodict, msg='Deleting original file %s (pass -k to keep)')
|
||||||
try:
|
|
||||||
os.remove(encodeFilename(old_filename))
|
|
||||||
except OSError:
|
|
||||||
self.report_warning('Unable to remove downloaded original file')
|
|
||||||
if old_filename in infodict['__files_to_move']:
|
|
||||||
del infodict['__files_to_move'][old_filename]
|
|
||||||
return infodict
|
return infodict
|
||||||
|
|
||||||
def run_all_pps(self, key, info, *, additional_pps=None):
|
def run_all_pps(self, key, info, *, additional_pps=None):
|
||||||
|
|
|
@ -92,6 +92,12 @@ def write_debug(self, text, *args, **kwargs):
|
||||||
if self._downloader:
|
if self._downloader:
|
||||||
return self._downloader.write_debug(text, *args, **kwargs)
|
return self._downloader.write_debug(text, *args, **kwargs)
|
||||||
|
|
||||||
|
def _delete_downloaded_files(self, *files_to_delete, **kwargs):
|
||||||
|
if not self._downloader:
|
||||||
|
for filename in set(filter(None, files_to_delete)):
|
||||||
|
os.remove(filename)
|
||||||
|
return self._downloader._delete_downloaded_files(*files_to_delete, **kwargs)
|
||||||
|
|
||||||
def get_param(self, name, default=None, *args, **kwargs):
|
def get_param(self, name, default=None, *args, **kwargs):
|
||||||
if self._downloader:
|
if self._downloader:
|
||||||
return self._downloader.params.get(name, default, *args, **kwargs)
|
return self._downloader.params.get(name, default, *args, **kwargs)
|
||||||
|
|
|
@ -220,11 +220,9 @@ def run(self, info):
|
||||||
os.replace(temp_filename, filename)
|
os.replace(temp_filename, filename)
|
||||||
|
|
||||||
self.try_utime(filename, mtime, mtime)
|
self.try_utime(filename, mtime, mtime)
|
||||||
|
converted = original_thumbnail != thumbnail_filename
|
||||||
files_to_delete = [thumbnail_filename]
|
self._delete_downloaded_files(
|
||||||
if self._already_have_thumbnail:
|
thumbnail_filename if converted or not self._already_have_thumbnail else None,
|
||||||
if original_thumbnail == thumbnail_filename:
|
original_thumbnail if converted and not self._already_have_thumbnail else None,
|
||||||
files_to_delete = []
|
info=info)
|
||||||
elif original_thumbnail != thumbnail_filename:
|
return [], info
|
||||||
files_to_delete.append(original_thumbnail)
|
|
||||||
return files_to_delete, info
|
|
||||||
|
|
|
@ -374,7 +374,7 @@ def concat_files(self, in_files, out_file, concat_opts=None):
|
||||||
self.real_run_ffmpeg(
|
self.real_run_ffmpeg(
|
||||||
[(concat_file, ['-hide_banner', '-nostdin', '-f', 'concat', '-safe', '0'])],
|
[(concat_file, ['-hide_banner', '-nostdin', '-f', 'concat', '-safe', '0'])],
|
||||||
[(out_file, out_flags)])
|
[(out_file, out_flags)])
|
||||||
os.remove(concat_file)
|
self._delete_downloaded_files(concat_file)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _concat_spec(cls, in_files, concat_opts=None):
|
def _concat_spec(cls, in_files, concat_opts=None):
|
||||||
|
@ -701,8 +701,7 @@ def run(self, info):
|
||||||
self.run_ffmpeg_multiple_files(
|
self.run_ffmpeg_multiple_files(
|
||||||
(filename, metadata_filename), temp_filename,
|
(filename, metadata_filename), temp_filename,
|
||||||
itertools.chain(self._options(info['ext']), *options))
|
itertools.chain(self._options(info['ext']), *options))
|
||||||
for file in filter(None, files_to_delete):
|
self._delete_downloaded_files(*files_to_delete)
|
||||||
os.remove(file) # Don't obey --keep-files
|
|
||||||
os.replace(temp_filename, filename)
|
os.replace(temp_filename, filename)
|
||||||
return [], info
|
return [], info
|
||||||
|
|
||||||
|
@ -1049,7 +1048,7 @@ def run(self, info):
|
||||||
destination, opts = self._ffmpeg_args_for_chapter(idx + 1, chapter, info)
|
destination, opts = self._ffmpeg_args_for_chapter(idx + 1, chapter, info)
|
||||||
self.real_run_ffmpeg([(in_file, opts)], [(destination, self.stream_copy_opts())])
|
self.real_run_ffmpeg([(in_file, opts)], [(destination, self.stream_copy_opts())])
|
||||||
if in_file != info['filepath']:
|
if in_file != info['filepath']:
|
||||||
os.remove(in_file)
|
self._delete_downloaded_files(in_file, msg=None)
|
||||||
return [], info
|
return [], info
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -314,7 +314,7 @@ def remove_chapters(self, filename, ranges_to_cut, concat_opts, force_keyframes=
|
||||||
self.to_screen(f'Removing chapters from {filename}')
|
self.to_screen(f'Removing chapters from {filename}')
|
||||||
self.concat_files([in_file] * len(concat_opts), out_file, concat_opts)
|
self.concat_files([in_file] * len(concat_opts), out_file, concat_opts)
|
||||||
if in_file != filename:
|
if in_file != filename:
|
||||||
os.remove(in_file)
|
self._delete_downloaded_files(in_file, msg=None)
|
||||||
return out_file
|
return out_file
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue
Block a user