diff --git a/templates/upgrade-search.yaml b/templates/upgrade-search.yaml index 003c975..7a67329 100644 --- a/templates/upgrade-search.yaml +++ b/templates/upgrade-search.yaml @@ -3,8 +3,10 @@ Scheduled upgrade search (upgradeSearch.schedule): makes Sonarr/Radarr actively German / German DL instead of English-only files) for everything already in the library. RSS only sees new uploads, so older episodes would otherwise never be upgraded. -- Sonarr: SeriesSearch for every monitored series. Sonarr's "Cutoff Unmet" list only looks - at quality, not at custom format scores, so CutoffUnmetEpisodeSearch would find nothing. +- Sonarr: EpisodeSearch only for monitored episodes whose file scores below the profile's + cutoffFormatScore, plus MissingEpisodeSearch. Sonarr's "Cutoff Unmet" list only looks at + quality, not at custom format scores, so CutoffUnmetEpisodeSearch would find nothing; and a + SeriesSearch per series searches anime episode by episode (hundreds of indexer queries). - Radarr: CutoffUnmetMoviesSearch (Radarr does consider CF scores) + MissingMoviesSearch. The API keys are read at runtime from the apps' config PVCs (mounted read-only), so they @@ -48,9 +50,17 @@ spec: cmd() { curl -sf -H "X-Api-Key: $2" -H "Content-Type: application/json" -X POST "$1/api/v3/command" -d "$3" | jq -r '"\(.name): \(.status)"'; } S=http://sonarr:8989; SK=$(key /sonarr/config.xml) - for id in $(curl -sf -H "X-Api-Key: $SK" "$S/api/v3/series" | jq -r '.[] | select(.monitored) | .id'); do - cmd "$S" "$SK" "{\"name\":\"SeriesSearch\",\"seriesId\":$id}" + get() { curl -sf -H "X-Api-Key: $SK" "$S/api/v3/$1"; } + get series | jq -r '.[] | select(.monitored) | "\(.id) \(.qualityProfileId)"' | while read -r sid pid; do + cut=$(get "qualityprofile/$pid" | jq '.cutoffFormatScore') + low=$(get "episodefile?seriesId=$sid" | jq -c --argjson c "$cut" '[.[] | select(.customFormatScore < $c) | .id]') + ids=$(get "episode?seriesId=$sid" | jq -c --argjson low "$low" '[.[] | select(.monitored and .hasFile) | select(.episodeFileId as $f | $low | index($f)) | .id]') + if [ "$ids" != "[]" ]; then + echo "series $sid: $(echo "$ids" | jq length) episode(s) below cutoff $cut" + cmd "$S" "$SK" "{\"name\":\"EpisodeSearch\",\"episodeIds\":$ids}" + fi done + cmd "$S" "$SK" '{"name":"MissingEpisodeSearch"}' R=http://radarr:7878; RK=$(key /radarr/config.xml) cmd "$R" "$RK" '{"name":"CutoffUnmetMoviesSearch"}'