From d98bd7d6d8f4169fadc93f2ac87ff73e9d4d6737 Mon Sep 17 00:00:00 2001 From: Sweetbread Date: Wed, 4 Feb 2026 15:02:22 +0300 Subject: [PATCH] fixup! Rework my page and add info from listenbrainz --- Dockerfile | 2 ++ blueprints/risdeveau/__init__.py | 4 +++- requirements.txt | 1 + shell.nix | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bfc6d69..583d00b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,8 @@ WORKDIR /app COPY . . COPY --from=sass /build/blueprints/ ./blueprints/ +RUN apt update && apt upgrade +RUN apt install libmagic1 -y RUN pip install --no-cache-dir -r requirements.txt ENV FLASK_ENV=production diff --git a/blueprints/risdeveau/__init__.py b/blueprints/risdeveau/__init__.py index 4bfb7cf..ff42d93 100644 --- a/blueprints/risdeveau/__init__.py +++ b/blueprints/risdeveau/__init__.py @@ -1,4 +1,5 @@ import os +import magic from pathlib import Path from htmlmin import minify from datetime import datetime, timedelta @@ -53,7 +54,8 @@ def static(filename: str): @bp.route("/asset/mb/") def mb_cover(mbid): - r = make_response(get_image_front(mbid, "250")) + r = make_response(image := get_image_front(mbid, "250")) + r.headers['Content-Type'] = magic.from_buffer(image[:2048], mime=True) r.headers['Cache-Control'] = 'public, max-age=86400' r.headers['Expires'] = (datetime.now() + timedelta(days=1)) \ .strftime('%a, %d %b %Y %H:%M:%S GMT') diff --git a/requirements.txt b/requirements.txt index c9aef98..75d13ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ htmlmin2 requests APScheduler musicbrainzngs +python-magic diff --git a/shell.nix b/shell.nix index a798ec6..c814697 100644 --- a/shell.nix +++ b/shell.nix @@ -7,6 +7,7 @@ pkgs.mkShell { buildInputs = with pypkgs; [ python + python-magic virtualenv pkgs.nodePackages.sass ];