Add a scheduled, throttled metadata refresh for books already in the library

Aperta
#956 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
backend

Direzione di ricerca

Start with LibraryController.cs and LibraryMetadataRescanWorkflow.cs for the existing per-book refresh, then read AuthorMonitoringBackgroundService.cs and AuthorMonitoringService.cs for scheduling and monitoring patterns. The issue proposes three coordinated operations sharing a throttle that counts provider requests, plus progress and logging; scope and design are still open for discussion, so agree on the shape before implementation.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The only route that re-fetches provider metadata for a book already in the library is per book: POST /api/v1/library/{id}/rescan-metadata (listenarr.api/Features/Library/LibraryController.cs:165). Nothing schedules it, and there is no library-wide or per-author way to trigger it either.

Author monitoring and series monitoring each announce a twenty-four hour interval on start and report each cycle's completion (AuthorMonitoringBackgroundService.cs, around lines 28 and 32), but every message either job emits is about adding a book, not revisiting one. In AuthorMonitoringService.cs, a book already matched to an existing row increments an ExistingCount and moves to the next one, around lines 253 and 278; nothing there refreshes it. The one job whose name contains "rescan," MetadataRescanService.cs (five minutes fixed at line 32), turns out to be a file-tag repair job rather than a provider refresh, and logs nothing on a cycle with no candidate files.

The per-book call bypasses the metadata cache (GetMetadataAsync(..., cache: false), LibraryMetadataRescanWorkflow.cs around line 169) and loops the configured regions for every identifier it tries (around lines 147, 201 and 224), so one book is worth more than one provider request. A throttle on a bulk version of this needs to count requests, not books, or it will undercount its own traffic by that multiplier. The endpoint has a short per-actor cooldown on one call, but nothing throttles a run across many books, since no such run exists yet.

I think the shape to reach for is close to what Sonarr, Radarr and Readarr already settled on for their own catalogue units. Readarr, as I recall it, offers a per-author refresh-and-scan command alongside a scheduled refresh task, both routed through the provider client's own rate limiting. I'd name three shapes here, all through the same throttle: a per-author manual trigger, since the per-book route exists and a library-wide one doesn't, and the author is the natural unit the monitoring jobs already work in; a background job walking monitored authors on a configurable interval and refreshing the books already held for each, spread across the interval rather than fired all at once; and an explicit library-wide operation, with its own progress reporting, for when a per-author walk isn't the right tool, catching a whole library up in one throttled pass instead of a shell loop hitting the per-book endpoint thousands of times. A tasks page listing every scheduled job would help, but that's a separate, larger piece of work, so I'm leaving it out here.

On a real library I measured a couple of thousand series-membership rows with no identifier and never a second series, a separate defect I am writing up. Our #768 and #847, plus a monitoring-mapper fix still in progress, should get new rows carrying that data correctly going forward, but none of it repairs what's already there. That's exactly the case the library-wide operation above is for: once a fix like that lands, catching existing rows up should be one throttled operation, not thousands of individual calls.

I am building all three as one piece of work, sharing the per-book workflow, one throttle that counts provider requests, and the log contract the monitoring jobs already follow, and running it on a real library before offering it. If you would rather have fewer of the three, or a different unit than the author, say so before it arrives and I will cut it to fit.

Disclosure: drafted with Claude Code at my direction; I read the cited code at the stated commit and reviewed this before posting.

Lingua principale
C#
Stelle
901
Fork
70
Merge medio
16h 27m
PR unite (30g)
60

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Listenarrs/Listenarr

Tutte le issue di Listenarrs/Listenarr

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.