Documentation
¶
Overview ¶
Package deezer is the library behind the deezer command line: the HTTP client, request shaping, and the typed data models for the Deezer public music API (https://api.deezer.com/).
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 ChartSection
- type Client
- func (c *Client) GetAlbum(ctx context.Context, id int64) (*Album, error)
- func (c *Client) GetArtist(ctx context.Context, id int64) (*Artist, error)
- func (c *Client) GetChart(ctx context.Context) (*ChartSection, error)
- func (c *Client) GetTrack(ctx context.Context, id int64) (*Track, error)
- func (c *Client) SearchAlbums(ctx context.Context, query string, limit int) ([]Album, error)
- func (c *Client) SearchArtists(ctx context.Context, query string, limit int) ([]Artist, error)
- func (c *Client) SearchTracks(ctx context.Context, query string, limit int) ([]Track, error)
- type Domain
- type Track
Constants ¶
const DefaultUserAgent = "deezer-cli/dev (+https://github.com/tamnd/deezer-cli)"
DefaultUserAgent identifies the client to Deezer. A real, honest User-Agent is both polite and the thing most likely to keep you unblocked.
const Host = "deezer.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 int64 `json:"id"`
Title string `json:"title"`
Artist string `json:"artist"`
Tracks int `json:"nb_tracks,omitempty"`
ReleaseDate string `json:"release_date,omitempty"`
Genres []string `json:"genres,omitempty"`
TrackList []Track `json:"track_list,omitempty"`
CoverURL string `json:"cover_url,omitempty"`
}
Album is a Deezer album.
type Artist ¶
type Artist struct {
ID int64 `json:"id"`
Name string `json:"name"`
Albums int `json:"nb_albums,omitempty"`
Fans int `json:"nb_fans,omitempty"`
PictureURL string `json:"picture_url,omitempty"`
TopTracks []Track `json:"top_tracks,omitempty"`
}
Artist is a Deezer artist.
type ChartSection ¶
type ChartSection struct {
Tracks []Track `json:"tracks,omitempty"`
Albums []Album `json:"albums,omitempty"`
Artists []Artist `json:"artists,omitempty"`
}
ChartSection holds the current chart data.
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
// Rate is the minimum gap between requests. Zero means no pacing.
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to the Deezer API over HTTP.
func (*Client) GetChart ¶
func (c *Client) GetChart(ctx context.Context) (*ChartSection, error)
GetChart fetches the current global chart.
func (*Client) SearchAlbums ¶
SearchAlbums searches for albums matching query.
func (*Client) SearchArtists ¶
SearchArtists searches for artists matching query.
type Domain ¶
type Domain struct{}
Domain is the deezer 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 int64 `json:"id"`
Title string `json:"title"`
Artist string `json:"artist"`
Album string `json:"album,omitempty"`
Duration int `json:"duration_seconds,omitempty"`
Preview string `json:"preview_url,omitempty"`
Rank int `json:"rank,omitempty"`
}
Track is a Deezer track (song).