Documentation
¶
Overview ¶
Package musicbrainz is the library behind the musicbrainz command line: the HTTP client, request shaping, and typed data models for the MusicBrainz open music metadata database (https://musicbrainz.org/ws/2).
MusicBrainz is rate-limited to 1 request per second. The Client paces requests at 1100 ms intervals and retries 503/429/5xx with exponential backoff. A descriptive User-Agent header is required by the API Terms of Service.
Index ¶
- Constants
- type Artist
- type ArtistDetail
- type Client
- func (c *Client) Artists(ctx context.Context, query string, limit int) ([]Artist, error)
- func (c *Client) GetArtist(ctx context.Context, mbid string) (*ArtistDetail, error)
- func (c *Client) Labels(ctx context.Context, query string, limit int) ([]Label, error)
- func (c *Client) Recordings(ctx context.Context, query string, limit int) ([]Recording, error)
- func (c *Client) ReleaseGroups(ctx context.Context, query string, limit int) ([]ReleaseGroup, error)
- func (c *Client) Releases(ctx context.Context, query string, limit int) ([]Release, error)
- type Config
- type Domain
- type Label
- type Recording
- type Release
- type ReleaseGroup
- type ReleaseStub
Constants ¶
const Host = "musicbrainz.org"
Host is the site this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Artist ¶
type Artist struct {
Rank int `json:"rank"`
MBID string `json:"mbid"`
Name string `json:"name"`
Type string `json:"type"` // Group, Person, Orchestra, Choir, Other
Country string `json:"country"` // ISO 3166-1 alpha-2 country code
Area string `json:"area"` // area name
BeginDate string `json:"begin_date"` // YYYY or YYYY-MM or YYYY-MM-DD
EndDate string `json:"end_date"`
Score int `json:"score"` // relevance 0-100
URL string `json:"url"` // https://musicbrainz.org/artist/{id}
}
Artist is one result from a MusicBrainz artist search.
type ArtistDetail ¶ added in v0.2.0
type ArtistDetail struct {
MBID string `json:"mbid"`
Name string `json:"name"`
Type string `json:"type"`
Country string `json:"country"`
Area string `json:"area"`
BeginDate string `json:"begin_date"`
EndDate string `json:"end_date"`
URL string `json:"url"`
Releases []ReleaseStub `json:"releases"`
}
ArtistDetail is the full artist record from a lookup by MBID.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to MusicBrainz over HTTP.
func (*Client) Artists ¶
Artists searches MusicBrainz for artists matching query. Returns at most limit results (pass 0 for default of 10; max 100).
func (*Client) GetArtist ¶ added in v0.2.0
GetArtist fetches a full artist record by MBID, including their releases.
func (*Client) Labels ¶ added in v0.2.0
Labels searches MusicBrainz for labels matching query. Returns at most limit results (pass 0 for default of 10; max 100).
func (*Client) Recordings ¶
Recordings searches MusicBrainz for recordings matching query. Returns at most limit results (pass 0 for default of 10; max 100).
func (*Client) ReleaseGroups ¶ added in v0.2.0
func (c *Client) ReleaseGroups(ctx context.Context, query string, limit int) ([]ReleaseGroup, error)
ReleaseGroups searches MusicBrainz for release groups matching query. Returns at most limit results (pass 0 for default of 10; max 100).
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with the MusicBrainz public API base URL, a descriptive User-Agent, and a 1100 ms rate floor (10% above the 1 req/s limit).
type Domain ¶
type Domain struct{}
Domain is the musicbrainz driver.
func (Domain) Classify ¶
Classify turns an input into the canonical (type, id). MusicBrainz entities live at /{type}/{uuid}.
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 ¶ added in v0.2.0
type Label struct {
Rank int `json:"rank"`
MBID string `json:"mbid"`
Name string `json:"name"`
Type string `json:"type"` // Original Production, Bootleg Production, etc.
Country string `json:"country"` // ISO 3166-1 alpha-2
Score int `json:"score"`
URL string `json:"url"` // https://musicbrainz.org/label/{id}
}
Label is one result from a MusicBrainz label search.
type Recording ¶
type Recording struct {
Rank int `json:"rank"`
MBID string `json:"mbid"`
Title string `json:"title"`
ArtistCredit string `json:"artist_credit"` // primary artist-credit name(s)
ReleaseTitle string `json:"release_title"`
ReleaseDate string `json:"release_date"`
LengthMs int `json:"length_ms"` // duration in ms (0 if unknown)
Score int `json:"score"` // relevance 0-100
URL string `json:"url"` // https://musicbrainz.org/recording/{id}
}
Recording is one result from a MusicBrainz recording search.
type Release ¶ added in v0.2.0
type Release struct {
Rank int `json:"rank"`
MBID string `json:"mbid"`
Title string `json:"title"`
Status string `json:"status"` // Official, Promotional, Bootleg, Pseudo-Release
Date string `json:"date"` // YYYY or YYYY-MM or YYYY-MM-DD
Country string `json:"country"` // ISO 3166-1 alpha-2
Label string `json:"label"` // first label name
Type string `json:"type"` // Album, Single, EP, Compilation, etc.
ArtistCredit string `json:"artist_credit"` // primary artist-credit name(s)
Score int `json:"score"`
URL string `json:"url"` // https://musicbrainz.org/release/{id}
}
Release is one result from a MusicBrainz release search.
type ReleaseGroup ¶ added in v0.2.0
type ReleaseGroup struct {
Rank int `json:"rank"`
MBID string `json:"mbid"`
Title string `json:"title"`
Type string `json:"type"` // Album, Single, EP, Broadcast, Other
FirstReleaseDate string `json:"first_release_date"` // YYYY or YYYY-MM or YYYY-MM-DD
ArtistCredit string `json:"artist_credit"`
Score int `json:"score"`
URL string `json:"url"` // https://musicbrainz.org/release-group/{id}
}
ReleaseGroup is one result from a MusicBrainz release-group search.