1
1
#! /bin/bash
2
- scriptVersion=" 1.6 "
2
+ scriptVersion=" 1.7 "
3
3
scriptName=" Video"
4
4
5
5
# ### Import Settings
@@ -126,16 +126,18 @@ ArrWaitForTaskCompletion () {
126
126
alerted=no
127
127
until false
128
128
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
139
141
done
140
142
}
141
143
@@ -170,8 +172,8 @@ VideoSmaProcess (){
170
172
arrApiKey=" $radarrArrApiKey "
171
173
fi
172
174
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
175
177
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' )
176
178
arrItemData=$( curl -s " $arrUrl /api/v3/movie/$arrItemId ?apikey=$arrApiKey " )
177
179
onlineSourceId=" $( echo " $arrItemData " | jq -r " .tmdbId" ) "
@@ -188,8 +190,8 @@ VideoSmaProcess (){
188
190
arrApiKey=" $sonarrArrApiKey "
189
191
fi
190
192
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
193
195
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)' )
194
196
arrSeriesId=" $( echo $arrQueueItemData | jq -r .seriesId) "
195
197
arrEpisodeId=" $( echo $arrQueueItemData | jq -r .episodeId) "
0 commit comments