mb artist relationships

Get Artist Relationship urls including Discogs, Wikepedia etc.

Currently not used
This commit is contained in:
AdeHub
2019-07-14 19:59:48 +12:00
parent 14bef1e63d
commit 476ee7b312

View File

@@ -793,3 +793,28 @@ def getArtistForReleaseGroup(rgid):
return False
else:
return releaseGroup['artist-credit'][0]['artist']['name']
def getArtistRelationships(artistid):
"""
Returns list of relationship urls. e.g. Discogs, Wikipedia etc.
"""
urls = []
artist = None
try:
with mb_lock:
info = musicbrainzngs.get_artist_by_id(artistid, includes = 'url-rels' )
except musicbrainzngs.WebServiceError as e:
logger.warn(
'Attempt to query MusicBrainz for %s failed "%s"' % (artistid, str(e)))
mb_lock.snooze(5)
if 'artist' in info:
artist = info['artist']
if 'url-relation-list' in artist:
for l in artist['url-relation-list']:
urls.append({
'type': l['type'],
'url': l['target']
})
return urls