services

package
v0.0.0-...-d2e9830 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when search query return 0 results
	ErrNotFound = errors.New("Found nothing for given query")
	// ErrAPI is returned when API error occurs
	ErrAPI = errors.New("API error occured")
)
View Source
var DJ *bot.MumbleDJ

DJ is an injected MumbleDJ struct.

View Source
var Services []interfaces.Service

Services is a slice of enabled MumbleDJ services.

Functions

This section is empty.

Types

type GenericService

type GenericService struct {
	ReadableName  string
	Format        string
	TrackRegex    []*regexp.Regexp
	PlaylistRegex []*regexp.Regexp
}

GenericService is a generic struct that should be embedded in other service structs, as it provides useful helper methods and properties.

func (*GenericService) CheckURL

func (gs *GenericService) CheckURL(url string) bool

CheckURL matches the passed URL with a list of regex patterns for valid URLs associated with this service. Returns true if a match is found, false otherwise.

func (*GenericService) GetFormat

func (gs *GenericService) GetFormat() string

GetFormat returns the youtube-dl format for the service.

func (*GenericService) GetReadableName

func (gs *GenericService) GetReadableName() string

GetReadableName returns the readable name for the service.

func (*GenericService) SearchTrack

func (gs *GenericService) SearchTrack(string, *gumble.User) (interfaces.Track, error)

SearchTrack default implementation informing about not implemented feature

type Mixcloud

type Mixcloud struct {
	*GenericService
}

Mixcloud is a wrapper around the Mixcloud API. https://www.mixcloud.com/developers/

func NewMixcloudService

func NewMixcloudService() *Mixcloud

NewMixcloudService returns an initialized Mixcloud service object.

func (*Mixcloud) CheckAPIKey

func (mc *Mixcloud) CheckAPIKey() error

CheckAPIKey performs a test API call with the API key provided in the configuration file to determine if the service should be enabled.

func (*Mixcloud) GetTracks

func (mc *Mixcloud) GetTracks(url string, submitter *gumble.User) ([]interfaces.Track, error)

GetTracks uses the passed URL to find and return tracks associated with the URL. An error is returned if any error occurs during the API call.

type SoundCloud

type SoundCloud struct {
	*GenericService
}

SoundCloud is a wrapper around the SoundCloud API. https://developers.soundcloud.com/docs/api/reference

func NewSoundCloudService

func NewSoundCloudService() *SoundCloud

NewSoundCloudService returns an initialized SoundCloud service object.

func (*SoundCloud) CheckAPIKey

func (sc *SoundCloud) CheckAPIKey() error

CheckAPIKey performs a test API call with the API key provided in the configuration file to determine if the service should be enabled.

func (*SoundCloud) GetTracks

func (sc *SoundCloud) GetTracks(url string, submitter *gumble.User) ([]interfaces.Track, error)

GetTracks uses the passed URL to find and return tracks associated with the URL. An error is returned if any error occurs during the API call.

type YouTube

type YouTube struct {
	*GenericService
	// contains filtered or unexported fields
}

YouTube is a wrapper around the YouTube Data API. https://developers.google.com/youtube/v3/docs/

func NewYouTubeService

func NewYouTubeService() *YouTube

NewYouTubeService returns an initialized YouTube service object.

func (*YouTube) CheckAPIKey

func (yt *YouTube) CheckAPIKey() error

CheckAPIKey performs a test API call with the API key provided in the configuration file to determine if the service should be enabled.

func (*YouTube) GetTracks

func (yt *YouTube) GetTracks(url string, submitter *gumble.User) ([]interfaces.Track, error)

GetTracks uses the passed URL to find and return tracks associated with the URL. An error is returned if any error occurs during the API call.

func (*YouTube) SearchTrack

func (yt *YouTube) SearchTrack(query string, submitter *gumble.User) (interfaces.Track, error)

SearchTrack uses YouTube Data API v3 to find results for given query and takes first video from results list and returns it. If nothing has been found or API call error occurred it should return empty bot.Track and error. `bot.Track, nil` otherwise.

Jump to

Keyboard shortcuts

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