Documentation
¶
Overview ¶
catalog.go provides a client for the Radio Browser API (radio-browser.info), a free community-maintained directory of internet radio stations.
Package radio implements a playlist.Provider for internet radio stations. It includes a built-in cliamp radio stream, user-defined stations from ~/.config/cliamp/radios.toml, favorites from radio_favorites.toml, and lazy-loaded catalog stations from the Radio Browser API.
Index ¶
- func IsCatalogOrFavID(id string) bool
- type CatalogStation
- type Favorites
- type Provider
- func (p *Provider) AppendCatalog(stations []CatalogStation)
- func (p *Provider) ClearSearch()
- func (p *Provider) IDPrefix(id string) string
- func (p *Provider) IsFavoritableID(id string) bool
- func (p *Provider) IsSearching() bool
- func (p *Provider) LoadCatalogPage(offset, limit int) (int, error)
- func (p *Provider) Name() string
- func (p *Provider) Playlists() ([]playlist.PlaylistInfo, error)
- func (p *Provider) SearchCatalog(query string) (int, error)
- func (p *Provider) SetSearchResults(stations []CatalogStation)
- func (p *Provider) ToggleFavorite(id string) (added bool, name string, err error)
- func (p *Provider) Tracks(id string) ([]playlist.Track, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCatalogOrFavID ¶
IsCatalogOrFavID returns true if the ID belongs to a catalog, search, or favorite entry.
Types ¶
type CatalogStation ¶
type CatalogStation struct {
Name string `json:"name"`
URL string `json:"url_resolved"`
Country string `json:"country"`
Tags string `json:"tags"`
Codec string `json:"codec"`
Bitrate int `json:"bitrate"`
Votes int `json:"votes"`
Homepage string `json:"homepage"`
}
CatalogStation represents a station from the Radio Browser API.
func SearchStations ¶
func SearchStations(query string, limit int) ([]CatalogStation, error)
SearchStations searches the Radio Browser API by station name.
func TopStationsOffset ¶
func TopStationsOffset(offset, limit int) ([]CatalogStation, error)
TopStationsOffset returns a page of the most-voted stations starting at offset.
type Favorites ¶
type Favorites struct {
// contains filtered or unexported fields
}
Favorites manages a persistent set of favorite radio stations.
func LoadFavorites ¶
func LoadFavorites() *Favorites
LoadFavorites reads favorites from ~/.config/cliamp/radio_favorites.toml.
func (*Favorites) Add ¶
func (f *Favorites) Add(s CatalogStation) error
Add adds a station to favorites and saves to disk.
func (*Favorites) Stations ¶
func (f *Favorites) Stations() []CatalogStation
Stations returns all favorite stations.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider serves radio stations as single-track playlists. It combines local stations, user favorites, and catalog stations from the Radio Browser API into a single unified list.
func New ¶
func New() *Provider
New creates a Provider with the built-in station plus any user-defined stations from ~/.config/cliamp/radios.toml and favorites.
func (*Provider) AppendCatalog ¶
func (p *Provider) AppendCatalog(stations []CatalogStation)
AppendCatalog adds catalog stations fetched from the Radio Browser API.
func (*Provider) ClearSearch ¶
func (p *Provider) ClearSearch()
ClearSearch deactivates search mode, restoring the catalog view.
func (*Provider) IDPrefix ¶
IDPrefix returns the type prefix of a provider list ID ("l", "f", "c", or ""). Also implements provider.SectionedList when called as a method.
func (*Provider) IsFavoritableID ¶
IsFavoritableID reports whether the given ID can be favorited. Implements provider.SectionedList.
func (*Provider) IsSearching ¶
IsSearching returns true if API search results are active.
func (*Provider) LoadCatalogPage ¶
LoadCatalogPage fetches the next page of catalog entries from the Radio Browser API and appends them to the provider's catalog. Implements provider.CatalogLoader.
func (*Provider) Playlists ¶
func (p *Provider) Playlists() ([]playlist.PlaylistInfo, error)
Playlists returns a unified list: local stations, then favorites (★ prefixed), then catalog stations (with metadata). IDs are prefixed: "l:", "f:", "c:".
func (*Provider) SearchCatalog ¶
SearchCatalog performs a server-side station search via the Radio Browser API. Results are reflected in subsequent Playlists() calls. Implements provider.CatalogSearcher.
func (*Provider) SetSearchResults ¶
func (p *Provider) SetSearchResults(stations []CatalogStation)
SetSearchResults activates search mode with the given results. Playlists() will return search results instead of catalog stations.
func (*Provider) ToggleFavorite ¶
ToggleFavorite toggles the favorite status of a catalog or favorite entry. Returns (true, name) if added, (false, name) if removed.