infoextract

package
v0.0.0-...-c928bda Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package infoextract provides the interface to extract information from various sources.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrURIInvalid = errors.New("uri invalid")
)

Functions

func GetGenresByName

func GetGenresByName(db *gorm.DB, names ...string) ([]edb.Genre, error)

GetGenresByName returns genres for the given names and creates new ones for those not found.

func GetImage

func GetImage(db *gorm.DB, uri string) (edb.Image, error)

GetImage searches for an image with the given source uri or creates a new one.

Types

type Extractor

type Extractor interface {
	service.Identifier

	Extract(ctx context.Context, uri string) (interface{}, error)
}

type ExtractorPool

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

An ExtractorPool collects extractors.

func CollectExtractors

func CollectExtractors(extractors ...Extractor) *ExtractorPool

Create a new extractor pool from the given extractors. Passing a nil extractor will cause a panic.

func (*ExtractorPool) GetExtractor

func (p *ExtractorPool) GetExtractor(extractorID string) (Extractor, bool)

GetExtractor returns the extractor with the given extractor id.

func (*ExtractorPool) ResolveExtractor

func (p *ExtractorPool) ResolveExtractor(uri string) (Extractor, bool)

ResolveExtractor finds an extractor for the given uri. To be discovered, an extractor has to register using AddCheckers.

type HasHostnames

type HasHostnames interface {
	Extractor
	// URLHostnames returns a slice of hostnames.
	// The hostnames shouldn't include "www.".
	URLHostnames() []string
}

HasHostnames is an interface for an Extractor which extracts for specific hostnames.

type URIChecker

type URIChecker interface {
	Extractor

	// CheckURI checks whether the extractor works for the given uri.
	CheckURI(uri string) bool
}

A URIChecker is an Extractor which extracts URIs.

type URLChecker

type URLChecker interface {
	Extractor

	// CheckURL checks whether the extractor works for the given url.
	CheckURL(u *url.URL) bool
}

A URLChecker is an Extractor which extracts from URLs.

Jump to

Keyboard shortcuts

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