Eliminate radarr_cleanup.sh's per-movie API calls

Radarr's movie list already embeds movieFile.path on every hasFile=true
entry -- confirmed live, zero exceptions across the full library. The
separate moviefile?movieId=X call per movie (2896 of them) was fetching
data already sitting in the list this script fetches anyway. One live
list fetch replaces up to 2896 per-movie calls, every time this function
runs including rescan-aware retries.
This commit is contained in:
Gmer4Lfe
2026-07-17 00:25:18 -04:00
parent 9d27fac3b1
commit a22433967a
+12 -11
View File
@@ -309,22 +309,23 @@ TRACKED_FILE="$TMP_DIR/tracked_paths.txt"
# Fetches every movie's file path fresh into TRACKED_FILE/TRACKED_MAP/TRACKED_COUNT. Pulled
# into a function so the rescan-aware retry below can re-fetch after waiting without
# duplicating this whole loop inline.
#
# Radarr's movie list already embeds movieFile.path directly on every entry with
# hasFile=true (confirmed live 2026-07-17, zero exceptions across the full library) —
# unlike Lidarr/Sonarr, where trackFile/episodefile genuinely require a separate per-item
# call. A single live movie-list fetch replaces what used to be one API call per movie
# (2896 of them) for the same data already sitting in that response. Still a fresh live
# fetch on every call (not cache-first) — this function's whole purpose during the
# rescan-aware retry below is to see Radarr's progress as the rescan updates hasFile/
# movieFile, so it needs genuinely current data each time, not a stale snapshot.
_fetch_tracked_files() {
> "$TRACKED_FILE"
local _movie_index=0
while IFS= read -r movie_id; do
[[ -z "$movie_id" ]] && continue
(( _movie_index++ ))
[[ $(( _movie_index % 100 )) -eq 0 ]] && \
log "Fetching files: $_movie_index/$MOVIE_COUNT movies..."
MOVIE_FILES=$(arr_api "$RADARR_URL" "$RADARR_API_KEY" "v3" "moviefile?movieId=${movie_id}" "Radarr" 2>/dev/null)
if [[ -n "$MOVIE_FILES" ]]; then
local movies_now
movies_now=$(arr_api "$RADARR_URL" "$RADARR_API_KEY" "v3" "movie" "Radarr" 2>/dev/null)
while IFS= read -r api_path; do
[[ -z "$api_path" ]] && continue
translate_path "$api_path" >> "$TRACKED_FILE"
done < <(echo "$MOVIE_FILES" | jq -r '.[].path // .path' 2>/dev/null)
fi
done <<< "$MOVIE_IDS"
done < <(echo "$movies_now" | jq -r '.[] | select(.hasFile==true) | .movieFile.path' 2>/dev/null)
sort -u "$TRACKED_FILE" -o "$TRACKED_FILE"