Respond with noart.png when no cover art is available

This commit is contained in:
Yoshi Askharoun
2021-08-01 23:31:36 -05:00
parent ea194bbb6b
commit c00e283dff
2 changed files with 3 additions and 3 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
import json
from flask import Flask, request, Response, abort
from flask import Flask, request, Response, abort, send_file
import urllib.request
from urllib.error import HTTPError
@@ -44,7 +44,7 @@ def get_image(mbid: str, locale: str):
image = urllib.request.urlopen(f"http://coverartarchive.org/release/{mbid}/front-{width}")
return Response(image.read(), mimetype="image/jpeg")
except urllib.error.HTTPError as error:
abort(error.code)
return send_file('noart.png', attachment_filename='noart.png')
@app.route("/v3.2/<string:locale>/music/artist/<string:mbid>/primaryImage")
@@ -77,4 +77,4 @@ def get_artist_primary_image(mbid: str, locale: str):
if __name__ == "__main__":
app.run(port=80)
app.run(host="127.0.0.1", port=80)
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB