v1.8 - Add support for stalled downloads cleanup
#267 - Based on reviewing this PR, I have updated the script to accommodate the request without the need for a complete re-write and removal of existing functionality. Additionally, this should now support any port... Has had limited testing...
This commit is contained in:
parent
178ef2290a
commit
2e698c6d03
1 changed files with 21 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
scriptVersion="1.7"
|
||||
scriptVersion="1.8"
|
||||
scriptName="QueueCleaner"
|
||||
|
||||
#### Import Settings
|
||||
|
@ -28,35 +28,44 @@ verifyConfig () {
|
|||
}
|
||||
|
||||
QueueCleanerProcess () {
|
||||
arrQueueData=""
|
||||
# Sonarr
|
||||
if [ "$arrPort" == "8989" ]; then
|
||||
if [ -z "$arrQueueData" ]; then
|
||||
arrQueueData="$(curl -s "$arrUrl/api/v3/queue?page=1&pagesize=200&sortDirection=descending&sortKey=progress&includeUnknownSeriesItems=true&apikey=${arrApiKey}" | jq -r .records[])"
|
||||
fi
|
||||
|
||||
# Radarr
|
||||
if [ "$arrPort" == "7878" ]; then
|
||||
arrQueueData="$(curl -s "$arrUrl/api/v3/queue?page=1&pagesize=200&sortDirection=descending&sortKey=progress&includeUnknownMovieItems=true&apikey=${arrApiKey}" | jq -r .records[])"
|
||||
if [ -z "$arrQueueData" ]; then
|
||||
arrQueueData="$(curl -s "$arrUrl/api/v3/queue?page=1&pagesize=200&sortDirection=descending&sortKey=progress&includeUnknownMovieItems=true&apikey=${arrApiKey}" | jq -r .records[])"
|
||||
fi
|
||||
|
||||
# Lidarr
|
||||
if [ "$arrPort" == "8686" ]; then
|
||||
if [ -z "$arrQueueData" ]; then
|
||||
arrQueueData="$(curl -s "$arrUrl/api/v1/queue?page=1&pagesize=200&sortDirection=descending&sortKey=progress&includeUnknownArtistItems=true&apikey=${arrApiKey}" | jq -r .records[])"
|
||||
fi
|
||||
|
||||
# Readarr
|
||||
if [ "$arrPort" == "8787" ]; then
|
||||
if [ -z "$arrQueueData" ]; then
|
||||
arrQueueData="$(curl -s "$arrUrl/api/v1/queue?page=1&pagesize=200&sortDirection=descending&sortKey=progress&includeUnknownAuthorItems=true&apikey=${arrApiKey}" | jq -r .records[])"
|
||||
fi
|
||||
|
||||
arrQueueIdCount=$(echo "$arrQueueData" | jq -r ".id" | wc -l)
|
||||
arrQueueCompletedIds=$(echo "$arrQueueData" | jq -r 'select(.status=="completed") | select(.trackedDownloadStatus=="warning") | .id')
|
||||
arrQueueIdsCompletedCount=$(echo "$arrQueueData" | jq -r 'select(.status=="completed") | select(.trackedDownloadStatus=="warning") | .id' | wc -l)
|
||||
arrQueueIdsCompletedCount=$(echo -n "$arrQueueCompletedIds" | wc -l)
|
||||
arrQueueFailedIds=$(echo "$arrQueueData" | jq -r 'select(.status=="failed") | .id')
|
||||
arrQueueIdsFailedCount=$(echo "$arrQueueData" | jq -r 'select(.status=="failed") | .id' | wc -l)
|
||||
arrQueuedIds=$(echo "$arrQueueCompletedIds"; echo "$arrQueueFailedIds")
|
||||
arrQueueIdsCount=$(( $arrQueueIdsCompletedCount + $arrQueueIdsFailedCount ))
|
||||
arrQueueIdsFailedCount=$(echo -n "$arrQueueFailedIds" | wc -l)
|
||||
arrQueueStalledIds=$(echo "$arrQueueData" | jq -r 'select(.status=="stalled") | .id')
|
||||
arrQueueIdsStalledount=$(echo -n "$arrQueueStalledIds" | wc -l)
|
||||
arrQueuedIds=$(echo "$arrQueueCompletedIds"; echo "$arrQueueFailedIds"; echo "$arrQueueStalledIds")
|
||||
arrQueueIdsCount=$(( $arrQueueIdsCompletedCount + $arrQueueIdsFailedCount + $arrQueueIdsStalledount ))
|
||||
|
||||
# Debugging
|
||||
#echo "$arrQueueIdsCount :: $arrQueueIdsCompletedCount + $arrQueueIdsFailedCount + $arrQueueIdsStalledount"
|
||||
#echo "$arrQueueCompletedIds"
|
||||
#echo "$arrQueueFailedIds"
|
||||
#echo "$arrQueueStalledIds"
|
||||
|
||||
if [ $arrQueueIdsCount -eq 0 ]; then
|
||||
log "No items in queue to clean up"
|
||||
log "$arrQueueIdCount items in queue, no items in queue to clean up"
|
||||
else
|
||||
for queueId in $(echo $arrQueuedIds); do
|
||||
arrQueueItemData="$(echo "$arrQueueData" | jq -r "select(.id==$queueId)")"
|
||||
|
|
Loading…
Reference in a new issue