Fix album_art() in __init__.py

flask.send_file() expects a string, g.lib.get_album() returns bytes. Added decode() to album_art(). 

If g.lib.get_album() gets a non-existing id, it returns None. Python would throw an error in this case. Added check to prevent this.
This commit is contained in:
waweic 2018-02-26 18:33:30 +01:00 committed by GitHub
parent 1254d48b72
commit be96c1022a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -285,8 +285,8 @@ def album_query(queries):
@app.route('/album/<int:album_id>/art')
def album_art(album_id):
album = g.lib.get_album(album_id)
if album.artpath:
return flask.send_file(album.artpath)
if album and album.artpath:
return flask.send_file(album.artpath.decode())
else:
return flask.abort(404)