ListenBrainz: Love export and basic import

Love import currently works only for tracks with existing recording MBID
This commit is contained in:
Philipp Wolfer 2023-11-13 09:21:22 +01:00
parent ead323eaed
commit 0020594ea3
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
6 changed files with 300 additions and 4 deletions

View file

@ -60,7 +60,7 @@ func (c Client) GetListens(user string, maxTime time.Time, minTime time.Time) (r
SetQueryParams(map[string]string{
"max_ts": strconv.FormatInt(maxTime.Unix(), 10),
"min_ts": strconv.FormatInt(minTime.Unix(), 10),
"count": strconv.FormatInt(int64(c.MaxResults), 10),
"count": strconv.Itoa(c.MaxResults),
}).
SetResult(&result).
Get(path)
@ -71,3 +71,36 @@ func (c Client) GetListens(user string, maxTime time.Time, minTime time.Time) (r
}
return
}
func (c Client) GetFeedback(user string, status int, offset int) (result GetFeedbackResult, err error) {
const path = "/feedback/user/{username}/get-feedback"
response, err := c.HttpClient.R().
SetPathParam("username", user).
SetQueryParams(map[string]string{
"status": strconv.Itoa(status),
"offset": strconv.Itoa(offset),
"count": strconv.Itoa(c.MaxResults),
}).
SetResult(&result).
Get(path)
if response.StatusCode() != 200 {
err = errors.New(response.String())
return
}
return
}
func (c Client) SendFeedback(feedback Feedback) (result StatusResult, err error) {
const path = "/feedback/recording-feedback"
response, err := c.HttpClient.R().
SetBody(feedback).
SetResult(&result).
Post(path)
if response.StatusCode() != 200 {
err = errors.New(response.String())
return
}
return
}