From 5a38f9d8fd9253e6f7a1e2ba51cf8d124eee052e Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Sat, 25 Apr 2026 20:12:45 -0700 Subject: tag image with correct mimetype --- apply_album_art.sh | 19 ++++++++++++++----- main.py | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apply_album_art.sh b/apply_album_art.sh index eb13ce6..8ee6d51 100755 --- a/apply_album_art.sh +++ b/apply_album_art.sh @@ -21,17 +21,26 @@ find "$input_dir" -type d | while read -r dir; do [[ -z "$image" ]] && continue echo "Processing folder: $dir" echo "Using image: $image" - temp_cover="$(mktemp --suffix=.jpg)" + + ext_lower="${image##*.}" + ext_lower="${ext_lower,,}" + if [[ "$ext_lower" == "png" ]]; then + mimetype="image/png" + suffix=".png" + else + mimetype="image/jpeg" + suffix=".jpg" + fi + + temp_cover="$(mktemp --suffix=${suffix})" ffmpeg -y -i "$image" \ -vf "scale=500:500:force_original_aspect_ratio=decrease,pad=500:500:(ow-iw)/2:(oh-ih)/2" \ "$temp_cover" >/dev/null 2>&1 find "$dir" -maxdepth 1 -type f -iname "*.flac" | while read -r flac; do echo "Tagging: $flac" - metaflac \ - --remove-tag=METADATA_BLOCK_PICTURE \ - --import-picture-from="$temp_cover" \ - "$flac" + metaflac --remove --block-type=PICTURE "$flac" + metaflac --import-picture-from="3|${mimetype}|||$temp_cover" "$flac" done rm -f "$temp_cover" diff --git a/main.py b/main.py index cb3eaae..714f61b 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ import syncedlyrics from mutagen.flac import FLAC import ffmpeg -_lyrics_semaphore = threading.Semaphore(1) +_lyrics_semaphore = threading.Semaphore(3) def iter_files(base: Path) -> Iterator[Path]: -- cgit v1.2.3