deezer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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

View Source
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.

View Source
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 NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults.

func (*Client) GetAlbum

func (c *Client) GetAlbum(ctx context.Context, id int64) (*Album, error)

GetAlbum fetches album details with track list.

func (*Client) GetArtist

func (c *Client) GetArtist(ctx context.Context, id int64) (*Artist, error)

GetArtist fetches artist info and their top tracks.

func (*Client) GetChart

func (c *Client) GetChart(ctx context.Context) (*ChartSection, error)

GetChart fetches the current global chart.

func (*Client) GetTrack

func (c *Client) GetTrack(ctx context.Context, id int64) (*Track, error)

GetTrack fetches a single track by ID.

func (*Client) SearchAlbums

func (c *Client) SearchAlbums(ctx context.Context, query string, limit int) ([]Album, error)

SearchAlbums searches for albums matching query.

func (*Client) SearchArtists

func (c *Client) SearchArtists(ctx context.Context, query string, limit int) ([]Artist, error)

SearchArtists searches for artists matching query.

func (*Client) SearchTracks

func (c *Client) SearchTracks(ctx context.Context, query string, limit int) ([]Track, error)

SearchTracks searches for tracks 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) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify and Locate satisfy the kit.Domain interface for URI routing.

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.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

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

Jump to

Keyboard shortcuts

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