Add Lidarr tracked-data cache + duplicate artist cleanup

Shared cache (lidarr_get_tracked_data() in common.sh) so scripts stop
hitting Lidarr's live API for tracked counts every run, and stop
treating a mid-rescan dip as a genuine problem — a whole-library
RescanFolders legitimately makes trackFileCount read far below normal
while it re-verifies every file (confirmed 2026-07-16: 22% of normal
mid-scan). Cache reads fresh-if-recent, waits out an active rescan
(calibrated to that command's own historical duration, tracked per
command name since RescanFolders and DownloadedAlbumsScan take wildly
different amounts of time), then falls back to a stale cache rather
than hard-failing after a few strikes.

lidarr_cleanup.sh: no longer stacks a fresh DownloadedAlbumsScan on
top of one already running, and the tracked-count floor check now
waits out a genuine rescan instead of aborting on every overlap.

lidarr_duplicate_artist_cleanup.sh (new): finds case-insensitive
duplicate artist entries — same display name, different MusicBrainz
ID, added when a search/list-sync matches the wrong same-named artist.
Deletes the empty phantom side and blocks it from Import List
Exclusions, leaves genuinely-different-real-artists alone (checked by
album title overlap, deduped per-artist first so a legitimate reissue
under an artist's own catalog doesn't false-flag as cross-artist
overlap), and only notifies for the rare case where both sides have
real, overlapping content.

lidarr_cache_prefill.sh (new): warms the cache at array start so nothing
reads it cold after boot.

lidarr_missing_art.sh, lidarr_release_fixer.sh: write-through the cache
as a side effect of fetches they already needed for their own purposes.
This commit is contained in:
Gmer4Lfe
2026-07-16 14:02:35 -04:00
parent 8bdf7eeb9c
commit 59cee06f45
7 changed files with 667 additions and 26 deletions
+3
View File
@@ -306,6 +306,9 @@ ALL_ARTISTS=$(lidarr_api "artist") || {
error "Failed to fetch artists"
exit 1
}
# Write-through — keeps the shared tracked-data cache fresh as a side effect of a fetch
# this script already needed for its own purposes. See lidarr_get_tracked_data() in common.sh.
lidarr_cache_write "$ALL_ARTISTS"
while IFS= read -r artist; do
aid=$(echo "$artist" | jq -r '.id')