This commit is contained in:
CodeDevMLH
2025-08-11 03:39:32 +02:00
parent 47a92f4467
commit 75f98050b8
2 changed files with 22 additions and 3 deletions

View File

@@ -951,6 +951,10 @@ def generate_track_file_path(track: Dict[str, Any], custom_dir_format: str, cust
clean_main_artist = clean_name(main_artist)
clean_title = clean_name(title)
# Prepare artist and album artist lists
artist_list = [clean_name(a) for a in re.split(r"\s*,\s*", artist_names or "") if a.strip()] or [clean_main_artist]
album_artist_list = [clean_name(a) for a in re.split(r"\s*,\s*", album_artist_names or "") if a.strip()] or [clean_album_artist]
# Prepare placeholder replacements
replacements = {
# Common placeholders
@@ -970,6 +974,21 @@ def generate_track_file_path(track: Dict[str, Any], custom_dir_format: str, cust
"%duration%": str(duration_ms // 1000) if duration_ms > 0 else "0", # Convert ms to seconds
}
artist_indices = {int(i) for i in re.findall(r"%artist_(\d+)%", custom_dir_format + custom_track_format)}
ar_album_indices = {int(i) for i in re.findall(r"%ar_album_(\d+)%", custom_dir_format + custom_track_format)}
# Replace artist placeholders with actual values
for i in artist_indices:
idx = i - 1
value = artist_list[idx] if 0 <= idx < len(artist_list) else artist_list[0]
replacements[f"%artist_{i}%"] = value
# Replace album artist placeholders with actual values
for i in ar_album_indices:
idx = i - 1
value = album_artist_list[idx] if 0 <= idx < len(album_artist_list) else album_artist_list[0]
replacements[f"%ar_album_{i}%"] = value
# Apply replacements to directory format
dir_path = custom_dir_format
for placeholder, value in replacements.items():

View File

@@ -31,9 +31,9 @@ const saveFormattingConfig = async (data: Partial<FormattingSettings>) => {
const placeholders = {
Common: {
"%music%": "Track title",
"%artist%": "Track artist",
"%artist%": "Track artist (use %arist_1%, %artist_2%, etc. for selecting specific artists)",
"%album%": "Album name",
"%ar_album%": "Album artist",
"%ar_album%": "Album artist (use %ar_album_1%, %ar_album_2%, etc. for selecting specific album artists)",
"%tracknum%": "Track number",
"%year%": "Year of release",
},