Exemplo n.º 1
0
### Uploading proper art! ###
if VERBOSE: print "Uploading proper art...\n"

library = api.get_all_songs()
album_songs = [{
    'title': track['title'],
    'id': track['id']
} for track in library if track['album'] == ALBUM]
art_files = [{
    'title': os.path.splitext(x)[0],
    'path': x
} for x in os.listdir('AlbumArt')]
success_list = []

os.chdir("AlbumArt")
for song in album_songs:
    for artwork in art_files:
        if song['title'].replace('/', '-') == artwork['title']:
            success = webapi.upload_album_art(song['id'], artwork['path'])
            if success:
                if VERBOSE: print "Fixed art for: " + song['title']
                success_list.append(song['title'])
if VERBOSE:
    print "Fixed the artwork of " + str(len(success_list)) + "/" + str(
        len(album_songs)) + " songs."
os.chdir(BASE_DIR)
shutil.rmtree("AlbumArt")
if BACKED_UP_FOLDER:
    if VERBOSE: print "Restoring AlbumArt folder backup..."
    os.rename("AlbumArtBackup", "AlbumArt")