Added %root_artist% template variable
This commit is contained in:
parent
94f3bc95c3
commit
ff8b6da33e
|
@ -1 +0,0 @@
|
|||
# Empty File
|
|
@ -447,7 +447,7 @@ class DownloadJob:
|
|||
)
|
||||
if url: result['artistURLs'].append({'url': url, 'ext': format})
|
||||
result['artistPath'] = artistPath
|
||||
result['artistFilename'] = f"{settingsRegexArtist(self.settings['artistImageTemplate'], track.album['mainArtist'], self.settings)}"
|
||||
result['artistFilename'] = f"{settingsRegexArtist(self.settings['artistImageTemplate'], track.album['mainArtist'], self.settings, rootArtist=track.album['rootArtist'])}"
|
||||
|
||||
# Remove subfolders from filename and add it to filepath
|
||||
if pathSep in filename:
|
||||
|
|
|
@ -72,7 +72,7 @@ class QueueManager:
|
|||
single=trackAPI_gw,
|
||||
)
|
||||
|
||||
def generateAlbumQueueItem(self, dz, id, settings, bitrate):
|
||||
def generateAlbumQueueItem(self, dz, id, settings, bitrate, rootArtist=None):
|
||||
# Get essential album info
|
||||
try:
|
||||
albumAPI = dz.api.get_album(id)
|
||||
|
@ -87,6 +87,7 @@ class QueueManager:
|
|||
albumAPI_gw = dz.gw.get_album(id)
|
||||
albumAPI['nb_disk'] = albumAPI_gw['NUMBER_DISK']
|
||||
albumAPI['copyright'] = albumAPI_gw['COPYRIGHT']
|
||||
albumAPI['root_artist'] = rootArtist
|
||||
|
||||
# If the album is a single download as a track
|
||||
if albumAPI['nb_tracks'] == 1:
|
||||
|
@ -185,12 +186,16 @@ class QueueManager:
|
|||
return QueueError("https://deezer.com/artist/"+str(id), f"Wrong URL: {e['type']+': ' if 'type' in e else ''}{e['message'] if 'message' in e else ''}")
|
||||
|
||||
if interface: interface.send("startAddingArtist", {'name': artistAPI['name'], 'id': artistAPI['id']})
|
||||
rootArtist = {
|
||||
'id': artistAPI['id'],
|
||||
'name': artistAPI['name']
|
||||
}
|
||||
|
||||
artistDiscographyAPI = dz.gw.get_artist_discography_tabs(id, 100)
|
||||
allReleases = artistDiscographyAPI.pop('all', [])
|
||||
albumList = []
|
||||
for album in allReleases:
|
||||
albumList.append(self.generateAlbumQueueItem(dz, album['id'], settings, bitrate))
|
||||
albumList.append(self.generateAlbumQueueItem(dz, album['id'], settings, bitrate, rootArtist=rootArtist))
|
||||
|
||||
if interface: interface.send("finishAddingArtist", {'name': artistAPI['name'], 'id': artistAPI['id']})
|
||||
return albumList
|
||||
|
@ -204,13 +209,17 @@ class QueueManager:
|
|||
return QueueError("https://deezer.com/artist/"+str(id)+"/discography", f"Wrong URL: {e['type']+': ' if 'type' in e else ''}{e['message'] if 'message' in e else ''}")
|
||||
|
||||
if interface: interface.send("startAddingArtist", {'name': artistAPI['name'], 'id': artistAPI['id']})
|
||||
rootArtist = {
|
||||
'id': artistAPI['id'],
|
||||
'name': artistAPI['name']
|
||||
}
|
||||
|
||||
artistDiscographyAPI = dz.gw.get_artist_discography_tabs(id, 100)
|
||||
artistDiscographyAPI.pop('all', None) # all contains albums and singles, so its all duplicates. This removes them
|
||||
albumList = []
|
||||
for type in artistDiscographyAPI:
|
||||
for album in artistDiscographyAPI[type]:
|
||||
albumList.append(self.generateAlbumQueueItem(dz, album['id'], settings, bitrate))
|
||||
albumList.append(self.generateAlbumQueueItem(dz, album['id'], settings, bitrate, rootArtist=rootArtist))
|
||||
|
||||
if interface: interface.send("finishAddingArtist", {'name': artistAPI['name'], 'id': artistAPI['id']})
|
||||
return albumList
|
||||
|
|
|
@ -204,6 +204,7 @@ class Track:
|
|||
'name': albumAPI['artist']['name'],
|
||||
'pic': artistPicture
|
||||
}
|
||||
self.album['rootArtist'] = albumAPI.get('root_artist', None)
|
||||
|
||||
self.album['artist'] = {}
|
||||
self.album['artists'] = []
|
||||
|
|
|
@ -85,7 +85,7 @@ def generateFilepath(track, settings):
|
|||
(settings['createArtistFolder'] and track.playlist and settings['tags']['savePlaylistAsCompilation']) or
|
||||
(settings['createArtistFolder'] and track.playlist and settings['createStructurePlaylist'])
|
||||
):
|
||||
filepath = filepath / settingsRegexArtist(settings['artistNameTemplate'], track.album['mainArtist'], settings)
|
||||
filepath = filepath / settingsRegexArtist(settings['artistNameTemplate'], track.album['mainArtist'], settings, rootArtist=track.album['rootArtist'])
|
||||
artistPath = filepath
|
||||
|
||||
if (settings['createAlbumFolder'] and
|
||||
|
@ -168,9 +168,14 @@ def settingsRegexAlbum(foldername, album, settings, playlist=None):
|
|||
else:
|
||||
foldername = foldername.replace("%genre%", "Unknown")
|
||||
foldername = foldername.replace("%album%", fixName(album['title'], settings['illegalCharacterReplacer']))
|
||||
foldername = foldername.replace("%artist%",
|
||||
fixName(album['mainArtist']['name'], settings['illegalCharacterReplacer']))
|
||||
foldername = foldername.replace("%artist%", fixName(album['mainArtist']['name'], settings['illegalCharacterReplacer']))
|
||||
foldername = foldername.replace("%artist_id%", str(album['mainArtist']['id']))
|
||||
if album['rootArtist']:
|
||||
foldername = foldername.replace("%root_artist%", fixName(album['rootArtist']['name'], settings['illegalCharacterReplacer']))
|
||||
foldername = foldername.replace("%root_artist_id%", str(album['rootArtist']['id']))
|
||||
else:
|
||||
foldername = foldername.replace("%root_artist%", fixName(album['mainArtist']['name'], settings['illegalCharacterReplacer']))
|
||||
foldername = foldername.replace("%root_artist_id%", str(album['mainArtist']['id']))
|
||||
foldername = foldername.replace("%tracktotal%", str(album['trackTotal']))
|
||||
foldername = foldername.replace("%disctotal%", str(album['discTotal']))
|
||||
foldername = foldername.replace("%type%", fixName(album['recordType'].capitalize(), settings['illegalCharacterReplacer']))
|
||||
|
@ -185,9 +190,15 @@ def settingsRegexAlbum(foldername, album, settings, playlist=None):
|
|||
return antiDot(fixLongName(foldername))
|
||||
|
||||
|
||||
def settingsRegexArtist(foldername, artist, settings):
|
||||
def settingsRegexArtist(foldername, artist, settings, rootArtist=None):
|
||||
foldername = foldername.replace("%artist%", fixName(artist['name'], settings['illegalCharacterReplacer']))
|
||||
foldername = foldername.replace("%artist_id%", str(artist['id']))
|
||||
if rootArtist:
|
||||
foldername = foldername.replace("%root_artist%", fixName(rootArtist['name'], settings['illegalCharacterReplacer']))
|
||||
foldername = foldername.replace("%root_artist_id%", str(rootArtist['id']))
|
||||
else:
|
||||
foldername = foldername.replace("%root_artist%", fixName(artist['name'], settings['illegalCharacterReplacer']))
|
||||
foldername = foldername.replace("%root_artist_id%", str(artist['id']))
|
||||
foldername = foldername.replace('\\', pathSep).replace('/', pathSep)
|
||||
return antiDot(fixLongName(foldername))
|
||||
|
||||
|
|
Loading…
Reference in New Issue