7 while getopts fo:i: opt; do
17 dir=$1; shift; cd "$dir"
21 /^\([0-9][0-9]\)[-.\ ].*\.flac$/!d
29 *) if [ -r .offset ]; then read offset <.offset; else offset=0; fi ;;
32 : ${id=$($JBDIR/bin/flaccrip-discid -a .)}
33 ntr=$(echo "$id" | sed 's:^0*\([1-9][0-9]*\)-.*$:\1:')
34 ar=$($JBDIR/bin/flaccrip-arfetch $id)
36 while read type rest; do
38 H) npress=$((npress + 1)) ;;
44 case $npress,$force in
46 echo >&2 "$0: no AccurateRip record found"
50 echo "Found $npress pressings"
54 cks="" ntrack=$# ngood=0
56 while :; do case "$t" in 0*) t=${t#0} ;; *) break ;; esac; done
57 l=$((t - 1)) h=$((t + 1))
58 tt=$(printf %02d "$t")
59 ll=$(printf %02d "$l")
60 hh=$(printf %02d "$h")
65 flags="${flags+$flags }-f"
66 elif [ -f "$ll"[-.\ ]*.flac ]; then
67 before=$(echo "$ll"[-.\ ]*.flac)
68 elif ((offset < 0)); then
69 echo >&2 "$0: warning: -ve offset, but track $l missing; using silence"
73 flags="${flags+$flags }-l"
74 elif [ -f "$hh"[-.\ ]*.flac ]; then
75 after=$(echo "$hh"[-.\ ]*.flac)
76 elif ((offset > 0)); then
77 echo >&2 "$0: warning: +ve offset, but track $h missing; using silence"
80 ck=$($JBDIR/bin/flaccrip-offset -o"$offset" \
81 $flags ${before+-b "$before"} ${after+-a "$after"} "$tt"[-.\ ]*.flac |
82 $JBDIR/bin/flaccrip-compute)
85 while read arty art arconf arck; do
94 printf "Track %2d (%s): match pressing %d; confidence %d\n" \
107 printf "Track %2d (%s): NO MATCH\n" $t $ck
112 if ((ngood == ntrack)); then
113 echo "All tracks match: GOOD RIP"
115 elif ((ngood == 0)); then
116 echo "No matches: new pressing, incorrect offset or wrong discid?"
119 echo "Matched $ngood/$ntrack: time to re-rip :-("