Skip to content

Commit

Permalink
reverted #2214
Browse files Browse the repository at this point in the history
  • Loading branch information
xnetcat committed Nov 14, 2024
1 parent e80f84d commit 431a5e3
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions spotdl/download/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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:
Expand All @@ -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}")
Expand Down

0 comments on commit 431a5e3

Please sign in to comment.