mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-07 21:48:18 -08:00
chore: move useragent to cfg
This commit is contained in:
parent
7b18ebb294
commit
63517c0a03
5 changed files with 15 additions and 5 deletions
|
|
@ -96,7 +96,7 @@ func Run(
|
|||
}
|
||||
|
||||
images.Initialize(images.ImageSourceOpts{
|
||||
UserAgent: "Koito v0.0.1 (contact@koito.app)",
|
||||
UserAgent: cfg.UserAgent(),
|
||||
EnableCAA: !cfg.CoverArtArchiveDisabled(),
|
||||
EnableDeezer: !cfg.DeezerDisabled(),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ type config struct {
|
|||
allowAllHosts bool
|
||||
disableRateLimit bool
|
||||
importThrottleMs int
|
||||
userAgent string
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
@ -123,6 +124,8 @@ func loadConfig(getenv func(string) string) (*config, error) {
|
|||
cfg.disableMusicBrainz = parseBool(getenv(DISABLE_MUSICBRAINZ_ENV))
|
||||
cfg.skipImport = parseBool(getenv(SKIP_IMPORT_ENV))
|
||||
|
||||
cfg.userAgent = "Koito v0.0.1 (contact@koito.io)"
|
||||
|
||||
if getenv(DEFAULT_USERNAME_ENV) == "" {
|
||||
cfg.defaultUsername = "admin"
|
||||
} else {
|
||||
|
|
@ -168,6 +171,12 @@ func parseBool(s string) bool {
|
|||
|
||||
// Global accessors for configuration values
|
||||
|
||||
func UserAgent() string {
|
||||
lock.RLock()
|
||||
defer lock.RUnlock()
|
||||
return globalConfig.userAgent
|
||||
}
|
||||
|
||||
func ListenAddr() string {
|
||||
lock.RLock()
|
||||
defer lock.RUnlock()
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/gabehf/koito/internal/cfg"
|
||||
"github.com/gabehf/koito/internal/logger"
|
||||
"github.com/gabehf/koito/internal/utils"
|
||||
"github.com/gabehf/koito/queue"
|
||||
|
|
@ -48,10 +49,10 @@ const (
|
|||
artistImageEndpoint = "/search/artist?q=%s"
|
||||
)
|
||||
|
||||
func NewDeezerClient(useragent string) *DeezerClient {
|
||||
func NewDeezerClient() *DeezerClient {
|
||||
ret := new(DeezerClient)
|
||||
ret.url = deezerBaseUrl
|
||||
ret.userAgent = useragent
|
||||
ret.userAgent = cfg.UserAgent()
|
||||
ret.requestQueue = queue.NewRequestQueue(1, 1)
|
||||
return ret
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ func Initialize(opts ImageSourceOpts) {
|
|||
}
|
||||
if opts.EnableDeezer {
|
||||
imgsrc.deezerEnabled = true
|
||||
imgsrc.deezerC = NewDeezerClient(opts.UserAgent)
|
||||
imgsrc.deezerC = NewDeezerClient()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ type MusicBrainzCaller interface {
|
|||
func NewMusicBrainzClient() *MusicBrainzClient {
|
||||
ret := new(MusicBrainzClient)
|
||||
ret.url = cfg.MusicBrainzUrl()
|
||||
ret.userAgent = "Koito/0.0.1 (contact@koito.app)"
|
||||
ret.userAgent = cfg.UserAgent()
|
||||
ret.requestQueue = queue.NewRequestQueue(cfg.MusicBrainzRateLimit(), cfg.MusicBrainzRateLimit())
|
||||
return ret
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue