From db5bdb9c59c83ef65ca897d968079c5f9e82b12a Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Mon, 6 Apr 2026 10:14:08 -0700 Subject: [PATCH] Fix Opus/AAC missing cover art when source FLAC has no embedded pictures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FLAC → Opus/AAC conversion only tried to read embedded art from the source FLAC. If art was only in cover.jpg (not embedded), the lossy copy got no art. Now falls back to cover.jpg in the same directory. --- web_server.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/web_server.py b/web_server.py index eaf3805d..597a3a3a 100644 --- a/web_server.py +++ b/web_server.py @@ -17042,8 +17042,32 @@ def _create_lossy_copy(final_path): from mutagen import File as MutagenFile from mutagen.flac import FLAC as MutagenFLAC source_audio = MutagenFLAC(final_path) + pic = None if source_audio and source_audio.pictures: pic = source_audio.pictures[0] + + # Fallback: read cover.jpg from the same directory + if not pic: + cover_path = os.path.join(os.path.dirname(final_path), 'cover.jpg') + if os.path.isfile(cover_path): + try: + from mutagen.flac import Picture + with open(cover_path, 'rb') as f: + img_data = f.read() + pic = Picture() + pic.type = 3 # Cover (front) + pic.mime = 'image/jpeg' + pic.desc = 'Cover' + pic.width = 0 + pic.height = 0 + pic.depth = 0 + pic.colors = 0 + pic.data = img_data + print(f"🎨 [Lossy Copy] Using cover.jpg as art source (FLAC had no embedded art)") + except Exception: + pass + + if pic: dest_audio = MutagenFile(out_path) if dest_audio is not None: if codec == 'opus':