From 431a5e34e5ddf25728d5edd3b0605ab69c76ef16 Mon Sep 17 00:00:00 2001 From: kuba Date: Thu, 14 Nov 2024 21:14:12 +0300 Subject: [PATCH] reverted #2214 --- spotdl/download/downloader.py | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/spotdl/download/downloader.py b/spotdl/download/downloader.py index dd18d5093..1c0e108ea 100644 --- a/spotdl/download/downloader.py +++ b/spotdl/download/downloader.py @@ -458,17 +458,6 @@ def search_and_download( # pylint: disable=R0911 file_name_length=self.settings["max_filename_length"], ) - # Update output path using song.album_name if valid; otherwise, use song.artist. - output_file = ( - Path("output") - / ( - Path(song.album_name) - if Path(song.album_name).is_dir() - else Path(song.artist) - ) - / output_file - ) - except Exception: song = reinit_song(song) @@ -480,17 +469,6 @@ def search_and_download( # pylint: disable=R0911 file_name_length=self.settings["max_filename_length"], ) - # Update output path using song.album_name if valid; otherwise, use song.artist. - output_file = ( - Path("output") - / ( - Path(song.album_name) - if Path(song.album_name).is_dir() - else Path(song.artist) - ) - / output_file - ) - reinitialized = True if song.explicit is True and self.settings["skip_explicit"] is True: @@ -509,14 +487,15 @@ def search_and_download( # pylint: disable=R0911 dup_song_paths: List[Path] = self.known_songs.get(song.url, []) # Remove files from the list that have the same path as the output file - dup_song_paths = list(Path(output_file.parts[0]).rglob(output_file.name)) + dup_song_paths = [ + dup_song_path + for dup_song_path in dup_song_paths + if (dup_song_path.absolute() != output_file.absolute()) + and dup_song_path.exists() + ] # Checking if file already exists in all subfolders of output directory - file_exists = ( - next(Path(output_file.parts[0]).rglob(output_file.name), None) - or dup_song_paths - ) - + file_exists = file_exists = output_file.exists() or dup_song_paths if not self.settings["scan_for_songs"]: for file_extension in self.scan_formats: ext_path = output_file.with_suffix(f".{file_extension}")