turbowookie

package
v0.0.0-...-31c7ed3 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2016 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDB

func InitDB() *gorp.DbMap

func ReadConfig

func ReadConfig(filename string) (map[string]string, error)

ReadConfig reads a configuration yaml file and spits out a map of the keys we care about.

func WatchMPD

func WatchMPD(host string, handler *Handler)

WatchMPD starts up an MPD watcher, and does performs tasks when certain things happen. The biggest task is in telling the client things have changed using a long-poll system.

Types

type Handler

type Handler struct {
	// MpdClient is our MPD Client, used to tell MPD to do things. Important
	// things.
	MpdClient *MPDClient

	// ServerConfig is a map of configuration key/values found in
	// a config.yaml file.
	ServerConfig map[string]string

	// Router is a mux.Router, it's what really does all the HTTP stuff, we just
	// act as the interface. And the HandlerFuncs
	Router *mux.Router
	// contains filtered or unexported fields
}

Handler is our custom http.Handler used to actually do the HTTP stuff.

func NewHandler

func NewHandler(filename string, serveDart, startMPD bool, portOverride int) (*Handler, error)

NewHandler creates a new Handler, using the passed in filename as a yaml file containing the server's configuation settings.

func (*Handler) HandleFunc

func (h *Handler) HandleFunc(path string, f func(w http.ResponseWriter, r *http.Request)) *mux.Route

HandleFunc make Handler extendible... Same as ServeHTTP, just pass up the Router's function.

func (*Handler) ListenAndServe

func (h *Handler) ListenAndServe() error

ListenAndServe serve up some TurboWookie. And setup an MPD Watcher to see when things happen to the stream. Because things sometimes happen to the stream.

func (*Handler) PolarChanged

func (h *Handler) PolarChanged(element string)

PolarChanged tell clients connected to our long-poll system that something (element) has changed.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Make Handler an HTTP.Handler. Hackily. Just pass up the underlying Router's function.

type MPDClient

type MPDClient struct {
	// Domain MPD's running on
	Domain string

	// Port MPD's running on
	Port string

	// Underlying command running MPD
	MpdCmd *exec.Cmd
	// contains filtered or unexported fields
}

MPDClient is a simpler layer over a gompd/mpd.Client.

func NewMPDClient

func NewMPDClient(config map[string]string, noStartMPD bool) *MPDClient

NewMPDClient creates a new MPDClient. Takes in a config map (typically retreived from a config.yaml file), and a noStartMPD bool (which, if true will NOT start MPD . If it's false (and it should default to false), it will start MPD as expected).

func (*MPDClient) Add

func (c *MPDClient) Add(uri string) error

Add adds the specified uri to the playlist. uri can be a directory or file. uri must be relative to MPD's music directory.

func (*MPDClient) CurrentSong

func (c *MPDClient) CurrentSong() (map[string]string, error)

CurrentSong returns information about the song currently playing.

func (*MPDClient) GetAlbums

func (c *MPDClient) GetAlbums(artist string) (map[string][]string, error)

func (*MPDClient) GetArtists

func (c *MPDClient) GetArtists() ([]string, error)

func (*MPDClient) GetFiles

func (c *MPDClient) GetFiles() ([]map[string]string, error)

GetFiles returns a map of all songs in the library, and their stored metadata (artist, album, etc).

func (*MPDClient) GetPlaylist

func (c *MPDClient) GetPlaylist() ([]map[string]string, error)

GetPlaylist returns the entire playlist queue, played and unplayed.

func (*MPDClient) GetSongs

func (c *MPDClient) GetSongs(artist string, album string) ([]map[string]string, error)

func (*MPDClient) GetUpcoming

func (c *MPDClient) GetUpcoming() ([]map[string]string, error)

GetUpcoming returns a list of all upcoming songs in the queue, and their metadata.

func (*MPDClient) KillMpd

func (c *MPDClient) KillMpd()

KillMpd kills the underlying MPD process.

func (*MPDClient) QueueSong

func (c *MPDClient) QueueSong()

func (*MPDClient) ScanLibrary

func (c *MPDClient) ScanLibrary()

func (*MPDClient) Search

func (c *MPDClient) Search(query string) ([]map[string]string, error)

func (*MPDClient) SearchAlbums

func (c *MPDClient) SearchAlbums(query string) []string

func (*MPDClient) SearchArtists

func (c *MPDClient) SearchArtists(query string) []string

func (*MPDClient) SearchSongs

func (c *MPDClient) SearchSongs(query string) []map[string]string

func (*MPDClient) Startup

func (c *MPDClient) Startup() error

Startup routine. Makes sure we can connect to MPD and that there's something playing.

type Song

type Song struct {
	Id        int64
	Artist    string
	Album     string
	Title     string
	Uri       string
	PlayCount int64
	SkipCount int64
}

func (Song) ToMap

func (song Song) ToMap() map[string]string

Jump to

Keyboard shortcuts

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