providers

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrString added in v0.16.0

func ErrString(err error) interface{}

func ExpandPath added in v0.16.0

func ExpandPath(p string) (string, error)

ExpandPath variables contained in the path

  • ENV variables like $HOME
  • ~ for home dir

func List

func List() map[string]Provider

List of registered providers

func Register

func Register(p Provider)

Register is called by provider's init to register the provider

Types

type FeedBacker added in v0.16.0

type FeedBacker interface {
	Stage(stage string) // Indicate current stage
	Total(total int)    // Indicate the total number (could be bytes, percent )
	Update(current int) // Indicate the current position
	Done()              // Call when the task is done
}

type HTTPClient added in v0.16.0

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

func NewHTTPClient added in v0.16.0

func NewHTTPClient(c ProviderConfig) *HTTPClient

func (*HTTPClient) Get added in v0.16.0

func (c *HTTPClient) Get(ctx context.Context, url string, q *url.Values, body io.Reader) ([]byte, error)

func (*HTTPClient) Head added in v0.16.0

func (c *HTTPClient) Head(ctx context.Context, url string, q *url.Values, body io.Reader) ([]byte, error)

func (*HTTPClient) Post added in v0.16.0

func (c *HTTPClient) Post(ctx context.Context, url string, q *url.Values, body io.Reader) ([]byte, error)

type Provider

type Provider interface {
	Configure(fns ...ProviderConfigFn)                                    // Pass general configuration
	Name() string                                                         // Provider's name
	MediaList(context.Context, []*matcher.MatchRequest) chan *media.Media // List of available shows that match one of MatchRequest
	GetMediaDetails(context.Context, *media.Media) error                  // Download more details when available
}

Provider is the interface for a provider

type ProviderConfig added in v0.16.0

type ProviderConfig struct {
	Log         *mylog.MyLog  // Logger
	HitsLimiter *rate.Limiter // Limit the number of hits per second
	// TODO ByteLimiter *rate.Limiter // Limit the number of bytes per second
	UserAgent string // User agent to use for queries
}

Config carries the configuration to providers

type ProviderConfigFn added in v0.16.0

type ProviderConfigFn func(c ProviderConfig) ProviderConfig

func ProviderHitsPerSecond added in v0.16.0

func ProviderHitsPerSecond(limiter *rate.Limiter) ProviderConfigFn

func ProviderLog added in v0.16.0

func ProviderLog(l *mylog.MyLog) ProviderConfigFn

func ProviderUserAgent added in v0.16.0

func ProviderUserAgent(agent string) ProviderConfigFn

type ProviderSettings added in v0.16.0

type ProviderSettings struct {
	Enabled  bool
	HitsRate int // Number of get per second
	Settings map[string]string
}

type Runner added in v0.16.0

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

Runner handle downloads for a provider

func NewRunner added in v0.16.0

func NewRunner(ctx context.Context, s *Settings, p Provider, fns ...RunnerConfigFn) *Runner

NewRunner return a configured runner for the provider

func (*Runner) GetNewMediasList added in v0.16.0

func (r *Runner) GetNewMediasList(ctx context.Context, mr []*matcher.MatchRequest) <-chan *media.Media

GetNewMediasList pull the providers for medias available on its web site, check if it isn't already downloaded before sent it back to the channel

func (*Runner) SubmitDownload added in v0.16.0

func (r *Runner) SubmitDownload(ctx context.Context, m *media.Media, fb FeedBacker, onDone func())

func (*Runner) WaitUntilCompletion added in v0.16.0

func (r *Runner) WaitUntilCompletion(ctx context.Context)

type RunnerConfig added in v0.16.0

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

type RunnerConfigFn added in v0.16.0

type RunnerConfigFn func(c RunnerConfig) RunnerConfig

func RunnerWithConcurentLimit added in v0.16.0

func RunnerWithConcurentLimit(limit int) RunnerConfigFn

func RunnerWithLogger added in v0.16.0

func RunnerWithLogger(log *mylog.MyLog) RunnerConfigFn

type Settings added in v0.16.0

type Settings struct {
	Providers    map[string]ProviderSettings // Registered providers
	Destinations map[string]string           // Mapping of destination path
	WatchList    []*matcher.MatchRequest     // Slice of show matchers

}

Settings hold application global settings

func (*Settings) CheckPath added in v0.16.0

func (s *Settings) CheckPath() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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