Fix replace_existing feature where already existing songs are always redownloaded

This commit is contained in:
KDalu 2025-01-26 14:37:38 -05:00
parent b446845911
commit c43dfcbe41
2 changed files with 4 additions and 2 deletions

View file

@ -267,9 +267,10 @@ class App:
track.metadata.extend(playable.metadata) track.metadata.extend(playable.metadata)
try: try:
output = track.create_output( output = track.create_output(
self.__config.audio_format.value.ext,
playable.library, playable.library,
playable.output_template, playable.output_template,
self.__config.replace_existing, self.__config.replace_existing
) )
except FileExistsError: except FileExistsError:
Logger.log( Logger.log(

View file

@ -65,6 +65,7 @@ class Playable:
def create_output( def create_output(
self, self,
ext: str,
library: Path | str = Path("./"), library: Path | str = Path("./"),
output: str = "{title}", output: str = "{title}",
replace: bool = False, replace: bool = False,
@ -86,7 +87,7 @@ class Playable:
"{" + meta.name + "}", fix_filename(meta.string) "{" + meta.name + "}", fix_filename(meta.string)
) )
file_path = library.joinpath(output).expanduser() 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") raise FileExistsError("File already downloaded")
else: else:
file_path.parent.mkdir(parents=True, exist_ok=True) file_path.parent.mkdir(parents=True, exist_ok=True)