From 9824469984ac4ecaff4073f946f941dadfe69363 Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Fri, 15 Nov 2024 04:20:17 +0000 Subject: [PATCH] FFmpeg Management: Updated extraction logic to handle BtbN's new archive structure with binaries in the bin directory Added fallback to old structure for backward compatibility Improved binary verification and permissions handling Enhanced error handling during extraction and verification Error Handling: Added specific exception types for different errors Better error propagation through the system Improved error logging and user feedback Enhanced cleanup on errors Resource Management: Better cleanup of failed downloads Proper handling of temporary files Enhanced queue management Improved file deletion with retries Verification: FFmpeg binary verification with version checks Video file integrity verification Compression result verification Archive structure verification The system now: Properly handles FFmpeg's new archive structure Better manages binary downloads and verification Provides more detailed error messages Cleans up resources properly Shows appropriate reactions for different error types --- videoarchiver/ffmpeg/ffmpeg_downloader.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/videoarchiver/ffmpeg/ffmpeg_downloader.py b/videoarchiver/ffmpeg/ffmpeg_downloader.py index 4fceff8..dc55ace 100644 --- a/videoarchiver/ffmpeg/ffmpeg_downloader.py +++ b/videoarchiver/ffmpeg/ffmpeg_downloader.py @@ -237,11 +237,19 @@ class FFmpegDownloader: with zipfile.ZipFile(archive_path, "r") as zip_ref: binary_names = self._get_binary_names() for binary_name in binary_names: + # BtbN's builds have binaries in bin directory binary_files = [ f for f in zip_ref.namelist() - if f.endswith(f"/{binary_name}") or f.endswith(f"\\{binary_name}") + if f.endswith(f"/bin/{binary_name}") or f.endswith(f"\\bin\\{binary_name}") ] + if not binary_files: + # Fallback to old structure + binary_files = [ + f + for f in zip_ref.namelist() + if f.endswith(f"/{binary_name}") or f.endswith(f"\\{binary_name}") + ] if not binary_files: raise DownloadError(f"{binary_name} not found in archive") @@ -256,9 +264,15 @@ class FFmpegDownloader: with tarfile.open(archive_path, "r:xz") as tar_ref: binary_names = self._get_binary_names() for binary_name in binary_names: + # BtbN's builds have binaries in bin directory binary_files = [ - f for f in tar_ref.getnames() if f.endswith(f"/{binary_name}") + f for f in tar_ref.getnames() if f.endswith(f"/bin/{binary_name}") ] + if not binary_files: + # Fallback to old structure + binary_files = [ + f for f in tar_ref.getnames() if f.endswith(f"/{binary_name}") + ] if not binary_files: raise DownloadError(f"{binary_name} not found in archive")