From 012036b5002b7a3a4867eb211a226c3a7799c3b0 Mon Sep 17 00:00:00 2001 From: Vincent Riquer Date: Thu, 23 Jan 2025 00:17:35 +0000 Subject: [PATCH] toys/checkgenre: check dest files for old school ID3v1 genre tags --- toys/checkgenre | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 toys/checkgenre diff --git a/toys/checkgenre b/toys/checkgenre new file mode 100755 index 0000000..616c97e --- /dev/null +++ b/toys/checkgenre @@ -0,0 +1,85 @@ +#!/usr/bin/env bash + +# config structures +declare -A \ + destinationchannels \ + destinationfat32compat \ + destinationcopymime \ + destinationformat \ + destinationfrequency \ + destinationid \ + destinationloss \ + destinationmaxbps \ + destinationnormalize \ + destinationpath \ + destinationquality \ + destinationrename \ + destinationnoresample \ + destinationrenamepath \ + destinationskipmime \ +|| { + echo "Check your Bash version. You need >= 4.0" >&2 + exit $EBASHVERS +} + +declare -r \ + DOCDIR=./doc \ + LIBDIR=./lib \ + SHAREDIR=./share +declare -r \ + exampleconf=$DOCDIR/example.cfg \ + schema=$SHAREDIR/schema.sql \ + \ + oldIFS="$IFS" + +cffile="$HOME/.atom/atom.cfg" +LC_ALL=C + +shopt -s extglob + +for function in "$LIBDIR"/*/* +do + source "$function" +done + +while getopts 'D' opt +do + case $opt in + D) (( debug++ )) ;; + esac +done + +getConfig + +openDatabase + +sourcepath='' + + +for destination in ${!destinationpath[@]} +do + case ${destinationformat[$destination]} in + ogg) mimetype='audio/ogg vorbis' ;; + opus) mimetype='audio/ogg opus' ;; + mp3) mimetype='audio/mpeg' ;; + esac + while read filename + do + getTags + expr='^[0-9]+$' + if [[ $genre =~ $expr ]] + then + echo "$filename ($genre)" + Update destination_files last_change 0 <<-EOWhere + filename = $filename + EOWhere + fi + done < <( + find "${destinationpath[$destination]}" \ + -name '*.ogg' \ + -o -name '*.mp3' \ + -o -name '*.opus' + ) +done + +closeDatabase