Documentation
¶
Overview ¶
Package discogs is the library behind the discogs command line: the HTTP client, request shaping, and the typed data models for the Discogs music database 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 transient failures (429 and 5xx). Build endpoint calls and JSON decoding on top of it.
Index ¶
- Constants
- type Artist
- type Client
- func (c *Client) Get(ctx context.Context, url string) ([]byte, error)
- func (c *Client) GetArtist(ctx context.Context, id string) (*Artist, error)
- func (c *Client) GetLabel(ctx context.Context, id string) (*Label, error)
- func (c *Client) GetMaster(ctx context.Context, id string) (*Master, error)
- func (c *Client) GetRelease(ctx context.Context, id string) (*Release, error)
- func (c *Client) Search(ctx context.Context, query, typ string, limit int) ([]*SearchResult, error)
- type Domain
- type Label
- type Master
- type Release
- type SearchResult
- type Track
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
const DefaultUserAgent = "discogs-cli/0.1.0 (github.com/tamnd/discogs-cli)"
DefaultUserAgent identifies the client to Discogs. A real, honest User-Agent is both polite and the thing most likely to keep you unblocked.
const Host = "api.discogs.com"
Host is the API host this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Artist ¶
type Artist struct {
ID int `kit:"id" json:"id"`
Name string `json:"name"`
Profile string `json:"profile"`
URLs []string `json:"urls"`
Members []string `json:"members"`
}
Artist is a Discogs artist record.
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 Discogs API over HTTP.
func NewClient ¶
func NewClient() *Client
NewClient returns a Client with sensible defaults: a 30s timeout, a 200ms minimum gap between requests, and three retries on transient errors.
func (*Client) Get ¶
Get fetches url and returns the response body. It paces and retries according to the client's settings.
func (*Client) GetRelease ¶
GetRelease fetches a release by numeric ID.
type Domain ¶
type Domain struct{}
Domain is the Discogs driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Classify ¶
Classify turns any accepted input into (uriType, id). - Numeric ID → default "release" type - URL path like /artists/45 → parse type+ID - Non-numeric, non-URL → "search" type
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 Label ¶
type Label struct {
ID int `kit:"id" json:"id"`
Name string `json:"name"`
Profile string `json:"profile"`
ContactInfo string `json:"contact_info"`
}
Label is a Discogs record label.
type Master ¶
type Master struct {
ID int `kit:"id" json:"id"`
Title string `json:"title"`
Year int `json:"year"`
Artists []string `json:"artists"`
Genres []string `json:"genres"`
Styles []string `json:"styles"`
}
Master is a Discogs master release record.
type Release ¶
type Release struct {
ID int `kit:"id" json:"id"`
Title string `json:"title"`
Year int `json:"year"`
Artists []string `json:"artists"`
Genres []string `json:"genres"`
Styles []string `json:"styles"`
Tracklist []Track `json:"tracklist"`
}
Release is a Discogs release record.