feat: add MusicBrainz artist-ID resolver

Add ResolveArtistMBID to query the MB artist search endpoint and return the
first matching artist ID, with httptest-backed tests for match, no-match,
HTTP error, and invalid-JSON paths.
This commit is contained in:
2026-07-19 22:16:43 +03:00
parent 85c42ec858
commit 40c4240693
3 changed files with 156 additions and 4 deletions

View File

@@ -89,10 +89,10 @@ name collisions.)
- [x] run tests - must pass before task 2
### Task 2: MusicBrainz artist-ID resolver
- [ ] add `ResolveArtistMBID(ctx, client, name) (string, error)` in `internal/musicbrainz` using `/ws/2/artist/?query=artist:<name>&fmt=json`
- [ ] parse first matching artist ID from JSON response; return error if none
- [ ] write tests with httptest stub (match found, no match, HTTP error)
- [ ] run tests - must pass before task 3
- [x] add `ResolveArtistMBID(ctx, client, name) (string, error)` in `internal/musicbrainz` using `/ws/2/artist/?query=artist:<name>&fmt=json`
- [x] parse first matching artist ID from JSON response; return error if none
- [x] write tests with httptest stub (match found, no match, HTTP error)
- [x] run tests - must pass before task 3
### Task 3: Periodic sync pipeline
- [ ] add `SyncAll(ctx, ndClient, mbClient, db, ttl)` orchestrator: for each monitored artist → ensure MBID (resolve + persist if missing) → `musicbrainz.SyncArtistDiscography` → `navidrome.SyncAlbums`