From 057a45b54d115e294c31291a9ed00180f675f9f7 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Wed, 7 Dec 2022 07:22:19 -0500 Subject: [PATCH] 1.0.009 - Remove Failed downloads #10 --- root/scripts/QueueCleaner.bash | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/root/scripts/QueueCleaner.bash b/root/scripts/QueueCleaner.bash index e7df6dd..7bb80cc 100644 --- a/root/scripts/QueueCleaner.bash +++ b/root/scripts/QueueCleaner.bash @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.0.008" +scriptVersion="1.0.009" if [ -z "$arrUrl" ] || [ -z "$arrApiKey" ]; then arrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" @@ -29,12 +29,17 @@ exec &> >(tee -a "/config/logs/QueueCleaner.txt") CleanerProcess () { arrQueueData="$(curl -s "$arrUrl/api/v3/queue?page=1&pagesize=200&sortDirection=descending&sortKey=progress&includeUnknownSeriesItems=true&apikey=${arrApiKey}" | jq -r .records[])" - arrQueueIds=$(echo "$arrQueueData" | jq -r 'select(.status=="completed") | select(.trackedDownloadStatus=="warning") | .id') - arrQueueIdsCount=$(echo "$arrQueueData" | jq -r 'select(.status=="completed") | select(.trackedDownloadStatus=="warning") | .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) + 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 )) + if [ $arrQueueIdsCount -eq 0 ]; then log "No items in queue to clean up..." else - for queueId in $(echo $arrQueueIds); do + for queueId in $(echo $arrQueuedIds); do arrQueueItemData="$(echo "$arrQueueData" | jq -r "select(.id==$queueId)")" arrQueueItemTitle="$(echo "$arrQueueItemData" | jq -r .title)" arrEpisodeId="$(echo "$arrQueueItemData" | jq -r .episodeId)"