11#! /bin/bash
2- scriptVersion=" 1.6 "
2+ scriptVersion=" 1.7 "
33scriptName=" Video"
44
55# ### Import Settings
@@ -126,16 +126,18 @@ ArrWaitForTaskCompletion () {
126126 alerted=no
127127 until false
128128 do
129- taskCount=$( curl -s " $arrUrl /api/v3/command?apikey=${arrApiKey} " | jq -r ' .[] | select(.status=="started") | .name' | wc -l)
130- if [ " $taskCount " -ge " 1" ]; then
131- if [ " $alerted " == " no" ]; then
132- alerted=yes
133- log " $count of $fileCount :: STATUS :: ARR APP BUSY :: Pausing/waiting for all active Arr app tasks to end..."
134- fi
135- sleep 2
136- else
137- break
138- fi
129+ arrtasks=$( curl -s " $arrUrl /api/v3/command?apikey=${arrApiKey} " | jq -r ' .[] | select(.status=="started") | .name' )
130+ taskCount=$( echo $arrtasks | wc -l)
131+ arrProcessMonitoredDownloadsCount=$( echo $arrtasks | grep " ProcessMonitoredDownloads" | wc -l)
132+ if [ " $taskCount " -ge 3 ] || [ " $arrProcessMonitoredDownloadsCount " -ge 1 ]; then
133+ if [ " $alerted " == " no" ]; then
134+ alerted=yes
135+ log " $count of $fileCount :: STATUS :: ARR APP BUSY :: Pausing/waiting for all active Arr app tasks to end..."
136+ fi
137+ sleep 2
138+ else
139+ break
140+ fi
139141 done
140142}
141143
@@ -170,8 +172,8 @@ VideoSmaProcess (){
170172 arrApiKey=" $radarrArrApiKey "
171173 fi
172174 log " $count of $fileCount :: Refreshing Radarr app Queue"
173- # refreshQueue=$(curl -s "$arrUrl/api/v3/command" -X POST -H 'Content-Type: application/json' -H "X-Api-Key: $arrApiKey" --data-raw '{"name":"RefreshMonitoredDownloads"}')
174- # ArrWaitForTaskCompletion
175+ refreshQueue=$( curl -s " $arrUrl /api/v3/command" -X POST -H ' Content-Type: application/json' -H " X-Api-Key: $arrApiKey " --data-raw ' {"name":"RefreshMonitoredDownloads"}' )
176+ ArrWaitForTaskCompletion
175177 arrItemId=$( curl -s " $arrUrl /api/v3/queue?page=1&pageSize=50&sortDirection=ascending&sortKey=timeleft&includeUnknownMovieItems=true&apikey=$arrApiKey " | jq -r --arg id " $downloadId " ' .records[] | select(.downloadId==$id) | .movieId' )
176178 arrItemData=$( curl -s " $arrUrl /api/v3/movie/$arrItemId ?apikey=$arrApiKey " )
177179 onlineSourceId=" $( echo " $arrItemData " | jq -r " .tmdbId" ) "
@@ -188,8 +190,8 @@ VideoSmaProcess (){
188190 arrApiKey=" $sonarrArrApiKey "
189191 fi
190192 log " $count of $fileCount :: Refreshing Sonarr app Queue"
191- # refreshQueue=$(curl -s "$arrUrl/api/v3/command" -X POST -H 'Content-Type: application/json' -H "X-Api-Key: $arrApiKey" --data-raw '{"name":"RefreshMonitoredDownloads"}')
192- # ArrWaitForTaskCompletion
193+ refreshQueue=$( curl -s " $arrUrl /api/v3/command" -X POST -H ' Content-Type: application/json' -H " X-Api-Key: $arrApiKey " --data-raw ' {"name":"RefreshMonitoredDownloads"}' )
194+ ArrWaitForTaskCompletion
193195 arrQueueItemData=$( curl -s " $arrUrl /api/v3/queue?page=1&pageSize=50&sortDirection=ascending&sortKey=timeleft&includeUnknownSeriesItems=true&apikey=$arrApiKey " | jq -r --arg id " $downloadId " ' .records[] | select(.downloadId==$id)' )
194196 arrSeriesId=" $( echo $arrQueueItemData | jq -r .seriesId) "
195197 arrEpisodeId=" $( echo $arrQueueItemData | jq -r .episodeId) "
0 commit comments