extractor

package
v0.0.0-...-9174c1b Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSearchResults      = errors.New("no search results")
	ErrNoSearchProvider     = errors.New("no search provider available")
	ErrNoSuggestionProvider = errors.New("no search suggestion provider available")
)

Functions

func AddExtractor

func AddExtractor(name string, e Extractor)

func AddSearcher

func AddSearcher(name string, s Searcher)

func AddSuggestor

func AddSuggestor(name string, s Suggestor)

func Suggest

func Suggest(cfg Config, input string) ([]string, error)

Types

type Config

type Config map[string]ProviderConfig

func DefaultConfig

func DefaultConfig() Config

func (Config) CheckValidity

func (cfg Config) CheckValidity() error

type ConfigTypeError

type ConfigTypeError struct {
	Provider string
	Key      string
	Expected reflect.Type
	Got      reflect.Type
}

func (*ConfigTypeError) Error

func (e *ConfigTypeError) Error() string

type Data

type Data struct {
	// Each instance of this struct should be reconstructable by calling
	// Extract() on the SourceUrl
	// String values are "" if not present
	SourceUrl      string
	StreamUrl      string // may expire, see Expires
	Title          string
	PlaylistUrl    string
	PlaylistTitle  string
	Description    string
	Uploader       string
	Duration       int       // in seconds; -1 if unknown
	Expires        time.Time // when StreamUrl expires
	OfficialArtist bool      // only for sites that have non-music (e.g. YouTube); search results only
}

func Extract

func Extract(cfg Config, input string) ([]Data, error)
func Search(cfg Config, input string) ([]Data, error)

type Error

type Error struct {
	ProviderName string
	Err          error
}

func (*Error) Error

func (e *Error) Error() string

type Extractor

type Extractor interface {
	Provider
	Matches(cfg ProviderConfig, input string) bool
	Extract(cfg ProviderConfig, input string) ([]Data, error)
}

type Provider

type Provider interface {
	DefaultConfig() ProviderConfig
}

type ProviderConfig

type ProviderConfig map[string]any

type Searcher

type Searcher interface {
	Provider
	Search(cfg ProviderConfig, input string) ([]Data, error)
}

type Suggestor

type Suggestor interface {
	Provider
	Suggest(cfg ProviderConfig, input string) ([]string, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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