diff --git a/Arrs_Stack/radarr_cleanup.sh b/Arrs_Stack/radarr_cleanup.sh index 15f9030..23b59a8 100755 --- a/Arrs_Stack/radarr_cleanup.sh +++ b/Arrs_Stack/radarr_cleanup.sh @@ -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 - 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" + 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 "$movies_now" | jq -r '.[] | select(.hasFile==true) | .movieFile.path' 2>/dev/null) sort -u "$TRACKED_FILE" -o "$TRACKED_FILE"