Files
minstrel/internal/lidarr/types.go
T
bvandeusenandClaude Opus 5.5 670b30c954
release / web (push) Successful in 1m42s
release / go (push) Successful in 2m7s
release / govulncheck (push) Successful in 37s
release / integration (push) Successful in 5m31s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / android (push) Canceled after 5m14s
release / Build signed APK (releases and dev) (push) Canceled after 4m42s
fix(lidarr): add an album as the looked-up resource with its artist nested (#5234)
Lidarr's POST /api/v1/album validates `artist` as a nested resource
(AlbumController: RuleFor(s => s.Artist).NotNull()), so the flat payload
we sent was refused with "'Artist' must not be empty" every time. The
album add has never worked against a real Lidarr; approved album and
track requests sat in the reconciler retrying every 5 minutes.

AddAlbum now does what Lidarr's own add-album UI does (getNewAlbum /
getNewArtist): look the album up by MBID (album/lookup?term=lidarr:<mbid>),
then POST that resource back with monitored + searchForNewAlbum. When
Lidarr doesn't have the artist yet, the nested artist gets the request's
quality/metadata profile and root folder, monitors this album only
(monitor "none" + albumsToMonitor, which AlbumMonitoredService prefers)
and no future releases. An artist Lidarr already has is left as it is.
An MBID Lidarr's metadata doesn't know is ErrNotFound with no POST.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 10:55:41 -04:00

98 lines
3.6 KiB
Go

// Package lidarr is a typed HTTP client for Lidarr's v1 API. It is the
// only place in the codebase that knows about Lidarr's wire format.
// Callers receive value structs, never raw JSON.
package lidarr
// LookupResult is the normalized shape returned by Lookup{Artist,Album,Track}.
// 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
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.
type QualityProfile struct {
ID int
Name string
}
// MetadataProfile controls which release types Lidarr tracks for an artist
// (album / single / EP / compilation). It's a separate Lidarr concept from
// quality profile and is required on POST /api/v1/artist — Lidarr 4xx's
// the request with "'Metadata Profile Id' must be greater than '0'" if
// it's missing or zero.
type MetadataProfile struct {
ID int
Name string
}
// RootFolder is the dropdown choice in /admin/integrations.
type RootFolder struct {
Path string
Accessible bool
FreeSpace int64
}
// AddArtistParams are the fields Lidarr requires on POST /api/v1/artist.
// ArtistName and MetadataProfileID are both required; omitting either
// produces a 400 with field-validation errors.
type AddArtistParams struct {
ForeignArtistID string
ArtistName string
QualityProfileID int
MetadataProfileID int
RootFolderPath string
MonitorAll bool // true => monitor="all"; false => "future"
}
// AddAlbumParams identify the album to add and carry the settings Lidarr
// needs when it has to create the parent artist on the fly (an album by an
// artist not yet in Lidarr). The artist fields are a fallback only: the
// album lookup normally supplies the artist itself.
type AddAlbumParams struct {
ForeignAlbumID string
ForeignArtistID string // Lidarr requires the artist's foreign id too
ArtistName string
QualityProfileID int
MetadataProfileID int
RootFolderPath string
}
// PingResult is the response shape from GET /api/v1/system/status.
type PingResult struct {
Version string
}
// LidarrArtist is the subset of Lidarr's artist resource used by M5b
// admin actions. The "id" field is Lidarr's internal numeric ID — needed
// for DELETE /api/v1/artist/{id} calls.
type LidarrArtist struct {
ID int `json:"id"`
ForeignArtistID string `json:"foreignArtistId"` // MBID
ArtistName string `json:"artistName"`
}
// LidarrAlbum is the subset of Lidarr's album resource used by M5b
// admin actions.
type LidarrAlbum struct {
ID int `json:"id"`
ForeignAlbumID string `json:"foreignAlbumId"` // MBID
Title string `json:"title"`
ArtistID int `json:"artistId"`
}