Artists of recordings
This commit is contained in:
@@ -534,17 +534,36 @@ def get_release_of_recording(mbid, limit, page):
|
||||
}
|
||||
|
||||
|
||||
def get_artist_of_recording(mbid, limit, page):
|
||||
def get_artist_of_recording(mbid):
|
||||
"""Obtiene el artista de una grabacion"""
|
||||
mb_artists = mb.browse_artists(params={'recording': mbid}, limit=limit,
|
||||
offset=limit * (page - 1))
|
||||
_log.info('Obteniendo el artista de la recording %s', mbid)
|
||||
|
||||
if 'error' in mb_artists:
|
||||
return mb_artists
|
||||
artist = None
|
||||
|
||||
with get_redis_connection() as redis:
|
||||
_log.debug('Intentando obtener el artista de la recording %s desde redis', mbid)
|
||||
artist_key = f'recording:{mbid}:artist'
|
||||
if artist_key in redis:
|
||||
_log.debug('Se encontro el artista de la recording %s en redis', mbid)
|
||||
artist = get_artist(redis.get(artist_key))
|
||||
else:
|
||||
_log.debug('El artista de la recording %s no estaba en redis', mbid)
|
||||
|
||||
if artist is None:
|
||||
_log.debug('Obteniendo el artista de la recording %s desde musicbrainz', mbid)
|
||||
mb_artist_browse = mb.browse_artists(params={'recording': mbid},
|
||||
includes=['tags'],
|
||||
limit=1, offset=0)
|
||||
|
||||
if 'error' in mb_artist_browse:
|
||||
_log.debug('Erro al obtener artista %s', mb_artist_browse)
|
||||
return mb_artist_browse
|
||||
|
||||
artist = mb_artist_browse.get('artists')[0]
|
||||
jobs.load_artist_on_cache.delay(artist.get('id'))
|
||||
|
||||
return {
|
||||
'paginate': paginate(mb_artists.get('artist_count', 0), limit, page),
|
||||
'artists': [map_artist(artist) for artist in mb_artists['artists']]
|
||||
'artist': artist
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user