lidarr-dl/sabnzbd/audiobook.bash

34 lines
736 B
Bash
Raw Normal View History

2023-07-19 13:22:02 +02:00
#!/usr/bin/with-contenv bash
2023-07-19 13:42:07 +02:00
ScriptVersion="0.2"
2023-07-19 13:22:02 +02:00
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 () {
2023-07-19 13:42:07 +02:00
log "Searching for audiobook (m4b) files..."
if [ $(find "$1" -type f -iname "*.m4b" | wc -l) -gt 0 ]; then
log "M4B files found, removing non m4b files..."
find "$1" -type f -not -iname "*.m4b" -delete
2023-07-19 13:22:02 +02:00
find "$1" -mindepth 2 -type f -exec mv "{}" "$1"/ \;
find "$1" -mindepth 1 -type d -delete
else
2023-07-19 13:42:07 +02:00
echo "ERROR: NO audiobook files found (M4B)" && exit 1
2023-07-19 13:22:02 +02:00
fi
}
clean
exit