From 2094b43b009c8110c2c80e7d9aee31a859a97289 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Wed, 19 Jul 2023 11:22:02 +0000 Subject: [PATCH] Create audiobook.bash --- sabnzbd/audiobook.bash | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 sabnzbd/audiobook.bash diff --git a/sabnzbd/audiobook.bash b/sabnzbd/audiobook.bash new file mode 100644 index 0000000..ad4a4c1 --- /dev/null +++ b/sabnzbd/audiobook.bash @@ -0,0 +1,31 @@ +#!/usr/bin/with-contenv bash +ScriptVersion="0.1" +scriptName="Audiobook" + +#### Import Settings +source /config/extended.conf + +log () { + m_time=`date "+%F %T"` + echo $m_time" :: $scriptName :: $scriptVersion :: "$1 +} + + +set -e +set -o pipefail + +touch "/config/scripts/audiobook.txt" +exec &> >(tee -a "/config/scripts/audiobook.txt") + +clean () { + if [ $(find "$1" -type f -regex ".*/.*\.\(m4b\)" | wc -l) -gt 0 ]; then + find "$1" -type f -not -regex ".*/.*\.\(m4b\)" -delete + find "$1" -mindepth 2 -type f -exec mv "{}" "$1"/ \; + find "$1" -mindepth 1 -type d -delete + else + echo "ERROR: NO AUDIOBOOK FILES FOUND (M4B)" && exit 1 + fi +} + +clean +exit