Traduciendo type en artista
This commit is contained in:
@@ -2,8 +2,24 @@ import fetcher.musicbrainz as mb
|
|||||||
from utils import pretty_print_json
|
from utils import pretty_print_json
|
||||||
|
|
||||||
|
|
||||||
|
def translate_artist(artist):
|
||||||
|
type = artist.get('type', None)
|
||||||
|
if type == 'Person':
|
||||||
|
artist['type'] = 'Persona'
|
||||||
|
elif type == 'Group':
|
||||||
|
artist['type'] = 'Grupo'
|
||||||
|
elif type == 'Orchestra':
|
||||||
|
artist['type'] = 'Orquesta'
|
||||||
|
elif type == 'Choir':
|
||||||
|
artist['type'] = 'Coro'
|
||||||
|
elif type == 'Character':
|
||||||
|
artist['type'] = 'Personaje'
|
||||||
|
elif type == 'Other':
|
||||||
|
artist['type'] = 'Otro'
|
||||||
|
|
||||||
|
|
||||||
def map_artist(mb_artist):
|
def map_artist(mb_artist):
|
||||||
return {
|
artist = {
|
||||||
'id': mb_artist.get('id'),
|
'id': mb_artist.get('id'),
|
||||||
'name': mb_artist.get('name'),
|
'name': mb_artist.get('name'),
|
||||||
'sort_name': mb_artist.get('sort_name'),
|
'sort_name': mb_artist.get('sort_name'),
|
||||||
@@ -13,6 +29,10 @@ def map_artist(mb_artist):
|
|||||||
'tags': sorted(mb_artist.get('tags', []), key=lambda tag: tag['count'], reverse=True),
|
'tags': sorted(mb_artist.get('tags', []), key=lambda tag: tag['count'], reverse=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
translate_artist(artist)
|
||||||
|
|
||||||
|
return artist
|
||||||
|
|
||||||
|
|
||||||
def map_artist_credit(mb_artist_credit):
|
def map_artist_credit(mb_artist_credit):
|
||||||
pretty_print_json(mb_artist_credit)
|
pretty_print_json(mb_artist_credit)
|
||||||
@@ -173,7 +193,6 @@ def get_recording(mbid):
|
|||||||
|
|
||||||
return map_recording(mb_recording)
|
return map_recording(mb_recording)
|
||||||
|
|
||||||
|
|
||||||
def get_recordings_of_release(mbid, limit, page):
|
def get_recordings_of_release(mbid, limit, page):
|
||||||
mb_recordings = mb.browse_recordings(params={'release': mbid}, includes=['artist-credits'], limit=limit, offset=limit * (page - 1))
|
mb_recordings = mb.browse_recordings(params={'release': mbid}, includes=['artist-credits'], limit=limit, offset=limit * (page - 1))
|
||||||
if 'error' in mb_recordings:
|
if 'error' in mb_recordings:
|
||||||
|
|||||||
Reference in New Issue
Block a user