radio

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package radio provides a client for the RadioBrowser API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeStreamURL added in v1.1.0

func NormalizeStreamURL(streamURL string) string

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.

func (*Catalog) TopVoted added in v1.1.0

func (c *Catalog) TopVoted(limit int) ([]StationView, error)

TopVoted returns projected top-voted 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 NewClient

func NewClient() *Client

NewClient creates a new RadioBrowser client.

func (*Client) ByCountry

func (c *Client) ByCountry(country string, limit int) ([]Station, error)

ByCountry returns stations matching a country.

func (*Client) ByTag

func (c *Client) ByTag(tag string, limit int) ([]Station, error)

ByTag returns stations matching a tag (genre).

func (*Client) ByUUID

func (c *Client) ByUUID(stationUUID string) ([]Station, error)

ByUUID returns a station by its RadioBrowser UUID.

func (*Client) Search

func (c *Client) Search(query string, limit int) ([]Station, error)

Search searches for stations by name.

func (*Client) SearchFiltered

func (c *Client) SearchFiltered(country, codec, tag string, limit int) ([]Station, error)

SearchFiltered searches for stations with optional country, codec, and tag filters.

func (*Client) SetServers

func (c *Client) SetServers(servers []string)

SetServers pins API mirrors (for tests).

func (*Client) TopClicked

func (c *Client) TopClicked(limit int) ([]Station, error)

TopClicked returns the most clicked stations.

func (*Client) TopVoted

func (c *Client) TopVoted(limit int) ([]Station, error)

TopVoted returns the top voted 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.

Jump to

Keyboard shortcuts

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