From c43dfcbe41eca95cf6c440c9ad9009f5c822da19 Mon Sep 17 00:00:00 2001 From: KDalu <71458929+KDalu@users.noreply.github.com> Date: Sun, 26 Jan 2025 14:37:38 -0500 Subject: [PATCH] Fix replace_existing feature where already existing songs are always redownloaded --- zotify/app.py | 3 ++- zotify/playable.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/zotify/app.py b/zotify/app.py index 3ef8e2d..4c25cb1 100644 --- a/zotify/app.py +++ b/zotify/app.py @@ -267,9 +267,10 @@ class App: track.metadata.extend(playable.metadata) try: output = track.create_output( + self.__config.audio_format.value.ext, playable.library, playable.output_template, - self.__config.replace_existing, + self.__config.replace_existing ) except FileExistsError: Logger.log( diff --git a/zotify/playable.py b/zotify/playable.py index 083ba3d..aa7fa7c 100644 --- a/zotify/playable.py +++ b/zotify/playable.py @@ -65,6 +65,7 @@ class Playable: def create_output( self, + ext: str, library: Path | str = Path("./"), output: str = "{title}", replace: bool = False, @@ -86,7 +87,7 @@ class Playable: "{" + meta.name + "}", fix_filename(meta.string) ) file_path = library.joinpath(output).expanduser() - if file_path.exists() and not replace: + if file_path.with_suffix("." + ext).exists() and not replace: raise FileExistsError("File already downloaded") else: file_path.parent.mkdir(parents=True, exist_ok=True)