Documentation
¶
Overview ¶
Package radio provides a client for the RadioBrowser API.
Index ¶
- func NormalizeStreamURL(streamURL string) string
- type Catalog
- func (c *Catalog) ByCountry(country string, limit int) ([]StationView, error)
- func (c *Catalog) ByTag(tag string, limit int) ([]StationView, error)
- func (c *Catalog) LookupStation(stationUUID string) (StationView, error)
- func (c *Catalog) ProjectStations(stations []Station) []StationView
- func (c *Catalog) Search(query string, limit int) ([]StationView, error)
- func (c *Catalog) SearchFiltered(country, codec, tag string, limit int) ([]StationView, error)
- func (c *Catalog) SomaFM() ([]StationView, error)
- func (c *Catalog) TopClicked(limit int) ([]StationView, error)
- func (c *Catalog) TopVoted(limit int) ([]StationView, error)
- type CatalogConfig
- type Client
- func (c *Client) ByCountry(country string, limit int) ([]Station, error)
- func (c *Client) ByTag(tag string, limit int) ([]Station, error)
- func (c *Client) ByUUID(stationUUID string) ([]Station, error)
- func (c *Client) Search(query string, limit int) ([]Station, error)
- func (c *Client) SearchFiltered(country, codec, tag string, limit int) ([]Station, error)
- func (c *Client) SetServers(servers []string)
- func (c *Client) TopClicked(limit int) ([]Station, error)
- func (c *Client) TopVoted(limit int) ([]Station, error)
- type SavedStationStore
- type SomaFMClient
- type Station
- type StationDirectory
- type StationView
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeStreamURL ¶ added in v1.1.0
NormalizeStreamURL applies known station stream URL migrations.
Types ¶
type Catalog ¶ added in v1.1.0
type Catalog struct {
// contains filtered or unexported fields
}
Catalog coordinates live radio lookup, saved station fallback, and station projection.
func NewCatalog ¶ added in v1.1.0
func NewCatalog(config CatalogConfig) *Catalog
NewCatalog creates a radio catalog from configured station sources.
func (*Catalog) ByCountry ¶ added in v1.1.0
func (c *Catalog) ByCountry(country string, limit int) ([]StationView, error)
ByCountry returns projected stations for a country.
func (*Catalog) ByTag ¶ added in v1.1.0
func (c *Catalog) ByTag(tag string, limit int) ([]StationView, error)
ByTag returns projected stations for a tag.
func (*Catalog) LookupStation ¶ added in v1.1.0
func (c *Catalog) LookupStation(stationUUID string) (StationView, error)
LookupStation returns full station metadata by UUID. Live metadata wins over saved snapshots.
func (*Catalog) ProjectStations ¶ added in v1.1.0
func (c *Catalog) ProjectStations(stations []Station) []StationView
ProjectStations normalizes live station metadata for frontend use.
func (*Catalog) Search ¶ added in v1.1.0
func (c *Catalog) Search(query string, limit int) ([]StationView, error)
Search returns projected stations matching a name query.
func (*Catalog) SearchFiltered ¶ added in v1.1.0
func (c *Catalog) SearchFiltered(country, codec, tag string, limit int) ([]StationView, error)
SearchFiltered returns projected stations matching optional filters.
func (*Catalog) SomaFM ¶ added in v1.1.0
func (c *Catalog) SomaFM() ([]StationView, error)
SomaFM returns projected SomaFM stations.
func (*Catalog) TopClicked ¶ added in v1.1.0
func (c *Catalog) TopClicked(limit int) ([]StationView, error)
TopClicked returns projected top-clicked stations.
type CatalogConfig ¶ added in v1.1.0
type CatalogConfig struct {
Directory StationDirectory
SomaFMStations func() ([]Station, error)
SavedStations SavedStationStore
ResolveArtwork func(favicon, homepage string) string
}
CatalogConfig wires a radio catalog to live and persisted station sources.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a RadioBrowser API client with DNS-based mirror discovery.
func (*Client) SearchFiltered ¶
SearchFiltered searches for stations with optional country, codec, and tag filters.
func (*Client) SetServers ¶
SetServers pins API mirrors (for tests).
func (*Client) TopClicked ¶
TopClicked returns the most clicked stations.
type SavedStationStore ¶ added in v1.1.0
type SavedStationStore interface {
GetCustomRadioStations() ([]library.RadioCustomStation, error)
GetRadioFavourites() ([]library.RadioFavourite, error)
GetRadioHistory(limit int) ([]library.RadioHistoryEntry, error)
}
SavedStationStore is the persisted station subset needed by Catalog.
type SomaFMClient ¶
type SomaFMClient struct {
// contains filtered or unexported fields
}
SomaFMClient fetches and caches SomaFM channel data. It provides artwork fallback for RadioBrowser stations and a curated channel listing for source filtering.
func NewSomaFMClient ¶
func NewSomaFMClient() *SomaFMClient
NewSomaFMClient creates a new SomaFM client.
func (*SomaFMClient) LookupArtwork ¶
func (s *SomaFMClient) LookupArtwork(homepage string) string
LookupArtwork returns the artwork URL for a SomaFM station identified by its homepage URL. Returns empty string if not applicable.
func (*SomaFMClient) Stations ¶
func (s *SomaFMClient) Stations() ([]Station, error)
Stations returns all SomaFM channels as Station values.
type Station ¶
type Station struct {
UUID string `json:"stationuuid"`
Name string `json:"name"`
Homepage string `json:"homepage"`
StreamURL string `json:"url_resolved"`
Favicon string `json:"favicon"`
Country string `json:"country"`
Tags string `json:"tags"`
Bitrate int `json:"bitrate"`
Codec string `json:"codec"`
Votes int `json:"votes"`
Clicks int `json:"clickcount"`
}
Station represents a radio station from RadioBrowser.
type StationDirectory ¶ added in v1.1.0
type StationDirectory interface {
Search(query string, limit int) ([]Station, error)
SearchFiltered(country, codec, tag string, limit int) ([]Station, error)
ByTag(tag string, limit int) ([]Station, error)
ByCountry(country string, limit int) ([]Station, error)
TopVoted(limit int) ([]Station, error)
TopClicked(limit int) ([]Station, error)
ByUUID(stationUUID string) ([]Station, error)
}
StationDirectory is the live station lookup interface backed by RadioBrowser.
type StationView ¶ added in v1.1.0
type StationView struct {
UUID string `json:"uuid"`
Name string `json:"name"`
StreamURL string `json:"streamUrl"`
Homepage string `json:"homepage"`
Favicon string `json:"favicon"`
Country string `json:"country"`
Tags string `json:"tags"`
Bitrate int `json:"bitrate"`
Codec string `json:"codec"`
Votes int `json:"votes"`
Clicks int `json:"clicks"`
}
StationView is the JSON-friendly station projection exposed to the frontend.