nathom / streamrip

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

[REGRESS] "Disc" subfolders ? #577

Closed benzekat75 closed 1 month ago

benzekat75 commented 6 months ago

Describe the bug

in previous versions there was a sub folder created per disc now it seems all tracks are located in the same folder

Command Used

rip url http://whatever

(was a Qobuz rip)

Debug Traceback

n/a

Config File

[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} - {title} ({year}) [{container}]"
# Available keys: "tracknumber", "artist", "albumartist", "composer", "title",
# and "albumcomposer", "explicit"
track_format = "{tracknumber}. {artist} - {title}{explicit}"
# Only allow printable ASCII characters in filenames.
restrict_characters = false
# 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

Windows

streamrip version

2.0.3

Screenshots and recordings

No response

Additional context

No response

Luisfelipeberchielli commented 6 months ago

Same problem here.

snopptobbe commented 6 months ago

very true...

benzekat75 commented 6 months ago

I realized I wasn't clear last time :)

I wanted to use something like that: folder_format = "{albumartist}\{title} ({year}) [{container}]"

snopptobbe commented 6 months ago

I realized I wasn't clear last time :)

I wanted to use something like that: folder_format = "{albumartist}{title} ({year}) [{container}]"

think you were very clear ^^...previous version that wasnt any issue automatically created subfolders disc 1 disc 2 for double cd etc..

jieweix commented 6 months ago

Repeated https://github.com/nathom/streamrip/issues/575

naiches commented 5 months ago

This makes downloading multi disc albums impossible, is there any fix?

naiches commented 5 months ago

I created a small Python script to sort the discs automatically (as a workaround) for now.

import os
import shutil
from mutagen.flac import FLAC

# Function to move files to subfolders based on disc number
def sort_discs(album_directory):
    # Iterate over all files in the album directory
    for filename in os.listdir(album_directory):
        # Check if the file is a FLAC file
        if filename.endswith('.flac'):
            file_path = os.path.join(album_directory, filename)
            # Read the metadata from the FLAC file
            audio = FLAC(file_path)
            # Extract the disc number, use 'discnumber' instead of 'part'
            if 'discnumber' in audio:
                disc_number = audio['discnumber'][0]
                disc_folder_name = f"Disc {disc_number}"
                disc_folder_path = os.path.join(album_directory, disc_folder_name)

                # Create a subfolder for the disc if it doesn't exist
                if not os.path.exists(disc_folder_path):
                    os.makedirs(disc_folder_path)

                # Move the FLAC file into the corresponding subfolder
                shutil.move(file_path, os.path.join(disc_folder_path, filename))
                print(f"Moved {filename} to {disc_folder_path}")
            else:
                print(f"No discnumber tag found for {filename}")

# Replace this with the path to your main album folder
album_directory = 'albumname'
sort_discs(album_directory)
BJReplay commented 1 month ago

I created a small Python script to sort the discs automatically (as a workaround) for now.

That's brilliant, @naiches! I expanded it to allow it to recurse through your library (or, in my case the temporary folder where I rip to, before I move to my library)

Two key changes: Moved the creation of the full path ahead of the test for a flac file (so I could use it later), and added the test for a folder, and if found, recurs into sort_discs again.

import os
import shutil
from mutagen.flac import FLAC

# Function to move files to subfolders based on disc number
def sort_discs(music_directory):
    # Iterate over all files in the album directory
    for filename in os.listdir(music_directory):
        print(filename)
        file_path = os.path.join(music_directory, filename)
        # Check if the file is a FLAC file
        if filename.endswith('.flac'):
            # Read the metadata from the FLAC file
            audio = FLAC(file_path)
            # Extract the disc number, use 'discnumber' instead of 'part'
            if 'discnumber' in audio:
                disc_number = audio['discnumber'][0]
                disc_folder_name = f"Disc {disc_number}"
                disc_folder_path = os.path.join(album_directory, disc_folder_name)

                # Create a subfolder for the disc if it doesn't exist
                if not os.path.exists(disc_folder_path):
                    os.makedirs(disc_folder_path)

                # Move the FLAC file into the corresponding subfolder
                shutil.move(file_path, os.path.join(disc_folder_path, filename))
                print(f"Moved {filename} to {disc_folder_path}")
            else:
                print(f"No discnumber tag found for {filename}")
        elif os.path.isdir(file_path):
            sort_discs(file_path)

# Replace this with the path to your main music folder
music_directory = '/mnt/f/TEMP/Music'
sort_discs(music_directory)
mortalis13 commented 1 month ago

Having disks separated in the latest version. I'd suggest using that and with a clean config file, which should be posted fully in the question btw. Should be the option disc_subdirectories that maybe didn't exist previously.

btw, I think these questions are ignored because they are not formatted as asked, with full log, full config file, and literal command...

nathom commented 1 month ago

This is closed by #679. Live on dev branch. Will be in next release.