diff --git a/sonarr/YoutubeSeriesDownloader.service b/sonarr/YoutubeSeriesDownloader.service index a6d61b6..06697e1 100644 --- a/sonarr/YoutubeSeriesDownloader.service +++ b/sonarr/YoutubeSeriesDownloader.service @@ -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