fix(lidarr): address review findings on HTTP client
- Add ArtistMBID/AlbumMBID to LookupResult so handlers can build the full lidarr_requests row from album/track lookups (parent MBID is needed for the AddAlbum API call and for the schema's NOT NULL lidarr_artist_mbid) - Trim trailing slash on BaseURL before joining paths to avoid double-slash URLs when operators enter "http://lidarr.lan/" - Check json.Marshal errors in AddArtist/AddAlbum - Extract lidarrImage as a named unexported type instead of repeating the anonymous struct three times - Add NewClient(baseURL, apiKey) constructor with 30s default timeout - Add ErrLookupFailed test coverage for the 4xx-non-auth branch on both get and post helpers - Rename TestListRootFolders_BadJSON -> _NullBody (it tests null, not malformed); add a real malformed-JSON test - Defensive separator guard on LookupAlbum.Secondary so an empty ArtistName doesn't produce a leading " · " Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,13 +4,25 @@
|
||||
package lidarr
|
||||
|
||||
// LookupResult is the normalized shape returned by Lookup{Artist,Album,Track}.
|
||||
// It is what we store on the request row (via the user's request) and
|
||||
// what /api/lidarr/search returns to the SPA.
|
||||
// MBID is the kind's primary identifier (foreignArtistId / foreignAlbumId /
|
||||
// foreignTrackId from Lidarr). ArtistMBID and AlbumMBID carry parent
|
||||
// identifiers when the kind has them — request creation and admin
|
||||
// approval need them to construct the lidarr_requests row and the
|
||||
// AddArtist/AddAlbum API calls.
|
||||
type LookupResult struct {
|
||||
MBID string // foreignArtistId / foreignAlbumId / foreignTrackId
|
||||
Name string // artist name; album/track returns Title here too
|
||||
Secondary string // genre + album count for artist; year for album; album for track
|
||||
ImageURL string // cover-art URL Lidarr surfaced (may be empty)
|
||||
MBID string // foreignArtistId / foreignAlbumId / foreignTrackId
|
||||
ArtistMBID string // parent artist's foreignArtistId — set on album/track results, empty on artist results
|
||||
AlbumMBID string // parent album's foreignAlbumId — set on track results only
|
||||
Name string // artist name; album/track returns Title here too
|
||||
Secondary string // genre + album count for artist; year for album; album for track
|
||||
ImageURL string // cover-art URL Lidarr surfaced (may be empty)
|
||||
}
|
||||
|
||||
// lidarrImage is the wire shape for image entries in Lidarr's API responses.
|
||||
type lidarrImage struct {
|
||||
CoverType string `json:"coverType"`
|
||||
RemoteURL string `json:"remoteUrl"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// QualityProfile is the dropdown choice in /admin/integrations.
|
||||
|
||||
Reference in New Issue
Block a user