92 lines
4.0 KiB
YAML
92 lines
4.0 KiB
YAML
{{- /*
|
|
Scheduled upgrade search (upgradeSearch.schedule): makes Sonarr/Radarr actively look for better releases (in practice:
|
|
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: 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
|
|
never have to be copied into a Secret or into git. Reuses the Sonarr image (curl + jq).
|
|
*/ -}}
|
|
{{- if .Values.upgradeSearch.enabled }}
|
|
apiVersion: batch/v1
|
|
kind: CronJob
|
|
metadata:
|
|
name: upgrade-search
|
|
namespace: {{ .Values.namespace }}
|
|
labels:
|
|
app.kubernetes.io/name: upgrade-search
|
|
spec:
|
|
schedule: {{ .Values.upgradeSearch.schedule | quote }}
|
|
timeZone: {{ .Values.common.tz }}
|
|
concurrencyPolicy: Forbid
|
|
successfulJobsHistoryLimit: 2
|
|
failedJobsHistoryLimit: 2
|
|
jobTemplate:
|
|
spec:
|
|
backoffLimit: 1
|
|
ttlSecondsAfterFinished: 604800
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: upgrade-search
|
|
spec:
|
|
restartPolicy: Never
|
|
securityContext:
|
|
runAsUser: {{ .Values.common.puid }}
|
|
runAsGroup: {{ .Values.common.pgid }}
|
|
containers:
|
|
- name: search
|
|
image: {{ .Values.apps.sonarr.image }}
|
|
command: ["/bin/sh", "-c"]
|
|
args:
|
|
- |
|
|
set -eu
|
|
key() { sed -n 's:.*<ApiKey>\(.*\)</ApiKey>.*:\1:p' "$1"; }
|
|
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)
|
|
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"}'
|
|
cmd "$R" "$RK" '{"name":"MissingMoviesSearch"}'
|
|
resources:
|
|
requests:
|
|
cpu: 10m
|
|
memory: 32Mi
|
|
limits:
|
|
cpu: 200m
|
|
memory: 128Mi
|
|
volumeMounts:
|
|
- name: sonarr-config
|
|
mountPath: /sonarr
|
|
readOnly: true
|
|
- name: radarr-config
|
|
mountPath: /radarr
|
|
readOnly: true
|
|
volumes:
|
|
- name: sonarr-config
|
|
persistentVolumeClaim:
|
|
claimName: sonarr-config
|
|
readOnly: true
|
|
- name: radarr-config
|
|
persistentVolumeClaim:
|
|
claimName: radarr-config
|
|
readOnly: true
|
|
{{- end }}
|