Prepare V0.2
This commit is contained in:
BIN
zotify/__pycache__/album.cpython-314.pyc
Normal file
BIN
zotify/__pycache__/album.cpython-314.pyc
Normal file
Binary file not shown.
BIN
zotify/__pycache__/config.cpython-314.pyc
Normal file
BIN
zotify/__pycache__/config.cpython-314.pyc
Normal file
Binary file not shown.
Binary file not shown.
@@ -63,12 +63,25 @@ def download_album(album):
|
||||
# inject these values into the template; track-level localized metadata will be used.
|
||||
get_album_name(album)
|
||||
tracks = get_album_tracks(album)
|
||||
|
||||
# Only create Disc folders when the album truly has multiple discs.
|
||||
disc_numbers = {
|
||||
(t.get('disc_number') if isinstance(t, dict) else None) or 1
|
||||
for t in tracks
|
||||
}
|
||||
album_multi_disc = len(disc_numbers) > 1
|
||||
|
||||
for n, track in Printer.progress(enumerate(tracks, start=1), unit_scale=True, unit='Song', total=len(tracks)):
|
||||
# Only pass dynamic numbering and album_id (useful for custom templates using {album_id}).
|
||||
download_track(
|
||||
'album',
|
||||
track[ID],
|
||||
extra_keys={'album_num': str(n).zfill(2), 'album_id': album},
|
||||
extra_keys={
|
||||
'album_num': str(n).zfill(2),
|
||||
'album_id': album,
|
||||
# Used by download_track() to decide whether to insert a Disc folder.
|
||||
'album_multi_disc': '1' if album_multi_disc else '0',
|
||||
},
|
||||
disable_progressbar=True
|
||||
)
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ CONFIG_VALUES = {
|
||||
SONG_ARCHIVE: { 'default': '', 'type': str, 'arg': '--song-archive' },
|
||||
ROOT_PATH: { 'default': '', 'type': str, 'arg': '--root-path' },
|
||||
ROOT_PODCAST_PATH: { 'default': '', 'type': str, 'arg': '--root-podcast-path' },
|
||||
SPLIT_ALBUM_DISCS: { 'default': 'False', 'type': bool, 'arg': '--split-album-discs' },
|
||||
SPLIT_ALBUM_DISCS: { 'default': 'True', 'type': bool, 'arg': '--split-album-discs' },
|
||||
DOWNLOAD_LYRICS: { 'default': 'False', 'type': bool, 'arg': '--download-lyrics' },
|
||||
LYRICS_LOCATION: { 'default': '', 'type': str, 'arg': '--lyrics-location' },
|
||||
LYRICS_FILENAME: { 'default': '{artist}_{song_name}', 'type': str, 'arg': '--lyrics-filename' },
|
||||
@@ -338,10 +338,6 @@ class Config:
|
||||
else:
|
||||
raise ValueError()
|
||||
|
||||
if cls.get_split_album_discs() and mode == 'album':
|
||||
base = PurePath(v)
|
||||
return str(base.parent / 'Disc {disc_number}' / base.name)
|
||||
|
||||
return v
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -274,6 +274,24 @@ def download_track(mode: str, track_id: str, extra_keys=None, disable_progressba
|
||||
output_template = output_template.replace("{track_id}", fix_filename(track_id))
|
||||
output_template = output_template.replace("{ext}", ext)
|
||||
|
||||
# SPLIT_ALBUM_DISCS should only create a Disc folder when the album truly has multiple discs.
|
||||
# - When downloading via zotify.album.download_album(), we pass extra_keys['album_multi_disc'].
|
||||
# - As a fallback, any track with disc_number > 1 implies multi-disc.
|
||||
if mode == 'album' and Zotify.CONFIG.get_split_album_discs():
|
||||
flag_raw = extra_keys.get('album_multi_disc')
|
||||
flag = str(flag_raw).strip().lower() in ('1', 'true', 'yes')
|
||||
try:
|
||||
disc_number_int = int(disc_number)
|
||||
except Exception:
|
||||
disc_number_int = 1
|
||||
|
||||
should_create_disc_dir = flag or disc_number_int > 1
|
||||
if should_create_disc_dir:
|
||||
tpl_path = PurePath(output_template)
|
||||
disc_dir_name = f"Disc {disc_number_int}"
|
||||
if disc_dir_name not in tpl_path.parts:
|
||||
output_template = str(tpl_path.parent / disc_dir_name / tpl_path.name)
|
||||
|
||||
filename = PurePath(Zotify.CONFIG.get_root_path()).joinpath(output_template)
|
||||
filedir = PurePath(filename).parent
|
||||
|
||||
|
||||
Reference in New Issue
Block a user