1.0.009 - Remove Failed downloads

#10
pull/24/head
RandomNinjaAtk 2 years ago committed by GitHub
parent 4089f113a1
commit 057a45b54d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)"

Loading…
Cancel
Save