Пример #1
0
def picture(song):
    """
    Return a picture of the album containing this song
    """
    picture = get_picture(song.artist, song.title)
    return {
        'picture': picture
    }
Пример #2
0
def picture(song):
    """
    Return a picture of the album containing this song
    """
    pict = None
    if song.cover == '' or song.cover is None:
        pict = get_picture(song.artist, song.title)
        if pict:
            song.cover = pict
            song.save()
        else:
            logger.warning('no picture found for %s %s' % (song.artist,
                                                           song.title))
    return pict
Пример #3
0
def picture(song):
    """
    Return a picture of the album containing this song
    """
    if song.cover == '' or song.cover is None:

        key = 'song_image_{}_{}'.format(slugify(song.artist),
                                        slugify(song.title))

        if cache.get(key):
            pict = cache.get(key)
        else:
            pict = get_picture(song.artist, song.title)
            if pict:
                song.cover = pict
                song.save()
            else:
                pict = "http://lorempixel.com/64/64/animals/"
            cache.set(key, pict)
        return {'picture': pict}
    else:
        return {'picture': song.cover}