metadata scripts
rank from list: remove turtledemo and add grouping name as argument metadata scan: scan grouping of all files metadata search replace: add working dir as argument
This commit is contained in:
1 parent
f27c172a73
commit
709d5d2b41
5 files changed
+38
-11
No files matched your search
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 <Series> [additional ffmpeg_handling.py args...]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
series="$1"
|
||||
shift
|
||||
|
||||
for d in */; do
|
||||
[ -d "$d" ] || continue
|
||||
name="${d%/}"
|
||||
|
||||
# extract leading number (int or float)
|
||||
if [[ $name =~ ([0-9]+([.,][0-9]+)?) ]]; then
|
||||
num="${BASH_REMATCH[1]}"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
echo $d $num
|
||||
/home/lucas/scripts/.venv/bin/python \
|
||||
/home/lucas/scripts/ffmpeg_handling.py \
|
||||
ms "$name" \
|
||||
--override \
|
||||
-k grouping \
|
||||
-v "$series #$num" \
|
||||
"$@"
|
||||
done
|
||||
File renamed without changes.
@@ -5,7 +5,6 @@ import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from difflib import SequenceMatcher
|
||||
from turtledemo.lindenmayer import replace
|
||||
|
||||
AUDIO_EXTENSIONS = {
|
||||
".mp3",
|
||||
@@ -56,7 +55,7 @@ def get_tag(path, tag):
|
||||
|
||||
return ""
|
||||
|
||||
def tag_file(path: Path, rank: int, year: str, dry_run: bool):
|
||||
def tag_file(path: Path, rank: int, year: str, dry_run: bool, replace_pattern: str=r"Top 100 SciFi Books" )
|
||||
work = get_tag(path, "work")
|
||||
grouping = get_tag(path, "grouping")
|
||||
existing_year = get_tag(path, "year")
|
||||
@@ -70,10 +69,7 @@ def tag_file(path: Path, rank: int, year: str, dry_run: bool):
|
||||
else:
|
||||
tag = "grouping"
|
||||
existing = ""
|
||||
#pattern = r"Top 100 SciFi Books #\d+(?:\.\d+)?"
|
||||
pattern = r"Enderverse Publication #\d+(?:\.\d+)?"
|
||||
#replace = r"Top 100 SciFi Books"
|
||||
replace = r"Enderverse Publication"
|
||||
pattern = f"{replace_pattern} #\d+(?:\.\d+)?"
|
||||
|
||||
if existing:
|
||||
if re.search(pattern, existing):
|
||||
@@ -118,7 +114,7 @@ def main():
|
||||
args = parser.parse_args()
|
||||
|
||||
library = Path(args.library)
|
||||
|
||||
replace_pattern=Path(args.booklist).stem
|
||||
found = set()
|
||||
|
||||
with open(args.booklist, encoding="utf-8") as f:
|
||||
@@ -197,7 +193,7 @@ def main():
|
||||
if file.suffix.lower() not in AUDIO_EXTENSIONS:
|
||||
continue
|
||||
|
||||
ret=tag_file(file, rank, year, args.dry_run)
|
||||
ret=tag_file(file, rank, year, args.dry_run, replace_pattern)
|
||||
if ret == "skip":
|
||||
break
|
||||
#print("next")
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
shopt -s globstar nullglob
|
||||
|
||||
root="${1:-.}"
|
||||
|
||||
for file in "$root"/**/*; do
|
||||
[[ -f "$file" ]] || continue
|
||||
|
||||
case "${file##*.}" in
|
||||
epub|EPUB)
|
||||
continue
|
||||
;;
|
||||
nfo|NFO)
|
||||
grouping="$(grep -i 'Series Name:' "$file" 2>/dev/null | sed 's/^[Ss]eries:[[:space:]]*//')"
|
||||
;;
|
||||
m4b|M4B|m4a|M4A|mp3|MP3|aac|AAC|flac|FLAC)
|
||||
grouping="$(kid3-cli -c "get grouping" "$file" 2>/dev/null)"
|
||||
;;
|
||||
*)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ ! "$grouping" =~ Publication ]]; then
|
||||
echo Grouping: $grouping
|
||||
echo "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
find . \( -iname '*.mp3' -o -iname '*.m4a' -o -iname '*.m4b' \) -print0 |
|
||||
root="${1:-.}"
|
||||
find "$root" \( -iname '*.mp3' -o -iname '*.m4a' -o -iname '*.m4b' \) -print0 |
|
||||
while IFS= read -r -d '' f; do
|
||||
|
||||
comment=$(ffprobe -v error \
|
||||
|
||||
Reference in new issue
Block a user