From 476ee7b3124dfed80b08323b9c3d1bed92f3ce1d Mon Sep 17 00:00:00 2001 From: AdeHub Date: Sun, 14 Jul 2019 19:59:48 +1200 Subject: [PATCH] mb artist relationships Get Artist Relationship urls including Discogs, Wikepedia etc. Currently not used --- headphones/mb.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/headphones/mb.py b/headphones/mb.py index c087d6b9..0f330b81 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -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 +