Esempio n. 1
0
def set_album_cover(track_info):
    if track_info['album'].image:
        # we already have a cover
        return track_info['album'].image

    if not os.path.exists(COVERSDIR):
        os.mkdir(COVERSDIR)

    filename = hashlib.sha1(track_info['album'].name).hexdigest() + '.png'
    path = os.path.join(COVERSDIR, filename)
    result = fetch_cover(track_info['artist'].name, track_info['album'].name, path)
    if not result:
        return None

    track_info['album'].image = path
    return path
Esempio n. 2
0
def test_bad_album():
    assert fetch_cover('Arcade Fire', 'they have no album like this', '/tmp/test-cover-3.png') == None
Esempio n. 3
0
def test_success():
    assert fetch_cover('Arcade Fire', 'Neon Bible', '/tmp/test-cover-1.png') == '/tmp/test-cover-1.png'
Esempio n. 4
0
def test_bad_artist():
    assert fetch_cover('abcdefghijklmnopqrstuvwxyz', 'Neon Bible', '/tmp/test-cover-2.png') == None