From be96c1022a82774fbbc7d4de421c14c286ca14d8 Mon Sep 17 00:00:00 2001 From: waweic Date: Mon, 26 Feb 2018 18:33:30 +0100 Subject: [PATCH 1/2] 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. --- beetsplug/web/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 635c2f5a8..9de44dcb4 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -285,8 +285,8 @@ def album_query(queries): @app.route('/album//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) From 8793bb0882fa60c339470839ed72cf436627672e Mon Sep 17 00:00:00 2001 From: waweic Date: Tue, 27 Feb 2018 22:37:05 +0100 Subject: [PATCH 2/2] Update changelog.rst Add the changelog entry --- docs/changelog.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index a4dfd2cb4..26de4dfaa 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -71,6 +71,10 @@ Fixes: * :doc:`/plugins/web`: The time display in the web interface would incorrectly jump at the 30-second mark of every minute. Now, it correctly changes over at zero seconds. :bug:`2822` +* :doc:`/plugins/web`: In a python 3 enviroment, the function to fetch the + album art would not work and throw an exception. It now works as expected. + Additionally, the server will now return a 404 response when the album id + is unknown, instead of a 500 response and a thrown exception. :bug:`2823` For developers: