nathom / streamrip

A scriptable music downloader for Qobuz, Tidal, SoundCloud, and Deezer
GNU General Public License v3.0
2.6k stars 228 forks source link

[BUG] set_playlist_to_album = false dont works #605

Open WMP opened 8 months ago

WMP commented 8 months ago

Describe the bug

I have a playlist on deezer with various tracks and bands, I want them to download as: {Artist}/{Album}/{Artist} - {Track}.mp3 . Unfortunately, when I use the option set_playlist_to_album = false they still download to {Playlist}/{Artist} - {Track}.mp3

Command Used

rip url https://deezer.page.link/wJ7pC2wZLLZ4GLhv8

Debug Traceback

Nothing interested

Config File

[metadata]
# Sets the value of the 'ALBUM' field in the metadata to the playlist's name. 
# This is useful if your music library software organizes tracks based on album name.
set_playlist_to_album = false
# If part of a playlist, sets the `tracknumber` field in the metadata to the track's 
# position in the playlist instead of its position in its album
renumber_playlist_tracks = false
# The following metadata tags won't be applied
# See https://github.com/nathom/streamrip/wiki/Metadata-Tag-Names for more info
exclude = []

# Changes the folder and file names generated by streamrip.
[filepaths]
# Create folders for single tracks within the downloads directory using the folder_format
# template
add_singles_to_folder = false
# Available keys: "albumartist", "title", "year", "bit_depth", "sampling_rate",
# "id", and "albumcomposer"
#folder_format = "{albumartist} - {title} ({year}) [{container}] [{bit_depth}B-{sampling_rate}kHz]"
folder_format = "{albumartist}"
# Available keys: "tracknumber", "artist", "albumartist", "composer", "title",
# and "albumcomposer", "explicit"
#track_format = "{tracknumber}. {artist} - {title}{explicit}"
track_format = "{albumartist} - {title}"
# Only allow printable ASCII characters in filenames.
restrict_characters = true
# Truncate the filename if it is greater than this number of characters
# Setting this to false may cause downloads to fail on some systems
truncate_to = 120

Operating System

Linux

streamrip version

2.0.5

Screenshots and recordings

No response

Additional context

No response

WMP commented 8 months ago

I am thinking of a similar code:

diff --git a/streamrip/media/playlist.py b/streamrip/media/playlist.py
index 2e84a85..3e3f8a0 100644
--- a/streamrip/media/playlist.py
+++ b/streamrip/media/playlist.py
@@ -27,6 +27,7 @@ from ..metadata import (
 from .artwork import download_artwork
 from .media import Media, Pending
 from .track import Track
+from .album import PendingAlbum

 logger = logging.getLogger("streamrip")

@@ -71,6 +72,10 @@ class PendingPlaylistTrack(Pending):
             meta.tracknumber = self.position
         if c.set_playlist_to_album:
             album.album = self.playlist_name
+        else:
+            album_folder = PendingAlbum._album_folder(self, self.folder, album)
+            self.folder = album_folder
+            os.makedirs(album_folder, exist_ok=True)

         quality = self.config.session.get_source(self.client.source).quality
         try:
nathom commented 8 months ago

Not a bug. More like an implementation of a playlist_path key in config.