Back to godoc.org

Package imdb2torrent

v0.8.1
Latest Go to latest

The latest major version is .

Published: Aug 27, 2020 | License: AGPL-3.0 | Module: github.com/doingodswork/deflix-stremio

Index

Variables

var DefaultIbitClientOpts = IbitClientOptions{
	BaseURL:  "https://ibit.am",
	Timeout:  5 * time.Second,
	CacheAge: 24 * time.Hour,
}
var DefaultLeetxClientOpts = LeetxClientOptions{
	BaseURL:  "https://1337x.to",
	Timeout:  5 * time.Second,
	CacheAge: 24 * time.Hour,
}
var DefaultTPBclientOpts = TPBclientOptions{
	BaseURL:  "https://apibay.org",
	Timeout:  5 * time.Second,
	CacheAge: 24 * time.Hour,
}
var DefaultYTSclientOpts = YTSclientOptions{
	BaseURL:  "https://yts.mx",
	Timeout:  5 * time.Second,
	CacheAge: 24 * time.Hour,
}

func NewIbitClient

func NewIbitClient(opts IbitClientOptions, cache Cache, logger *zap.Logger, logFoundTorrents bool) *ibitClient

func NewLeetxClient

func NewLeetxClient(opts LeetxClientOptions, cache Cache, cinemetaClient *cinemeta.Client, logger *zap.Logger, logFoundTorrents bool) *leetxClient

func NewTPBclient

func NewTPBclient(opts TPBclientOptions, cache Cache, cinemetaClient *cinemeta.Client, logger *zap.Logger, logFoundTorrents bool) (*tpbClient, error)

func NewYTSclient

func NewYTSclient(opts YTSclientOptions, cache Cache, logger *zap.Logger, logFoundTorrents bool) *ytsClient

type Cache

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

Cache is the interface that the imdb2torrent clients use for caching results. 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 CacheItem

type CacheItem struct {
	Results []Result
	Created time.Time
}

CacheItem combines Result objects and a creation time in a single struct. This can be useful for implementing the Cache interface, but is not necessarily required. See the InMemoryCache example implementation of the Cache interface for its usage.

type Client

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

func NewClient

func NewClient(siteClients map[string]MagnetSearcher, timeout time.Duration, logger *zap.Logger) *Client

func (*Client) FindMagnets

func (c *Client) FindMagnets(ctx context.Context, imdbID string) ([]Result, error)

FindMagnets tries to find magnet URLs for the given IMDb ID. It only returns 720p, 1080p, 1080p 10bit, 2160p and 2160p 10bit videos. It caches results once they're found. It can return an empty slice and no error if no actual error occurred (for example if torrents where found but no >=720p videos).

func (*Client) GetMagnetSearchers

func (c *Client) GetMagnetSearchers() map[string]MagnetSearcher

type IbitClientOptions

type IbitClientOptions struct {
	BaseURL  string
	Timeout  time.Duration
	CacheAge time.Duration
}

func NewIbitClientOpts

func NewIbitClientOpts(baseURL string, timeout, cacheAge time.Duration) IbitClientOptions

type InMemoryCache

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 imdb2torrent package.

func NewInMemoryCache

func NewInMemoryCache() *InMemoryCache

NewInMemoryCache creates a new InMemoryCache.

func (*InMemoryCache) Get

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

Get returns Result objects and the time they were cached from the cache. The boolean return value signals if the value was found in the cache.

func (*InMemoryCache) Set

func (c *InMemoryCache) Set(key string, results []Result) error

Set stores Result objects and the current time in the cache.

type LeetxClientOptions

type LeetxClientOptions struct {
	BaseURL  string
	Timeout  time.Duration
	CacheAge time.Duration
}

func NewLeetxClientOpts

func NewLeetxClientOpts(baseURL string, timeout, cacheAge time.Duration) LeetxClientOptions

type MagnetSearcher

type MagnetSearcher interface {
	Find(ctx context.Context, imdbID string) ([]Result, error)
	IsSlow() bool
}

type Result

type Result struct {
	// Movie title, e.g. "Big Buck Bunny"
	Title string
	// Video resolution and source, e.g. "720p" or "720p (web)"
	Quality string
	// Torrent info_hash
	InfoHash string
	// MagnetURL, usually containing the info_hash, torrent name and a list of torrent trackers
	MagnetURL string
}

type TPBclientOptions

type TPBclientOptions struct {
	BaseURL        string
	SocksProxyAddr string
	Timeout        time.Duration
	CacheAge       time.Duration
}

func NewTPBclientOpts

func NewTPBclientOpts(baseURL, socksProxyAddr string, timeout, cacheAge time.Duration) TPBclientOptions

type YTSclientOptions

type YTSclientOptions struct {
	BaseURL  string
	Timeout  time.Duration
	CacheAge time.Duration
}

func NewYTSclientOpts

func NewYTSclientOpts(baseURL string, timeout, cacheAge time.Duration) YTSclientOptions

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier