1.4 - new script interval, improved logging

This commit is contained in:
RandomNinjaAtk 2023-07-15 16:12:49 -04:00 committed by GitHub
parent 1e769a8fa2
commit 1bcb90b17c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,21 +1,40 @@
#!/usr/bin/env bash
scriptVersion="1.3"
scriptVersion="1.4"
ytdlpExtraOpts="--user-agent facebookexternalhit/1.1"
scriptName="YoutubeSeriesDownloader"
#### Import Settings
source /config/extended.conf
log () {
m_time=`date "+%F %T"`
echo $m_time" :: $scriptName :: $scriptVersion :: "$1
}
if [ "$enableYoutubeSeriesDownloader" != "true" ]; then
logfileSetup () {
# auto-clean up log file to reduce space usage
if [ -f "/config/logs/$scriptName.txt" ]; then
find /config/logs -type f -name "$scriptName.txt" -size +1024k -delete
fi
if [ ! -f "/config/logs/$scriptName.txt" ]; then
touch "/config/logs/$scriptName.txt"
chmod 666 "/config/logs/$scriptName.txt"
fi
exec &> >(tee -a "/config/logs/$scriptName.txt")
}
verifyConfig () {
#### Import Settings
source /config/extended.conf
if [ "$enableYoutubeSeriesDownloader" != "true" ]; then
log "Script is not enabled, enable by setting enableYoutubeSeriesDownloader to \"true\" by modifying the \"/config/extended.conf\" config file..."
log "Sleeping (infinity)"
sleep infinity
fi
fi
if [ -z "$youtubeSeriesDownloaderScriptInterval" ]; then
youtubeSeriesDownloaderScriptInterval="1h"
fi
}
getArrAppInfo () {
# Get Arr App information
@ -180,13 +199,15 @@ YoutubeSeriesDownloaderProcess () {
done
}
log "Starting Script...."
for (( ; ; )); do
let i++
logfileSetup
log "Script starting..."
verifyConfig
getArrAppInfo
verifyApiAccess
YoutubeSeriesDownloaderProcess
log "Script sleeping for 2 hours..."
sleep 2h
log "Script sleeping for $youtubeSeriesDownloaderScriptInterval..."
sleep $youtubeSeriesDownloaderScriptInterval
done
exit