diff options
| author | Pinapelz <yukais@pinapelz.com> | 2026-04-25 20:12:45 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2026-04-25 20:12:45 -0700 |
| commit | 5a38f9d8fd9253e6f7a1e2ba51cf8d124eee052e (patch) | |
| tree | 5b110ba02d056809fb166401c12c76e460a8f20e | |
| parent | 7ca095889d0753cca52bbc169f811dd153850960 (diff) | |
tag image with correct mimetype
| -rwxr-xr-x | apply_album_art.sh | 19 | ||||
| -rw-r--r-- | 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" @@ -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]: |
