diff --git a/sabnzbd/video.bash b/sabnzbd/video.bash index 15fa8fe..f54762f 100644 --- a/sabnzbd/video.bash +++ b/sabnzbd/video.bash @@ -1,5 +1,5 @@ #!/bin/bash -scriptVersion="1.6" +scriptVersion="1.7" scriptName="Video" #### Import Settings @@ -126,16 +126,18 @@ ArrWaitForTaskCompletion () { alerted=no until false do - taskCount=$(curl -s "$arrUrl/api/v3/command?apikey=${arrApiKey}" | jq -r '.[] | select(.status=="started") | .name' | wc -l) - if [ "$taskCount" -ge "1" ]; then - if [ "$alerted" == "no" ]; then - alerted=yes - log "$count of $fileCount :: STATUS :: ARR APP BUSY :: Pausing/waiting for all active Arr app tasks to end..." - fi - sleep 2 - else - break - fi + arrtasks=$(curl -s "$arrUrl/api/v3/command?apikey=${arrApiKey}" | jq -r '.[] | select(.status=="started") | .name') + taskCount=$(echo $arrtasks | wc -l) + arrProcessMonitoredDownloadsCount=$(echo $arrtasks | grep "ProcessMonitoredDownloads" | wc -l) + if [ "$taskCount" -ge 3 ] || [ "$arrProcessMonitoredDownloadsCount" -ge 1 ]; then + if [ "$alerted" == "no" ]; then + alerted=yes + log "$count of $fileCount :: STATUS :: ARR APP BUSY :: Pausing/waiting for all active Arr app tasks to end..." + fi + sleep 2 + else + break + fi done } @@ -170,8 +172,8 @@ VideoSmaProcess (){ arrApiKey="$radarrArrApiKey" fi log "$count of $fileCount :: Refreshing Radarr app Queue" - #refreshQueue=$(curl -s "$arrUrl/api/v3/command" -X POST -H 'Content-Type: application/json' -H "X-Api-Key: $arrApiKey" --data-raw '{"name":"RefreshMonitoredDownloads"}') - # ArrWaitForTaskCompletion + refreshQueue=$(curl -s "$arrUrl/api/v3/command" -X POST -H 'Content-Type: application/json' -H "X-Api-Key: $arrApiKey" --data-raw '{"name":"RefreshMonitoredDownloads"}') + ArrWaitForTaskCompletion 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') arrItemData=$(curl -s "$arrUrl/api/v3/movie/$arrItemId?apikey=$arrApiKey") onlineSourceId="$(echo "$arrItemData" | jq -r ".tmdbId")" @@ -188,8 +190,8 @@ VideoSmaProcess (){ arrApiKey="$sonarrArrApiKey" fi log "$count of $fileCount :: Refreshing Sonarr app Queue" - #refreshQueue=$(curl -s "$arrUrl/api/v3/command" -X POST -H 'Content-Type: application/json' -H "X-Api-Key: $arrApiKey" --data-raw '{"name":"RefreshMonitoredDownloads"}') - # ArrWaitForTaskCompletion + refreshQueue=$(curl -s "$arrUrl/api/v3/command" -X POST -H 'Content-Type: application/json' -H "X-Api-Key: $arrApiKey" --data-raw '{"name":"RefreshMonitoredDownloads"}') + ArrWaitForTaskCompletion 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)') arrSeriesId="$(echo $arrQueueItemData | jq -r .seriesId)" arrEpisodeId="$(echo $arrQueueItemData | jq -r .episodeId)"