Documentation
¶
Overview ¶
Package radio plays internet radio stations: streams that go on for as long as anyone listens, from Icecast, SHOUTcast and the like. People add a station by its stream's address, or find one in Radio Browser (radio-browser.info), an open directory of stations. The server passes the stream through to players, and reads the song titles stations send along with it (see icy.go).
Index ¶
Constants ¶
const UserAgent = "Matinee/1.0 (+https://matinee.yeix.io)"
UserAgent is sent to stations, which count listeners by it.
Variables ¶
var ( // ErrBadURL means the address isn't an http or https one. ErrBadURL = errors.New("that isn't a web address") // ErrNotAudio means the address answered with something that isn't a // stream, such as a web page. ErrNotAudio = errors.New("that address isn't a radio stream") // ErrHLS means the station streams in pieces (HLS), which Matinee // can't relay yet. ErrHLS = errors.New("that station streams as HLS, which isn't supported yet. Look for its MP3 or AAC stream") )
var DirectoryBase = "https://all.api.radio-browser.info"
DirectoryBase is Radio Browser's API. The docs' screenshot server points it at a stand-in at build time.
Functions ¶
func Relay ¶
func Relay(w http.ResponseWriter, r *http.Request, client *http.Client, addr string, onTitle func(string))
Relay plays a station to a player: it passes the stream through, takes the song titles out of it for onTitle, and ends when the player leaves.
func StreamTitle ¶
StreamTitle reads the title out of a block such as StreamTitle='Above & Beyond - Sun & Moon';StreamUrl=”;
Types ¶
type Found ¶
type Found struct {
Name string `json:"name"`
URL string `json:"url"`
Homepage string `json:"homepage,omitempty"`
Image string `json:"image,omitempty"`
Tags []string `json:"tags,omitempty"`
Country string `json:"country,omitempty"` // two letters, such as GB
Codec string `json:"codec,omitempty"` // such as MP3 or AAC
Bitrate int `json:"bitrate,omitempty"` // kbit/s
// The station in the library asked about, when it's added already.
ItemID int64 `json:"itemId,omitempty"`
}
Found is a station in the directory.
type Info ¶
type Info struct {
URL string // the stream, after following a playlist file
Name string // icy-name, if it sends one
Homepage string // icy-url
Genre string // icy-genre
ContentType string
}
Info is what a station says about itself when asked for its stream.
type StatusError ¶
type StatusError struct{ Status string }
StatusError is a station answering with something other than its stream.
func (*StatusError) Error ¶
func (e *StatusError) Error() string