Documentation
¶
Overview ¶
Package audiodb is the library behind the audiodb 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, reqURL 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"`
Name string `json:"name"`
ArtistID string `json:"artist_id,omitempty"`
ArtistName string `json:"artist,omitempty"`
Year string `json:"year,omitempty"`
Genre string `json:"genre,omitempty"`
Label string `json:"label,omitempty"`
Score string `json:"score,omitempty"`
}
Album is a music album record from TheAudioDB.
type Artist ¶
type Artist struct {
ID string `json:"id"`
Name string `json:"name"`
Genre string `json:"genre,omitempty"`
Country string `json:"country,omitempty"`
FormedYear string `json:"formed_year,omitempty"`
Members string `json:"members,omitempty"`
Biography string `json:"biography,omitempty"`
}
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 url 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
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 audiodb 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.
type Track ¶
type Track struct {
ID string `json:"id"`
Name string `json:"name"`
AlbumID string `json:"album_id,omitempty"`
AlbumName string `json:"album,omitempty"`
Duration string `json:"duration_ms,omitempty"`
Genre string `json:"genre,omitempty"`
TrackNumber string `json:"track_number,omitempty"`
MusicVideo string `json:"music_video,omitempty"`
}
Track is a music track record from TheAudioDB.