v1.7 - Improved logging output

This commit is contained in:
RandomNinjaAtk 2024-01-27 16:41:00 -05:00 committed by GitHub
parent 1d9bbcd5f3
commit e323b8a091
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,5 @@
#!/usr/bin/with-contenv bash #!/usr/bin/with-contenv bash
ScriptVersion="1.6" ScriptVersion="1.7"
scriptName="Audiobook" scriptName="Audiobook"
#### Import Settings #### Import Settings
@ -27,12 +27,12 @@ exec &> >(tee -a "/config/scripts/audiobook.txt")
SECONDS=0 SECONDS=0
log "Processing $1" log "Processing $1"
log "Searching for audiobook (m4b) files in completed download..."
m4bCount=$(find "$1" -type f -iname "*.m4b" | wc -l) m4bCount=$(find "$1" -type f -iname "*.m4b" | wc -l)
if [ $m4bCount -ne 1 ]; then if [ $m4bCount -gt 1 ]; then
log "ERROR: More than 1 M4B file found, performing cleanup..." log "ERROR: More than 1 M4B file found, performing cleanup..."
find "$1" -type f -iname "m4b" -delete find "$1" -type f -iname "m4b" -delete
else else
log "Searching for audiobook (m4b) files in completed download..."
if [ $m4bCount -gt 0 ]; then if [ $m4bCount -gt 0 ]; then
log "$m4bCount M4B files found, removing non m4b files..." log "$m4bCount M4B files found, removing non m4b files..."
find "$1" -type f -not -iname "*.m4b" -delete find "$1" -type f -not -iname "*.m4b" -delete
@ -43,12 +43,12 @@ else
fi fi
fi fi
log "Searching for audiobook (m4b.mp4) files in completed download..."
mp4Count=$(find "$1" -type f -iname "*.m4b.mp4" | wc -l) mp4Count=$(find "$1" -type f -iname "*.m4b.mp4" | wc -l)
if [ $mp4Count -ne 1 ]; then if [ $mp4Count -gt 1 ]; then
log "ERROR: More than 1 MP4 file found, performing cleanup..." log "ERROR: More than 1 MP4 file found, performing cleanup..."
find "$1" -type f -iname "*.mp4" -delete find "$1" -type f -iname "*.mp4" -delete
else else
log "Searching for audiobook (m4b.mp4) files in completed download..."
if [ $mp4Count -gt 0 ]; then if [ $mp4Count -gt 0 ]; then
log "$mp4Count M4B (m4b.mp4) files found, removing non m4b files..." log "$mp4Count M4B (m4b.mp4) files found, removing non m4b files..."
find "$1" -type f -not -iname "*.m4b.mp4" -delete find "$1" -type f -not -iname "*.m4b.mp4" -delete
@ -73,12 +73,12 @@ else
fi fi
fi fi
log "Searching for audiobook (mp3) files in completed download..."
mp3Count=$(find "$1" -type f -iname "*.mp3" | wc -l) mp3Count=$(find "$1" -type f -iname "*.mp3" | wc -l)
if [ $mp3Count -ne 1 ]; then if [ $mp3Count -gt 1 ]; then
log "ERROR: More than 1 MP3 file found, performing cleanup..." log "ERROR: More than 1 MP3 file found, performing cleanup..."
find "$1" -type f -iname "*.mp3" -delete find "$1" -type f -iname "*.mp3" -delete
else else
log "Searching for audiobook (mp3) files in completed download..."
if [ $mp3Count -gt 0 ]; then if [ $mp3Count -gt 0 ]; then
log "$mp3Count MP3 files found, removing non mp3 files..." log "$mp3Count MP3 files found, removing non mp3 files..."
find "$1" -type f -not -iname "*.mp3" -delete find "$1" -type f -not -iname "*.mp3" -delete