feat(server/m7-353): config + main.go wiring for coverart enricher
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/auth"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/config"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/coverart"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/db"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/library"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/lidarrconfig"
|
||||
@@ -71,11 +72,34 @@ func run() error {
|
||||
}
|
||||
|
||||
scanner := library.New(pool, logger, cfg.Library.ScanPaths)
|
||||
|
||||
contact := cfg.Library.ContactEmail
|
||||
if contact == "" {
|
||||
contact = "https://git.fabledsword.com/bvandeusen/minstrel"
|
||||
}
|
||||
coverFetcher := coverart.NewFetcher(coverart.FetcherConfig{
|
||||
UserAgent: fmt.Sprintf("Minstrel/dev (%s)", contact),
|
||||
MinPeriod: time.Second,
|
||||
})
|
||||
coverEnricher := coverart.NewEnricher(pool, logger.With("component", "coverart"), coverFetcher, cfg.Library.CoverArtFromMBCAA)
|
||||
|
||||
if cfg.Library.ScanOnStartup && len(cfg.Library.ScanPaths) > 0 {
|
||||
go func() {
|
||||
if _, err := scanner.Scan(ctx); err != nil {
|
||||
logger.Error("startup scan failed", "err", err)
|
||||
}
|
||||
// Enrich any newly-imported albums (and resume any partial backlog).
|
||||
if _, err := coverEnricher.EnrichBatch(ctx, cfg.Library.CoverArtBackfillCap); err != nil {
|
||||
logger.Warn("post-scan cover enrichment failed", "err", err)
|
||||
}
|
||||
}()
|
||||
} else {
|
||||
// No startup scan — still run the boot backfill once for any rows
|
||||
// the previous run didn't get to.
|
||||
go func() {
|
||||
if _, err := coverEnricher.EnrichBatch(ctx, cfg.Library.CoverArtBackfillCap); err != nil {
|
||||
logger.Warn("boot cover enrichment failed", "err", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user