Open mzaki83 opened 2 years ago
Same Question too!
You can simply change the sanitize_filename to sanitize_filepath. I also changed the cover.jpg to folder.jpg and the track_number to a 3 digit number.
diff --git a/downloader.py b/home/qobuz/qobuz-dl-master/qobuz_dl/downloader.py
index 66ef450..dbfe36d 100644
--- a/downloader.py
+++ b/home/qobuz/qobuz-dl-master/qobuz_dl/downloader.py
@@ -4,6 +4,7 @@ from typing import Tuple
import requests
from pathvalidate import sanitize_filename
+from pathvalidate import sanitize_filepath
from tqdm import tqdm
import qobuz_dl.metadata as metadata
@@ -97,8 +98,13 @@ class Download:
folder_format, track_format = _clean_format_str(
self.folder_format, self.track_format, file_format
)
- sanitized_title = sanitize_filename(folder_format.format(**album_attr))
+ logger.info(f"\n{YELLOW}folder_format:{folder_format.format(**album_attr)}\n")
+ # sanitized_title = sanitize_filename(folder_format.format(**album_attr))
+ sanitized_title = sanitize_filepath(folder_format.format(**album_attr))
+ # sanitized_title = folder_format.format(**album_attr)
+
dirn = os.path.join(self.path, sanitized_title)
+ logger.info(f"\n{YELLOW}dirn:{dirn}\n")
os.makedirs(dirn, exist_ok=True)
if self.no_cover:
@@ -155,9 +161,11 @@ class Download:
track_attr = self._get_track_attr(
meta, track_title, bit_depth, sampling_rate
)
+ logger.info(f"\n{YELLOW}folder_format:{folder_format}\n")
sanitized_title = sanitize_filename(folder_format.format(**track_attr))
dirn = os.path.join(self.path, sanitized_title)
+ logger.info(f"\n{YELLOW}dirn:{dirn}\n")
os.makedirs(dirn, exist_ok=True)
if self.no_cover:
logger.info(f"{OFF}Skipping cover")
@@ -205,7 +213,7 @@ class Download:
root_dir = os.path.join(root_dir, f"Disc {multiple}")
os.makedirs(root_dir, exist_ok=True)
- filename = os.path.join(root_dir, f".{tmp_count:02}.tmp")
+ filename = os.path.join(root_dir, f".{tmp_count:03}.tmp")
# Determine the filename
track_title = track_metadata.get("title")
@@ -215,6 +223,7 @@ class Download:
# track_format is a format string
# e.g. '{tracknumber}. {artist} - {tracktitle}'
formatted_path = sanitize_filename(self.track_format.format(**filename_attr))
+ #logger.info(f"\n{YELLOW}root_dir:{root_dir}\n")
final_file = os.path.join(root_dir, formatted_path)[:250] + extension
if os.path.isfile(final_file):
@@ -248,7 +257,7 @@ class Download:
"sampling_rate": track_metadata["maximum_sampling_rate"],
"tracktitle": track_title,
"version": track_metadata.get("version"),
- "tracknumber": f"{track_metadata['track_number']:02}",
+ "tracknumber": f"{track_metadata['track_number']:03}",
}
@staticmethod
@@ -341,7 +350,7 @@ def _get_title(item_dict):
return album_title
-def _get_extra(item, dirn, extra="cover.jpg", og_quality=False):
+def _get_extra(item, dirn, extra="folder.jpg", og_quality=False):
extra_file = os.path.join(dirn, extra)
if os.path.isfile(extra_file):
logger.info(f"{OFF}{extra} was already downloaded")
I probably lack the knowledge/skill to make this change, but thank you for responding.
I am so sorry if this is a dumb question but I can't seem to get folder naming to work as I had hoped. Is there a way to create nested album folders within an Artist folder. For example:
default folder = /mnt/Music/
folder_format={artist}/{year} {album} [{bit_depth}B-{sampling_rate}kHz]
track_format = {tracknumber} - {tracktitle}
Result of the above is ArtistYear Album [quality]
Thanks for helping!