From 077f8adab296466656f957cac7a726617ac32aed Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Thu, 21 Jan 2021 08:28:43 -0500 Subject: [PATCH] Update audio-pp.bash --- root/scripts/audio-pp.bash | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/root/scripts/audio-pp.bash b/root/scripts/audio-pp.bash index 6d0c6ab..1220a72 100644 --- a/root/scripts/audio-pp.bash +++ b/root/scripts/audio-pp.bash @@ -190,6 +190,42 @@ Main () { fi } + beets () { + echo "" + trackcount=$(find "$1" -type f -iregex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | wc -l) + echo "Matching $trackcount tracks with Beets" + if [ ! -d /beets ]; then + mkdir -p /beets + fi + if [ -f /beets/library.blb ]; then + rm /beets/library.blb + sleep 0.1 + fi + if [ -f /beets/beets.log ]; then + rm /beets/beets.log + sleep 0.1 + fi + + touch "/beets-match" + sleep 0.1 + + if find "$1" -type f -iregex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | read; then + beet -c /config/scripts/config/beets-config.yaml -l /beets/library.blb -d "$1" import -q "$1" > /dev/null + if find "$1" -type f -iregex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" -newer "$1/beets-match" | read; then + echo "SUCCESS: Matched with beets!" + else + rm -rf "$1"/* + echo "ERROR: Unable to match using beets to a musicbrainz release, marking download as failed..." && exit 1 + fi + fi + + if [ -f "$1/beets-match" ]; then + rm "/beets-match" + sleep 0.1 + fi + } + + #============START SCRIPT============ settings "$1" @@ -206,6 +242,10 @@ Main () { if [ "${ReplaygainTagging}" = TRUE ]; then replaygain "$1" fi + + if [ "${BeetsTagging}" = TRUE ]; then + beets "$1" + fi echo "" echo "Post Processing Complete!" && exit 0