diff --git a/src/ytdl_sub/utils/ffmpeg.py b/src/ytdl_sub/utils/ffmpeg.py index e53e405e..605fb80a 100644 --- a/src/ytdl_sub/utils/ffmpeg.py +++ b/src/ytdl_sub/utils/ffmpeg.py @@ -68,7 +68,7 @@ class FFMPEG: """ cls._ensure_installed() - cmd = ["ffmpeg"] + cmd = [".\\ffmpeg.exe" if IS_WINDOWS else "ffmpeg"] cmd.extend(ffmpeg_args) logger.debug("Running %s", " ".join(cmd)) with Logger.handle_external_logs(name="ffmpeg"): diff --git a/src/ytdl_sub/utils/thumbnail.py b/src/ytdl_sub/utils/thumbnail.py index 9ba26244..c1408ac7 100644 --- a/src/ytdl_sub/utils/thumbnail.py +++ b/src/ytdl_sub/utils/thumbnail.py @@ -64,18 +64,20 @@ def convert_url_thumbnail(thumbnail_url: str, output_thumbnail_path: str) -> Opt """ # timeout after 8 seconds with urlopen(thumbnail_url, timeout=1.0) as file: - with tempfile.NamedTemporaryFile() as thumbnail: + with tempfile.NamedTemporaryFile(delete=False) as thumbnail: thumbnail.write(file.read()) - os.makedirs(os.path.dirname(output_thumbnail_path), exist_ok=True) + os.makedirs(os.path.dirname(output_thumbnail_path), exist_ok=True) - tmp_output_path = FFMPEG.tmp_file_path( - relative_file_path=thumbnail.name, extension="jpg" - ) - FFMPEG.run(["-bitexact", "-i", thumbnail.name, tmp_output_path]) + tmp_output_path = FFMPEG.tmp_file_path( + relative_file_path=thumbnail.name, extension="jpg" + ) + FFMPEG.run(["-bitexact", "-i", thumbnail.name, tmp_output_path]) - # Have FileHandler handle the move to a potential cross-device - FileHandler.move(tmp_output_path, output_thumbnail_path) - FileHandler.delete(tmp_output_path) + # Have FileHandler handle the move to a potential cross-device + FileHandler.move(tmp_output_path, output_thumbnail_path) + FileHandler.delete(tmp_output_path) + + os.remove(thumbnail.name) return True