Implemented multitagSeparator setting

This commit is contained in:
RemixDev 2020-03-21 13:47:34 +01:00
parent ba647bc300
commit dfb29b2397
2 changed files with 59 additions and 2 deletions

View File

@ -266,6 +266,48 @@ def getTrackData(dz, trackAPI_gw, trackAPI = None, albumAPI_gw = None, albumAPI
monthTemp = track['album']['date']['month'] monthTemp = track['album']['date']['month']
track['album']['date']['month'] = track['album']['date']['day'] track['album']['date']['month'] = track['album']['date']['day']
track['album']['date']['day'] = monthTemp track['album']['date']['day'] = monthTemp
# Remove featuring from the title
track['title_clean'] = track['title']
if "(feat." in track['title_clean'].lower():
pos = track['title_clean'].lower().find("(feat.")
tempTrack = track['title_clean'][:pos]
if ")" in track['title_clean']:
tempTrack += track['title_clean'][track['title_clean'].find(")",pos+1)+1:]
track['title_clean'] = tempTrack.strip()
# Create artists strings
track['mainArtistsString'] = ""
tot = len(track['artist']['Main'])
if tot > 0:
for i, art in enumerate(track['artist']['Main']):
track['mainArtistsString'] += art
if tot != i+1:
if tot-1 == i+1:
track['mainArtistsString'] += " & "
else:
track['mainArtistsString'] += ", "
else:
track['mainArtistsString'] = track['mainArtist']['name']
tot = len(track['artist']['Featured'])
if tot > 0:
track['featArtistsString'] = "feat. "
for i, art in enumerate(track['artist']['Featured']):
track['featArtistsString'] += art
if tot != i+1:
if tot-1 == i+1:
track['featArtistsString'] += " & "
else:
track['featArtistsString'] += ", "
# Create title with feat
if "(feat." in track['title'].lower():
track['title_feat'] = track['title']
elif len(artists['Featured'])>0:
track['title_feat'] = track['title']+" ({})".format(track['featArtistsString'])
else:
track['title_feat'] = track['title']
return track return track
def downloadTrackObj(dz, trackAPI, settings, overwriteBitrate=False, extraTrack=None): def downloadTrackObj(dz, trackAPI, settings, overwriteBitrate=False, extraTrack=None):
@ -333,6 +375,13 @@ def downloadTrackObj(dz, trackAPI, settings, overwriteBitrate=False, extraTrack=
result['extrasPath'] = extrasPath result['extrasPath'] = extrasPath
result['playlistPosition'] = writepath[len(extrasPath):] result['playlistPosition'] = writepath[len(extrasPath):]
# Generate artist tag if needed
if settings['multitagSeparator'] != "default":
if settings['multitagSeparator'] == "andFeat":
track['artistsString'] = track['mainArtistsString'] + " " + track['featArtistsString']
else:
track['artistsString'] = settings['multitagSeparator'].join(track[artists])
track['downloadUrl'] = dz.get_track_stream_url(track['id'], track['MD5'], track['mediaVersion'], track['selectedFormat']) track['downloadUrl'] = dz.get_track_stream_url(track['id'], track['MD5'], track['mediaVersion'], track['selectedFormat'])
try: try:
with open(writepath, 'wb') as stream: with open(writepath, 'wb') as stream:

View File

@ -13,6 +13,10 @@ def tagID3(stream, track, save, id3v1=False, nullSeparator=True):
if save['title']: if save['title']:
tag.add(TIT2(text=track['title'])) tag.add(TIT2(text=track['title']))
if save['artist']: if save['artist']:
if 'artistsString' in track:
tag.add(TPE1(text=track['artistsString']))
tag.add(TXXX(desc="ARTISTS", text=track['artists']))
else:
tag.add(TPE1(text=track['artists'])) tag.add(TPE1(text=track['artists']))
if save['album']: if save['album']:
tag.add(TALB(text=track['album']['title'])) tag.add(TALB(text=track['album']['title']))
@ -67,6 +71,10 @@ def tagFLAC(stream, track, save):
if save['title']: if save['title']:
tag["TITLE"] = track['title'] tag["TITLE"] = track['title']
if save['artist']: if save['artist']:
if 'artistsString' in track:
tag["ARTIST"] = track['artistsString']
tag["ARTISTS"] = track['artists']
else:
tag["ARTIST"] = track['artists'] tag["ARTIST"] = track['artists']
if save['album']: if save['album']:
tag["ALBUM"] = track['album']['title'] tag["ALBUM"] = track['album']['title']