Documentation
¶
Overview ¶
Package theaudiodb is the library behind the theaudiodb command line: the HTTP client, request shaping, and the typed data models for TheAudioDB API.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public API throws under load.
Index ¶
- Constants
- type Album
- type Artist
- type Client
- func (c *Client) Discography(ctx context.Context, artistName string) ([]*Album, error)
- func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)
- func (c *Client) SearchAlbum(ctx context.Context, artistName, albumName string) ([]*Album, error)
- func (c *Client) SearchArtist(ctx context.Context, name string) ([]*Artist, error)
- func (c *Client) SearchTrack(ctx context.Context, artistName, trackName string) ([]*Track, error)
- type Config
- type Domain
- type Track
Constants ¶
const Host = "www.theaudiodb.com"
Host is the site this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Album ¶
type Album struct {
ID string `json:"id" kit:"id"`
Name string `json:"name"`
Artist string `json:"artist"`
Year string `json:"year"`
Genre string `json:"genre"`
Style string `json:"style"`
Score string `json:"score"`
}
Album is a music album record from TheAudioDB.
type Artist ¶
type Artist struct {
ID string `json:"id" kit:"id"`
Name string `json:"name"`
Genre string `json:"genre"`
Country string `json:"country"`
FormedYear string `json:"formed_year"`
Biography string `json:"biography"`
}
Artist is a music artist record from TheAudioDB.
type Client ¶
Client talks to TheAudioDB API over HTTP.
func NewClientWithConfig ¶
NewClientWithConfig returns a Client configured with the given Config.
func (*Client) Discography ¶
Discography returns all albums for a given artist name.
func (*Client) Get ¶
Get fetches rawURL and returns the response body. It paces and retries according to the client's settings.
func (*Client) SearchAlbum ¶
SearchAlbum searches for albums by artist name and album name.
func (*Client) SearchArtist ¶
SearchArtist searches for artists by name.
type Config ¶
type Config struct {
BaseURL string
APIKey string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tuneable client settings.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for the TheAudioDB free API.
type Domain ¶
type Domain struct{}
Domain is the theaudiodb driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.