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
This commit is contained in:
RemixDev 2020-05-10 11:33:46 +02:00
parent c1b5636a4f
commit d4e571bd09
2 changed files with 7 additions and 1 deletions

View File

@ -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. "

View File

@ -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']))