mirror of
https://git.sr.ht/~phw/scotty
synced 2025-06-05 04:58:33 +02:00
Use LB API to lookup missing metadata for loves
This is faster than using the MBID API individually
This commit is contained in:
parent
dddd2e4eec
commit
7542657925
4 changed files with 194 additions and 51 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue