diff options
| author | Pinapelz <yukais@pinapelz.com> | 2026-04-25 20:01:05 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2026-04-25 20:02:52 -0700 |
| commit | 7ca095889d0753cca52bbc169f811dd153850960 (patch) | |
| tree | bb602d990599ae9d953b25320c236c55ae1cf531 | |
| parent | 7616457c8915adab19d97b23c85beeda12fc789b (diff) | |
add apply_album_art.sh
| -rw-r--r-- | README.md | 3 | ||||
| -rwxr-xr-x | apply_album_art.sh | 38 |
2 files changed, 41 insertions, 0 deletions
@@ -26,3 +26,6 @@ uv run main.py <base_dir> [--nolrc] [-n num_threads] ``` Example: `uv run main.py <DIR_WITH_MUSIC>` + +# Other Tools +`apply_album_art.sh` - Recursively traverse all folders, automatically apply album art and resize to all FLACs that have a JPG/PNG in the same directory diff --git a/apply_album_art.sh b/apply_album_art.sh new file mode 100755 index 0000000..eb13ce6 --- /dev/null +++ b/apply_album_art.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [[ $# -lt 1 ]]; then + echo "Usage: $0 <directory>" + exit 1 +fi + +input_dir="$1" + +find "$input_dir" -type d | while read -r dir; do + image="" + for ext in jpg JPG jpeg JPEG png PNG; do + found=$(find "$dir" -maxdepth 1 -type f -name "*.${ext}" | head -n 1) + if [[ -n "${found:-}" ]]; then + image="$found" + break + fi + done + [[ -z "$image" ]] && continue + echo "Processing folder: $dir" + echo "Using image: $image" + temp_cover="$(mktemp --suffix=.jpg)" + 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" + done + + rm -f "$temp_cover" +done |
