aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rwxr-xr-xapply_album_art.sh38
2 files changed, 41 insertions, 0 deletions
diff --git a/README.md b/README.md
index 19b2c66..5736f26 100644
--- a/README.md
+++ b/README.md
@@ -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
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage