fix: serve file:// art URLs in /art endpoint for YouTube/Firefox MPRIS
This commit is contained in:
parent
38acb8bccb
commit
9738b4a6af
1 changed files with 8 additions and 3 deletions
|
|
@ -119,9 +119,13 @@ class ControlHandler(BaseHTTPRequestHandler):
|
|||
self.write_json(404, {"error": "no art"})
|
||||
return
|
||||
try:
|
||||
resp = requests.get(art_url, timeout=5)
|
||||
body = resp.content
|
||||
ctype = resp.headers.get("Content-Type", "image/jpeg")
|
||||
if art_url.startswith("file://"):
|
||||
body = open(art_url[7:], "rb").read()
|
||||
ctype = "image/png" if art_url.endswith(".png") else "image/jpeg"
|
||||
else:
|
||||
resp = requests.get(art_url, timeout=5)
|
||||
body = resp.content
|
||||
ctype = resp.headers.get("Content-Type", "image/jpeg")
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", ctype)
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
|
|
@ -163,6 +167,7 @@ class ControlHandler(BaseHTTPRequestHandler):
|
|||
self.send_response(status)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.send_header("Access-Control-Allow-Origin", "*")
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue