fix(lidarr): include artistName + metadataProfileId on add-artist/add-album
The 'lidarr_rejected' the operator was hitting on Approve was Lidarr 4xx-ing the POST with two field-validation errors: 'Metadata Profile Id' must be greater than '0'. 'Artist Name' must not be empty. Our payload was missing both. Lidarr's metadata profile is a separate concept from quality profile (it controls which release types are tracked: albums, singles, EPs, etc.) and is required by /api/v1/artist and /api/v1/album. The 'already exists' line in the toast copy was an incorrect guess at the cause; the real issue was an invalid payload. Changes: - internal/lidarr/types.go: AddArtistParams + AddAlbumParams gain ArtistName and MetadataProfileID. New MetadataProfile struct mirroring QualityProfile. - internal/lidarr/client.go: AddArtist + AddAlbum payloads include both new fields. New ListMetadataProfiles fetches GET /api/v1/metadataprofile. - internal/lidarrrequests/service.go: Approve fetches the metadata profile list and uses the first as a default (Lidarr installs ship 'Standard' at id=1 OOB, so this works for vanilla setups). Picker on /admin/integrations is a follow-up. ArtistName flows from the request row. - web/src/routes/admin/requests/+page.svelte: drop the speculative 'usually means already in library' copy on lidarr_rejected; point operators at server logs for the field-level reason instead. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -178,10 +178,31 @@ func (s *Service) Approve(ctx context.Context, requestID pgtype.UUID, adminID pg
|
||||
return dbq.LidarrRequest{}, ErrDefaultsIncomplete
|
||||
}
|
||||
|
||||
// Lidarr requires a metadata profile id on POST /api/v1/artist (and
|
||||
// on /api/v1/album when it has to create the parent artist). We
|
||||
// don't store this in lidarr_config yet — fetch the available
|
||||
// profiles per-Approve and pick the first as a sensible default.
|
||||
// Lidarr installs ship "Standard" at id=1 OOB, so this works for
|
||||
// vanilla setups; operators with custom profiles get whichever was
|
||||
// saved first. A picker on /admin/integrations is a follow-up.
|
||||
mdProfiles, err := client.ListMetadataProfiles(ctx)
|
||||
if err != nil {
|
||||
return dbq.LidarrRequest{}, fmt.Errorf("approve: list metadata profiles: %w", err)
|
||||
}
|
||||
if len(mdProfiles) == 0 {
|
||||
return dbq.LidarrRequest{}, fmt.Errorf("approve: no metadata profiles configured in lidarr")
|
||||
}
|
||||
mdProfileID := mdProfiles[0].ID
|
||||
|
||||
switch row.Kind {
|
||||
case dbq.LidarrRequestKindArtist:
|
||||
err = client.AddArtist(ctx, lidarr.AddArtistParams{
|
||||
ForeignArtistID: row.LidarrArtistMbid, QualityProfileID: qp, RootFolderPath: rf, MonitorAll: true,
|
||||
ForeignArtistID: row.LidarrArtistMbid,
|
||||
ArtistName: row.ArtistName,
|
||||
QualityProfileID: qp,
|
||||
MetadataProfileID: mdProfileID,
|
||||
RootFolderPath: rf,
|
||||
MonitorAll: true,
|
||||
})
|
||||
case dbq.LidarrRequestKindAlbum, dbq.LidarrRequestKindTrack:
|
||||
// Track-kind requests promote to album-add; the spec is explicit.
|
||||
@@ -190,8 +211,12 @@ func (s *Service) Approve(ctx context.Context, requestID pgtype.UUID, adminID pg
|
||||
albumMBID = *row.LidarrAlbumMbid
|
||||
}
|
||||
err = client.AddAlbum(ctx, lidarr.AddAlbumParams{
|
||||
ForeignAlbumID: albumMBID, ForeignArtistID: row.LidarrArtistMbid,
|
||||
QualityProfileID: qp, RootFolderPath: rf,
|
||||
ForeignAlbumID: albumMBID,
|
||||
ForeignArtistID: row.LidarrArtistMbid,
|
||||
ArtistName: row.ArtistName,
|
||||
QualityProfileID: qp,
|
||||
MetadataProfileID: mdProfileID,
|
||||
RootFolderPath: rf,
|
||||
})
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user