Example #1
0
def get_basic_artist_pictures(mbid):
    """
    Make sure document and its dependencies are present and contain required data.

    @param mbid: a string containing a MusicBrainz ID of an artist

    @return:  a CachedArtistPictures object containing minimal data set
    """
    try:
        artist_pictures = CachedArtistPictures.get(mbid)
        if 'artist_name' not in artist_pictures:
            raise ResourceNotFound
        mmda_logger('db','present',artist_pictures._doc_type, artist_pictures.get_id)
    except ResourceNotFound:
        # overhead, but in most cases artist page
        # is a place where user will go next anyway
        artist_pictures = CachedArtistPictures.get_or_create(mbid)
        artist = get_basic_artist(mbid)
        artist_pictures.artist_name = artist.name
        if 'aliases' in artist:
            artist_pictures.artist_aliases = list(artist.aliases)
        artist_pictures.save()
        mmda_logger('db','store', artist_pictures)
    return  artist_pictures