realdebrid

package
v0.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2020 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClientOpts = ClientOptions{
	BaseURL:  "https://api.real-debrid.com",
	Timeout:  5 * time.Second,
	CacheAge: 24 * time.Hour,
}

Functions

This section is empty.

Types

type Cache added in v0.7.0

type Cache interface {
	Set(key string) error
	Get(key string) (time.Time, bool, error)
}

Cache is the interface that the RealDebrid client uses for caching a user's API token validity and the "instant availability" of a torrent (via info_hash). A package user must pass an implementation of this interface. Usually you create a simple wrapper around an existing cache package. An example implementation is the InMemoryCache in this package.

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ClientOptions, tokenCache, availabilityCache Cache, logger *zap.Logger) (*Client, error)

func (*Client) CheckInstantAvailability added in v0.2.0

func (c *Client) CheckInstantAvailability(ctx context.Context, apiToken string, infoHashes ...string) []string

func (*Client) GetStreamURL

func (c *Client) GetStreamURL(ctx context.Context, magnetURL, apiToken string, remote bool) (string, error)

func (*Client) TestToken

func (c *Client) TestToken(ctx context.Context, apiToken string) error

type ClientOptions added in v0.7.0

type ClientOptions struct {
	BaseURL      string
	Timeout      time.Duration
	CacheAge     time.Duration
	ExtraHeaders []string
}

func NewClientOpts added in v0.7.0

func NewClientOpts(baseURL string, timeout, cacheAge time.Duration, extraHeaders []string) ClientOptions

type InMemoryCache added in v0.7.0

type InMemoryCache struct {
	// contains filtered or unexported fields
}

InMemoryCache is an example implementation of the Cache interface. It doesn't persist its data, so it's not suited for production use of the realdebrid package.

func NewInMemoryCache added in v0.8.0

func NewInMemoryCache() *InMemoryCache

NewInMemoryCache creates a new InMemoryCache.

func (*InMemoryCache) Get added in v0.7.0

func (c *InMemoryCache) Get(key string) (time.Time, bool, error)

Get returns the time the API token / "instant availability" was cached. The boolean return value signals if the value was found in the cache.

func (*InMemoryCache) Set added in v0.7.0

func (c *InMemoryCache) Set(key string) error

Set caches the validity of a user's API token or the "instant availability" for a torrent (via info_hash). There's no need to pass a boolean or so - if a value gets cached it means the token is valid / the torrent is "instantly available".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL