radio

package
v1.60.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 16 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCatalogOrFavID

func IsCatalogOrFavID(id string) bool

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) Contains

func (f *Favorites) Contains(url string) bool

Contains returns true if the station URL is in favorites.

func (*Favorites) Remove

func (f *Favorites) Remove(url string) error

Remove removes a station by URL from 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

func (p *Provider) IDPrefix(id string) string

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

func (p *Provider) IsFavoritableID(id string) bool

IsFavoritableID reports whether the given ID can be favorited. Implements provider.SectionedList.

func (*Provider) IsSearching

func (p *Provider) IsSearching() bool

IsSearching returns true if API search results are active.

func (*Provider) LoadCatalogPage

func (p *Provider) LoadCatalogPage(offset, limit int) (int, error)

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) Name

func (p *Provider) Name() string

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

func (p *Provider) SearchCatalog(query string) (int, error)

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

func (p *Provider) ToggleFavorite(id string) (added bool, name string, err error)

ToggleFavorite toggles the favorite status of a catalog or favorite entry. Returns (true, name) if added, (false, name) if removed.

func (*Provider) Tracks

func (p *Provider) Tracks(id string) ([]playlist.Track, error)

Tracks returns a single-track playlist for the given station ID.

Jump to

Keyboard shortcuts

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