From fe4a15ff75ca94dfdad3e83e1c7c0759d39efecf Mon Sep 17 00:00:00 2001 From: Kieran Eglin Date: Tue, 23 Apr 2024 11:54:38 -0700 Subject: [PATCH] First pass at test feedback --- yt_dlp/postprocessor/movefilesafterdownload.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/yt_dlp/postprocessor/movefilesafterdownload.py b/yt_dlp/postprocessor/movefilesafterdownload.py index 4e3344ebd5..cb4c1cd1c6 100644 --- a/yt_dlp/postprocessor/movefilesafterdownload.py +++ b/yt_dlp/postprocessor/movefilesafterdownload.py @@ -21,6 +21,9 @@ def pp_key(cls): def expand_relative_paths(self, files_to_move, finaldir): for filetype in self.FILETYPE_KEYS: + if filetype not in files_to_move: + files_to_move[filetype] = [] + for file_attrs in files_to_move[filetype]: if not os.path.isabs(file_attrs['final_filepath']): file_attrs['final_filepath'] = os.path.join(finaldir, file_attrs['final_filepath']) @@ -45,8 +48,7 @@ def write_filepath_into_info(self, info, filetype, file_attrs): def run(self, info): dl_path, dl_name = os.path.split(info['filepath']) - finaldir = info.get('__finaldir', dl_path) - info['__files_to_move']['media'] = [] + finaldir = info.get('__finaldir', os.path.abspath(dl_path)) if self._downloaded: info['__files_to_move']['media'] = [{'current_filepath': info['filepath'], 'final_filepath': dl_name}] @@ -54,9 +56,6 @@ def run(self, info): files_to_move = self.expand_relative_paths(info['__files_to_move'], finaldir) for filetype in self.FILETYPE_KEYS: - if filetype not in files_to_move: - continue - for file_attrs in files_to_move[filetype]: current_filepath = file_attrs['current_filepath'] final_filepath = file_attrs['final_filepath']