Implemented multitagSeparator setting
This commit is contained in:
parent
ba647bc300
commit
dfb29b2397
|
@ -266,6 +266,48 @@ def getTrackData(dz, trackAPI_gw, trackAPI = None, albumAPI_gw = None, albumAPI
|
|||
monthTemp = track['album']['date']['month']
|
||||
track['album']['date']['month'] = track['album']['date']['day']
|
||||
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
|
||||
|
||||
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['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'])
|
||||
try:
|
||||
with open(writepath, 'wb') as stream:
|
||||
|
|
|
@ -13,7 +13,11 @@ def tagID3(stream, track, save, id3v1=False, nullSeparator=True):
|
|||
if save['title']:
|
||||
tag.add(TIT2(text=track['title']))
|
||||
if save['artist']:
|
||||
tag.add(TPE1(text=track['artists']))
|
||||
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']))
|
||||
if save['album']:
|
||||
tag.add(TALB(text=track['album']['title']))
|
||||
if save['albumArtist']:
|
||||
|
@ -67,7 +71,11 @@ def tagFLAC(stream, track, save):
|
|||
if save['title']:
|
||||
tag["TITLE"] = track['title']
|
||||
if save['artist']:
|
||||
tag["ARTIST"] = track['artists']
|
||||
if 'artistsString' in track:
|
||||
tag["ARTIST"] = track['artistsString']
|
||||
tag["ARTISTS"] = track['artists']
|
||||
else:
|
||||
tag["ARTIST"] = track['artists']
|
||||
if save['album']:
|
||||
tag["ALBUM"] = track['album']['title']
|
||||
if save['albumArtist']:
|
||||
|
|
Loading…
Reference in New Issue