From 89c99883c89b3212a36f711da65b6399717ecc32 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 15 Sep 2021 17:14:17 +0700 Subject: [PATCH] make sure youtube_id gets written to cache file --- tubearchivist/home/src/reindex.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tubearchivist/home/src/reindex.py b/tubearchivist/home/src/reindex.py index 61d8d67..3734276 100644 --- a/tubearchivist/home/src/reindex.py +++ b/tubearchivist/home/src/reindex.py @@ -428,23 +428,22 @@ class ManualImport: """ move identified video file to cache, convert to mp4 """ file_name = os.path.split(video_path)[-1] video_file, ext = os.path.splitext(file_name) + + # make sure youtube_id is in filename if not youtube_id in video_file: - new_file_name = f'{video_file}_{youtube_id}{ext}' - new_path = os.path.join(self.CACHE_DIR, 'download', new_file_name) - else: - new_path = os.path.join(self.CACHE_DIR, 'download', file_name) + video_file = f'{video_file}_{youtube_id}' + + # move, convert if needed if ext == '.mp4': - # just move - new_path = os.path.join(self.CACHE_DIR, 'download', file_name) - shutil.move(video_path, new_path) + new_file = video_file + ext + dest_path = os.path.join(self.CACHE_DIR, 'download', new_file) + shutil.move(video_path, dest_path) else: - # needs conversion - new_path = os.path.join( - self.CACHE_DIR, 'download', video_file + '.mp4' - ) print(f'processing with ffmpeg: {video_file}') + new_file = video_file + '.mp4' + dest_path = os.path.join(self.CACHE_DIR, 'download', new_file) subprocess.run( - ["ffmpeg", "-i", video_path, new_path, + ["ffmpeg", "-i", video_path, dest_path, "-loglevel", "warning", "-stats"], check=True )