Use LB API to lookup missing metadata for loves

This is faster than using the MBID API individually
This commit is contained in:
Philipp Wolfer 2025-05-24 16:46:10 +02:00
parent dddd2e4eec
commit 7542657925
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
4 changed files with 194 additions and 51 deletions

View file

@ -28,6 +28,7 @@ import (
"time"
"github.com/go-resty/resty/v2"
"go.uploadedlobster.com/mbtypes"
"go.uploadedlobster.com/scotty/pkg/ratelimit"
)
@ -158,3 +159,24 @@ func (c Client) Lookup(ctx context.Context, recordingName string, artistName str
}
return
}
func (c Client) MetadataRecordings(ctx context.Context, mbids []mbtypes.MBID) (result RecordingMetadataResult, err error) {
const path = "/metadata/recording/"
errorResult := ErrorResult{}
body := RecordingMetadataRequest{
RecordingMBIDs: mbids,
Includes: "artist release",
}
response, err := c.HTTPClient.R().
SetContext(ctx).
SetBody(body).
SetResult(&result).
SetError(&errorResult).
Post(path)
if !response.IsSuccess() {
err = errors.New(errorResult.Error)
return
}
return
}