sources

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package sources contains the extractors for gLyrics.

Index

Constants

This section is empty.

Variables

View Source
var (
	// AnimeLyricsOrigin is the lyrics origin for Animelyrics
	AnimeLyricsOrigin = lyrics.Origin{Name: "Animelyrics", Website: "animelyrics.com"}

	// AnimeLyricsExtractor is an extractor for Animelyrics
	AnimeLyricsExtractor = ExtractorFunc(extractAnimeLyricsLyrics)
)
View Source
var (
	// AZLyricsOrigin is the lyrics origin for AZLyrics.
	AZLyricsOrigin = lyrics.Origin{Name: "AZLyrics", Website: "azlyrics.com"}

	// AZLyricsExtractor is an extractor for AZLyrics
	AZLyricsExtractor = ExtractorFunc(extractAZLyricsLyrics)
)
View Source
var (
	// GeniusOrigin is the Origin for Genius.
	GeniusOrigin = lyrics.Origin{Name: "Genius", Website: "genius.com"}

	// GeniusExtractor is an extractor for Genius
	GeniusExtractor = ExtractorFunc(extractGeniusLyrics)
)
View Source
var (
	// LyricalNonsenseOrigin is the lyrics origin for Lyrical Nonsense.
	LyricalNonsenseOrigin = lyrics.Origin{Name: "Lyrical Nonsense", Website: "lyrical-nonsense.com"}

	// LyricalNonsenseExtractor is an extractor for Lyrical Nonsense
	LyricalNonsenseExtractor = ExtractorFunc(extractLyricalNonsenseLyrics)
)
View Source
var (
	// LyricsModeOrigin is the glyrics.Origin for LyricsMode.
	LyricsModeOrigin = lyrics.Origin{Name: "LyricsMode", Website: "lyricsmode.com"}

	// LyricsModeExtractor is an extractor for LyricsMode
	LyricsModeExtractor = ExtractorFunc(extractLyricsModeLyrics)
)
View Source
var (
	// MusixMatchOrigin is the lyrics origin for MusixMatch.
	MusixMatchOrigin = lyrics.Origin{Name: "MusixMatch", Website: "musixmatch.com"}

	// MusixMatchExtractor is an extractor for MusixMatch
	MusixMatchExtractor = ExtractorFunc(extractMusixMatchLyrics)
)

Functions

func RegisterExtractor

func RegisterExtractor(e MaybeExtractor)

RegisterExtractor adds a new Extractor to the registered sources. Registered extractors are returned by GetExtractorsForRequest.

Types

type CanExtractTeller

type CanExtractTeller interface {
	// CanExtract performs simple checks to determine whether the extractor
	// has any chance of extracting lyrics from the Request.
	CanExtract(req *request.Request) bool
}

CanExtractTeller can tell whether lyrics can be extracted from the given request.

func RegexExtractorTeller

func RegexExtractorTeller(re *regexp.Regexp) CanExtractTeller

RegexExtractorTeller wraps the regular expression in a struct that implements CanExtractTeller.

type Extractor

type Extractor interface {
	// ExtractLyrics performs the actual extraction.
	ExtractLyrics(req *request.Request) (*lyrics.Info, error)
}

Extractor extracts lyrics from a Request.

func GetExtractorsForRequest

func GetExtractorsForRequest(req *request.Request) []Extractor

GetExtractorsForRequest returns a slice of all extractor which can extract lyrics from the given request.

type ExtractorFunc

type ExtractorFunc func(req *request.Request) (*lyrics.Info, error)

ExtractorFunc is a function which implements the Extractor interface.

func (ExtractorFunc) ExtractLyrics

func (e ExtractorFunc) ExtractLyrics(req *request.Request) (*lyrics.Info, error)

ExtractLyrics implements Extractor for extractor functions. It acts as an alias for the function itself.

type MaybeExtractor

type MaybeExtractor interface {
	CanExtractTeller
	Extractor
}

MaybeExtractor combines Extractor with CanExtractTeller.

func CreateMaybeExtractor

func CreateMaybeExtractor(teller CanExtractTeller, extractor Extractor) MaybeExtractor

CreateMaybeExtractor combines a CanExtractTeller and an Extractor to a MaybeExtractor.

Jump to

Keyboard shortcuts

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