chore(audiobook_metadata): move audiobook scripts
This commit is contained in:
1 parent
bc26e4dbb0
commit
30dfc6fa53
17 files changed
No files matched your search
+64
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
set -Eeuo pipefail
|
||||
escape_kid3() {
|
||||
printf '%s' "$1" | sed "s/'/'\\\\''/g"
|
||||
}
|
||||
DRY_RUN=false
|
||||
|
||||
if [[ "$1" == "--dry-run" ]]; then
|
||||
DRY_RUN=true
|
||||
shift
|
||||
fi
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 [--dry-run] file.txt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
list="$1"
|
||||
|
||||
if [[ ! -f "$list" ]]; then
|
||||
echo "ERROR: File list not found: $list"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while IFS= read -r file; do
|
||||
|
||||
[[ -z "$file" ]] && continue
|
||||
|
||||
if [[ ! -e "$file" ]]; then
|
||||
echo "ERROR: Missing file: $file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -d "$file" ]]; then
|
||||
echo "WARNING: Is a directory, skipping: $file"
|
||||
continue
|
||||
fi
|
||||
|
||||
bookdir="$(dirname "$file")"
|
||||
booktitle="$(basename "$bookdir")"
|
||||
author="$(basename "$(dirname "$bookdir")")"
|
||||
|
||||
echo
|
||||
echo "File: $file"
|
||||
echo "Artist: $author"
|
||||
echo "Album: $booktitle"
|
||||
|
||||
if $DRY_RUN; then
|
||||
echo "DRY RUN: no changes made"
|
||||
continue
|
||||
fi
|
||||
|
||||
artist=$(escape_kid3 "$author")
|
||||
album=$(escape_kid3 "$booktitle")
|
||||
|
||||
kid3-cli "$file" \
|
||||
-c "tag 1" \
|
||||
-c "set artist '$artist'" \
|
||||
-c "set album '$album'" \
|
||||
-c "tag 2" \
|
||||
-c "set artist '$artist'" \
|
||||
-c "set album '$album'" \
|
||||
-c save
|
||||
done < "$list"
|
||||
Reference in new issue
Block a user