35
media/trakt/trakt.go
Normal file
35
media/trakt/trakt.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package trakt
|
||||
|
||||
import (
|
||||
"github.com/l3uddz/nabarr/logger"
|
||||
"github.com/rs/zerolog"
|
||||
"go.uber.org/ratelimit"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
clientId string
|
||||
log zerolog.Logger
|
||||
rl ratelimit.Limiter
|
||||
|
||||
apiURL string
|
||||
apiTimeout time.Duration
|
||||
}
|
||||
|
||||
func New(cfg *Config) *Client {
|
||||
return &Client{
|
||||
clientId: cfg.ClientId,
|
||||
log: logger.New(cfg.Verbosity).With().Logger(),
|
||||
rl: ratelimit.New(1, ratelimit.WithoutSlack),
|
||||
|
||||
apiURL: "https://api.trakt.tv",
|
||||
apiTimeout: 30 * time.Second,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) getAuthHeaders() map[string]string {
|
||||
return map[string]string{
|
||||
"trakt-api-key": c.clientId,
|
||||
"trakt-api-version": "2",
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user