Documentation ¶
Index ¶
- Constants
- Variables
- func WithCore(ctx context.Context, core *Core) context.Context
- type AudioSourceResp
- type Core
- func (c *Core) AddServices(services ...service.Identifier)
- func (c *Core) Close() error
- func (c *Core) GetTrack(eid string) (edb.Track, error)
- func (c *Core) GetTrackLyrics(ctx context.Context, eid string) (edb.Lyrics, error)
- func (c *Core) GetTrackSource(ctx context.Context, eid string) (AudioSourceResp, error)
- func (c *Core) ResolveURI(ctx context.Context, uri string) (interface{}, error)
- type Handler
- type ResolveResp
Constants ¶
const (
// TrackType is the type name of track response.
TrackType = "track"
)
Variables ¶
var ( ErrEIDNotFound = errors.New("eid was not found") ErrNoExtractorForURI = errors.New("no extractor for uri found") )
var (
ErrLyricsNotFound = errors.New("lyrics not found")
)
Functions ¶
Types ¶
type AudioSourceResp ¶
type AudioSourceResp struct { Source string `json:"source"` Identifier string `json:"identifier"` URI string `json:"uri"` StartOffset float64 `json:"start_offset"` EndOffset float64 `json:"end_offset"` IsLive bool `json:"is_live"` }
AudioSourceResp represents an audio source response.
func AudioSourceRespFromTrackSource ¶
func AudioSourceRespFromTrackSource(trackSource edb.TrackSource, uri string) AudioSourceResp
AudioSourceRespFromTrackSource builds an AudioSourceResp from a edb.TrackSource. The track source is expected to have the audio source loaded.
type Core ¶
type Core struct { DB *gorm.DB LyricsSearcher search.Searcher ExtractorPool *infoextract.ExtractorPool TrackSourceFinder *audiosrc.Finder }
Core contains important data shared between the handlers.
func CoreFromContext ¶
CoreFromContext extracts the Core from a context.
func (*Core) AddServices ¶
func (c *Core) AddServices(services ...service.Identifier)
AddServices uses the given services to create the extractor pool and track source finder. It will panic if either of them is already set, no database is set, or an invalid service type is passed.
func (*Core) GetTrackLyrics ¶
GetTrackLyrics retrieves lyrics for the track with the given EID. The context must contain the api core.
func (*Core) GetTrackSource ¶
type Handler ¶
type Handler interface { // Start starts the handler. The handler should start responding to // requests after being started. Start() error // Stop closes the handler. The handler should no longer respond to // requests after being closed. Stop() error // Done returns a channel which is closed when the handler is done. Done() <-chan struct{} }
Handler defines the interface for an API request handler.
func CollectHandlers ¶
CollectHandlers creates a new handler from the given handlers.
type ResolveResp ¶
ResolveResp represents the response given to resolve requests.
func CreateResolveResponse ¶
func CreateResolveResponse(v interface{}) (resp ResolveResp, err error)
CreateResolveResponse returns a SimpleResolveResp instance for the given value.