mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-29 21:27:05 +02:00
Added constants for app name and version, use custom user-agent
This commit is contained in:
parent
f6b4ea4a46
commit
46e6a667c8
10 changed files with 75 additions and 6 deletions
|
@ -28,6 +28,7 @@ import (
|
|||
|
||||
"github.com/go-resty/resty/v2"
|
||||
"go.uploadedlobster.com/scotty/internal/ratelimit"
|
||||
"go.uploadedlobster.com/scotty/internal/version"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -48,6 +49,7 @@ func NewClient(token string) Client {
|
|||
client.SetAuthScheme("Token")
|
||||
client.SetAuthToken(token)
|
||||
client.SetHeader("Accept", "application/json")
|
||||
client.SetHeader("User-Agent", version.UserAgent())
|
||||
|
||||
// Handle rate limiting (see https://listenbrainz.readthedocs.io/en/latest/users/api/index.html#rate-limiting)
|
||||
ratelimit.EnableHTTPHeaderRateLimit(client, "X-RateLimit-Reset-In")
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
"go.uploadedlobster.com/scotty/internal/version"
|
||||
)
|
||||
|
||||
type ListenBrainzApiBackend struct {
|
||||
|
@ -119,7 +120,8 @@ func (b *ListenBrainzApiBackend) ImportListens(export models.ListensResult, impo
|
|||
AdditionalInfo: l.AdditionalInfo,
|
||||
},
|
||||
}
|
||||
listen.TrackMetadata.AdditionalInfo["submission_client"] = "Scotty"
|
||||
listen.TrackMetadata.AdditionalInfo["submission_client"] = version.AppName
|
||||
listen.TrackMetadata.AdditionalInfo["submission_client_version"] = version.AppVersion
|
||||
submission.Payload = append(submission.Payload, listen)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue