|
|
@ -1,5 +1,5 @@
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
scriptVersion="1.0.008"
|
|
|
|
scriptVersion="1.0.009"
|
|
|
|
|
|
|
|
|
|
|
|
if [ -z "$arrUrl" ] || [ -z "$arrApiKey" ]; then
|
|
|
|
if [ -z "$arrUrl" ] || [ -z "$arrApiKey" ]; then
|
|
|
|
arrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)"
|
|
|
|
arrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)"
|
|
|
@ -19,41 +19,36 @@ if [ -f "/config/logs/QueueCleaner.txt" ]; then
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
touch "/config/logs/QueueCleaner.txt"
|
|
|
|
touch "/config/logs/QueueCleaner.txt"
|
|
|
|
exec &> >(tee -a "/config/logs/QueueCleaner.txt")
|
|
|
|
|
|
|
|
chmod 666 "/config/logs/QueueCleaner.txt"
|
|
|
|
chmod 666 "/config/logs/QueueCleaner.txt"
|
|
|
|
|
|
|
|
exec &> >(tee -a "/config/logs/QueueCleaner.txt")
|
|
|
|
|
|
|
|
|
|
|
|
log () {
|
|
|
|
log () {
|
|
|
|
m_time=`date "+%F %T"`
|
|
|
|
m_time=`date "+%F %T"`
|
|
|
|
echo $m_time" :: QueueCleaner :: $scriptVersion :: "$1
|
|
|
|
echo $m_time" :: QueueCleaner :: $scriptVersion :: "$1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
arrQueueData="$(curl -s "$arrUrl/api/v3/queue?page=1&pagesize=200&sortDirection=descending&sortKey=progress&includeUnknownMovieItems=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)
|
|
|
|
|
|
|
|
if [ $arrQueueIdsCount -eq 0 ]; then
|
|
|
|
|
|
|
|
log "No items in queue to clean up..."
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
for queueId in $(echo $arrQueueIds); do
|
|
|
|
|
|
|
|
arrQueueItemData="$(echo "$arrQueueData" | jq -r "select(.id==$queueId)")"
|
|
|
|
|
|
|
|
arrQueueItemTitle="$(echo "$arrQueueItemData" | jq -r .title)"
|
|
|
|
|
|
|
|
log "Removing Failed Queue Item ID: $queueId ($arrQueueItemTitle) from Radarr..."
|
|
|
|
|
|
|
|
curl -sX DELETE "$arrUrl/api/v3/queue/$queueId?removeFromClient=true&blocklist=true&apikey=${arrApiKey}"
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
arrQueueData="$(curl -s "$arrUrl/api/v3/queue?page=1&pagesize=200&sortDirection=descending&sortKey=progress&includeUnknownMovieItems=true&apikey=${arrApiKey}" | jq -r .records[])"
|
|
|
|
CleanerProcess () {
|
|
|
|
arrQueueIds=$(echo "$arrQueueData" | jq -r 'select(.status=="failed") | select(.trackedDownloadStatus=="warning") | .id')
|
|
|
|
arrQueueData="$(curl -s "$arrUrl/api/v3/queue?page=1&pagesize=200&sortDirection=descending&sortKey=progress&includeUnknownSeriesItems=true&apikey=${arrApiKey}" | jq -r .records[])"
|
|
|
|
arrQueueIdsCount=$(echo "$arrQueueData" | jq -r 'select(.status=="failed") | 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
|
|
|
|
if [ $arrQueueIdsCount -eq 0 ]; then
|
|
|
|
log "No items in queue to clean up..."
|
|
|
|
log "No items in queue to clean up..."
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
for queueId in $(echo $arrQueuedIds); do
|
|
|
|
for queueId in $(echo $arrQueueIds); do
|
|
|
|
|
|
|
|
arrQueueItemData="$(echo "$arrQueueData" | jq -r "select(.id==$queueId)")"
|
|
|
|
arrQueueItemData="$(echo "$arrQueueData" | jq -r "select(.id==$queueId)")"
|
|
|
|
arrQueueItemTitle="$(echo "$arrQueueItemData" | jq -r .title)"
|
|
|
|
arrQueueItemTitle="$(echo "$arrQueueItemData" | jq -r .title)"
|
|
|
|
log "Removing Failed Queue Item ID: $queueId ($arrQueueItemTitle) from Radarr..."
|
|
|
|
log "Removing Failed Queue Item ID: $queueId ($arrQueueItemTitle) from Radarr..."
|
|
|
|
curl -sX DELETE "$arrUrl/api/v3/queue/$queueId?removeFromClient=true&blocklist=true&apikey=${arrApiKey}"
|
|
|
|
deleteItem=$(curl -sX DELETE "$arrUrl/api/v3/queue/$queueId?removeFromClient=true&blocklist=true&apikey=${arrApiKey}")
|
|
|
|
done
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CleanerProcess
|
|
|
|
|
|
|
|
|
|
|
|
exit
|
|
|
|
exit
|
|
|
|