arr-search: shuffle and do more
This commit is contained in:
@@ -13,6 +13,7 @@ let
|
||||
|
||||
curl = "${pkgs.curl}/bin/curl";
|
||||
jq = "${pkgs.jq}/bin/jq";
|
||||
shuf = "${pkgs.coreutils}/bin/shuf";
|
||||
|
||||
# Max items to search per cycle per category (missing + cutoff) per app
|
||||
maxPerCycle = 5;
|
||||
@@ -54,10 +55,16 @@ let
|
||||
local label="$2"
|
||||
|
||||
local series_ids
|
||||
series_ids=$(${curl} -sf --max-time 30 \
|
||||
# Fetch the full wanted list, dedupe to seriesIds, then randomly
|
||||
# sample maxPerCycle. Sonarr's wanted endpoint returns one record
|
||||
# per episode, so a small pageSize collapses to a single seriesId
|
||||
# whenever any one show dominates the alphabetical head of the
|
||||
# backlog -- which starves every other show indefinitely.
|
||||
series_ids=$(${curl} -sf --max-time 60 \
|
||||
-H "X-Api-Key: $SONARR_KEY" \
|
||||
"${sonarrUrl}/api/v3/wanted/$endpoint?page=1&pageSize=${builtins.toString maxPerCycle}&monitored=true&sortKey=title&sortDirection=ascending&includeSeries=true" \
|
||||
| ${jq} -r '[.records[].seriesId] | unique | .[] // empty')
|
||||
"${sonarrUrl}/api/v3/wanted/$endpoint?page=1&pageSize=5000&monitored=true" \
|
||||
| ${jq} -r '[.records[].seriesId] | unique | .[]' \
|
||||
| ${shuf} -n ${builtins.toString maxPerCycle})
|
||||
|
||||
if [ -z "$series_ids" ]; then
|
||||
echo "sonarr: no $label items"
|
||||
|
||||
Reference in New Issue
Block a user