-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented the retrieval of labels through brainzutils
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from brainzutils import cache | ||
from brainzutils.musicbrainz_db.label import fetch_multiple_labels | ||
from critiquebrainz.frontend.external.musicbrainz_db import DEFAULT_CACHE_EXPIRATION | ||
|
||
|
||
def get_label_by_id(mbid): | ||
"""Get label with MusicBrainz ID. | ||
Args: | ||
mbid (uuid): MBID(gid) of the label. | ||
Returns: | ||
Dictionary containing the label information | ||
""" | ||
key = cache.gen_key(mbid) | ||
label = cache.get(key) | ||
if not label: | ||
label = fetch_multiple_labels( | ||
[mbid], | ||
includes=['artist-rels', 'url-rels'], | ||
).get(mbid) | ||
cache.set(key=key, val=label, time=DEFAULT_CACHE_EXPIRATION) | ||
return label |