From d4e571bd09b31f2866332bbd9e0f3823c0eda720 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Sun, 10 May 2020 11:33:46 +0200 Subject: [PATCH] Added more artists options in the name template %artists% is now a comma separated list of artists %mainartists% is a comma and "&" separated list of artists %featartists% is like main aritsts but for featured artists --- deemix/app/downloader.py | 4 ++++ deemix/utils/pathtemplates.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/deemix/app/downloader.py b/deemix/app/downloader.py index 9b63583..022f6e3 100644 --- a/deemix/app/downloader.py +++ b/deemix/app/downloader.py @@ -355,17 +355,21 @@ def getTrackData(dz, trackAPI_gw, trackAPI=None, albumAPI_gw=None, albumAPI=None # Create artists strings track['mainArtistsString'] = "" + track['commaArtistsString'] = "" if 'Main' in track['artist']: tot = len(track['artist']['Main']) for i, art in enumerate(track['artist']['Main']): track['mainArtistsString'] += art + track['commaArtistsString'] += art if tot != i + 1: + track['commaArtistsString'] += ", " if tot - 1 == i + 1: track['mainArtistsString'] += " & " else: track['mainArtistsString'] += ", " else: track['mainArtistsString'] = track['mainArtist']['name'] + track['commaArtistsString'] = track['mainArtist']['name'] if 'Featured' in track['artist']: tot = len(track['artist']['Featured']) track['featArtistsString'] = "feat. " diff --git a/deemix/utils/pathtemplates.py b/deemix/utils/pathtemplates.py index fbc174a..61edb12 100644 --- a/deemix/utils/pathtemplates.py +++ b/deemix/utils/pathtemplates.py @@ -114,7 +114,9 @@ def generateFilepath(track, trackAPI, settings): def settingsRegex(filename, track, settings, playlist=None): filename = filename.replace("%title%", fixName(track['title'], settings['illegalCharacterReplacer'])) filename = filename.replace("%artist%", fixName(track['mainArtist']['name'], settings['illegalCharacterReplacer'])) - filename = filename.replace("%artists%", fixName(track['mainArtistsString'], settings['illegalCharacterReplacer'])) + filename = filename.replace("%artists%", fixName(track['commaArtistsString'], settings['illegalCharacterReplacer'])) + filename = filename.replace("%mainartists%", fixName(track['mainArtistsString'], settings['illegalCharacterReplacer'])) + filename = filename.replace("%featartists%", fixName('('+track['featArtistsString']+')', settings['illegalCharacterReplacer']) if 'featArtistsString' in track else "") filename = filename.replace("%album%", fixName(track['album']['title'], settings['illegalCharacterReplacer'])) filename = filename.replace("%albumartist%", fixName(track['album']['mainArtist']['name'], settings['illegalCharacterReplacer']))