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 #!/usr/bin/env bash
scriptVersion="1.3" scriptVersion="1.4"
ytdlpExtraOpts="--user-agent facebookexternalhit/1.1" ytdlpExtraOpts="--user-agent facebookexternalhit/1.1"
scriptName="YoutubeSeriesDownloader" scriptName="YoutubeSeriesDownloader"
#### Import Settings
source /config/extended.conf
log () { log () {
m_time=`date "+%F %T"` m_time=`date "+%F %T"`
echo $m_time" :: $scriptName :: $scriptVersion :: "$1 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 "Script is not enabled, enable by setting enableYoutubeSeriesDownloader to \"true\" by modifying the \"/config/extended.conf\" config file..."
log "Sleeping (infinity)" log "Sleeping (infinity)"
sleep infinity sleep infinity
fi fi
if [ -z "$youtubeSeriesDownloaderScriptInterval" ]; then
youtubeSeriesDownloaderScriptInterval="1h"
fi
}
getArrAppInfo () { getArrAppInfo () {
# Get Arr App information # Get Arr App information
@ -180,13 +199,15 @@ YoutubeSeriesDownloaderProcess () {
done done
} }
log "Starting Script...."
for (( ; ; )); do for (( ; ; )); do
let i++ let i++
logfileSetup
log "Script starting..."
verifyConfig
getArrAppInfo getArrAppInfo
verifyApiAccess verifyApiAccess
YoutubeSeriesDownloaderProcess YoutubeSeriesDownloaderProcess
log "Script sleeping for 2 hours..." log "Script sleeping for $youtubeSeriesDownloaderScriptInterval..."
sleep 2h sleep $youtubeSeriesDownloaderScriptInterval
done done
exit exit