musicbrainz

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package musicbrainz provides a client for querying the MusicBrainz API. It supports searching for releases by various criteria and retrieving detailed release information including recordings, artists, labels, and genres.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoResults = errors.New("no results")

Functions

func ArtistsCreditNames

func ArtistsCreditNames(credits []ArtistCredit) []string

func ArtistsCreditString

func ArtistsCreditString(credits []ArtistCredit) string

func ArtistsEnNames added in v0.9.0

func ArtistsEnNames(credits []ArtistCredit) []string

func ArtistsEnString added in v0.9.0

func ArtistsEnString(credits []ArtistCredit) string

func ArtistsNames

func ArtistsNames(credits []ArtistCredit) []string

func ArtistsSortNames added in v0.14.0

func ArtistsSortNames(credits []ArtistCredit) []string

func ArtistsSortString added in v0.14.0

func ArtistsSortString(credits []ArtistCredit) string

func ArtistsString

func ArtistsString(credits []ArtistCredit) string

func IsCompilation

func IsCompilation(rg ReleaseGroup) bool

func ReleaseDisambiguation added in v0.32.0

func ReleaseDisambiguation(release Release) string

func ReleaseEnTitle added in v0.32.0

func ReleaseEnTitle(release Release) string

func ReleaseGroupEnTitle added in v0.32.0

func ReleaseGroupEnTitle(rg ReleaseGroup) string

func ReleaseOrGroupEnTitle added in v0.32.0

func ReleaseOrGroupEnTitle(release Release) string

Types

type Alias added in v0.9.0

type Alias struct {
	Locale   string `json:"locale"`
	Primary  bool   `json:"primary"`
	Ended    bool   `json:"ended"`
	Type     string `json:"type"`
	TypeID   string `json:"type-id"`
	Begin    any    `json:"begin"`
	Name     string `json:"name"`
	End      any    `json:"end"`
	SortName string `json:"sort-name"`
}

type AnyTime

type AnyTime struct {
	time.Time
}

func (*AnyTime) UnmarshalJSON

func (at *AnyTime) UnmarshalJSON(data []byte) error

type Artist

type Artist struct {
	ID             string  `json:"id"`
	Name           string  `json:"name"`
	TypeID         string  `json:"type-id"`
	SortName       string  `json:"sort-name"`
	Type           string  `json:"type"`
	Genres         []Genre `json:"genres"`
	Disambiguation string  `json:"disambiguation"`
	Aliases        []Alias `json:"aliases"`
}

type ArtistCredit

type ArtistCredit struct {
	Name       string `json:"name"`
	JoinPhrase string `json:"joinphrase"`
	Artist     Artist `json:"artist"`
}

type CAAClient

type CAAClient struct {
	BaseURL    string
	HTTPClient *http.Client
	Limiter    *rate.Limiter
}

func (*CAAClient) GetCoverURL

func (c *CAAClient) GetCoverURL(ctx context.Context, release *Release) (string, error)

type Genre

type Genre struct {
	ID             string `json:"id"`
	Name           string `json:"name"`
	Disambiguation string `json:"disambiguation"`
	Count          int    `json:"count"`
}

func AnyGenres

func AnyGenres(release *Release) (genres []Genre)

type Label

type Label struct {
	LabelCode      any     `json:"label-code"`
	Type           string  `json:"type"`
	Disambiguation string  `json:"disambiguation"`
	SortName       string  `json:"sort-name"`
	TypeID         string  `json:"type-id"`
	Genres         []Genre `json:"genres"`
	ID             string  `json:"id"`
	Name           string  `json:"name"`
}

type LabelInfo

type LabelInfo struct {
	Label         Label  `json:"label"`
	CatalogNumber string `json:"catalog-number"`
}

func AnyLabelInfo

func AnyLabelInfo(release *Release) LabelInfo

type MBClient

type MBClient struct {
	BaseURL    string
	HTTPClient *http.Client
	Limiter    *rate.Limiter
}

func (*MBClient) GetRelease

func (c *MBClient) GetRelease(ctx context.Context, mbid string) (*Release, error)

func (*MBClient) SearchRelease

func (c *MBClient) SearchRelease(ctx context.Context, q ReleaseQuery) (*Release, error)

type Media

type Media struct {
	TrackOffset int     `json:"track-offset"`
	TrackCount  int     `json:"track-count"`
	Tracks      []Track `json:"tracks"`
	Pregap      *Track  `json:"pregap,omitempty"`
	Format      string  `json:"format"`
	FormatID    string  `json:"format-id"`
	Title       string  `json:"title"`
	Position    int     `json:"position"`
}

type Relation added in v0.14.0

type Relation struct {
	TargetType      string   `json:"target-type"`
	TypeID          string   `json:"type-id"`
	SourceCredit    string   `json:"source-credit"`
	TargetCredit    string   `json:"target-credit"`
	AttributeIDs    struct{} `json:"attribute-ids"`
	Direction       string   `json:"direction"`
	Attributes      []any    `json:"attributes"`
	Type            string   `json:"type"`
	AttributeValues struct{} `json:"attribute-values"`
	Begin           any      `json:"begin"`
	End             any      `json:"end"`
	Ended           bool     `json:"ended"`
	Artist          Artist   `json:"artist"`
	Work            Work     `json:"work"`
}

type Release

type Release struct {
	Title              string `json:"title"`
	ID                 string `json:"id"`
	TextRepresentation struct {
		Language string `json:"language"`
		Script   string `json:"script"`
	} `json:"text-representation"`
	StatusID        string  `json:"status-id"`
	ASIN            string  `json:"asin"`
	Genres          []Genre `json:"genres"`
	Country         string  `json:"country"`
	Barcode         string  `json:"barcode"`
	Disambiguation  string  `json:"disambiguation"`
	Packaging       string  `json:"packaging"`
	CoverArtArchive struct {
		Artwork  bool `json:"artwork"`
		Front    bool `json:"front"`
		Darkened bool `json:"darkened"`
		Back     bool `json:"back"`
		Count    int  `json:"count"`
	} `json:"cover-art-archive"`
	Artists       []ArtistCredit `json:"artist-credit"`
	Date          AnyTime        `json:"date"`
	Quality       string         `json:"quality"`
	Media         []Media        `json:"media"`
	Status        string         `json:"status"`
	ReleaseGroup  ReleaseGroup   `json:"release-group"`
	ReleaseEvents []struct {
		Area struct {
			ID             string   `json:"id"`
			Name           string   `json:"name"`
			Iso31661Codes  []string `json:"iso-3166-1-codes"`
			TypeID         any      `json:"type-id"`
			SortName       string   `json:"sort-name"`
			Disambiguation string   `json:"disambiguation"`
			Type           any      `json:"type"`
		} `json:"area"`
		Date AnyTime `json:"date"`
	} `json:"release-events"`
	PackagingID string      `json:"packaging-id"`
	LabelInfo   []LabelInfo `json:"label-info"`
	Aliases     []Alias     `json:"aliases"`
}

type ReleaseGroup

type ReleaseGroup struct {
	FirstReleaseDate AnyTime                     `json:"first-release-date"`
	Genres           []Genre                     `json:"genres"`
	PrimaryTypeID    string                      `json:"primary-type-id"`
	Disambiguation   string                      `json:"disambiguation"`
	Artists          []ArtistCredit              `json:"artist-credit"`
	SecondaryTypeIDs []any                       `json:"secondary-type-ids"`
	PrimaryType      ReleaseGroupPrimaryType     `json:"primary-type"`
	ID               string                      `json:"id"`
	SecondaryTypes   []ReleaseGroupSecondaryType `json:"secondary-types"`
	Title            string                      `json:"title"`
	Aliases          []Alias                     `json:"aliases"`
}

type ReleaseGroupPrimaryType

type ReleaseGroupPrimaryType string
const (
	Album     ReleaseGroupPrimaryType = "Album"
	Single    ReleaseGroupPrimaryType = "Single"
	EP        ReleaseGroupPrimaryType = "EP"
	Broadcast ReleaseGroupPrimaryType = "Broadcast"
	Other     ReleaseGroupPrimaryType = "Other"
)

type ReleaseGroupSecondaryType

type ReleaseGroupSecondaryType string
const (
	AudioDrama     ReleaseGroupSecondaryType = "Audio drama"
	Audiobook      ReleaseGroupSecondaryType = "Audiobook"
	Compilation    ReleaseGroupSecondaryType = "Compilation"
	Demo           ReleaseGroupSecondaryType = "Demo"
	DJMix          ReleaseGroupSecondaryType = "DJ-mix"
	FieldRecording ReleaseGroupSecondaryType = "Field recording"
	Interview      ReleaseGroupSecondaryType = "Interview"
	Live           ReleaseGroupSecondaryType = "Live"
	MixtapeStreet  ReleaseGroupSecondaryType = "Mixtape/Street"
	Remix          ReleaseGroupSecondaryType = "Remix"
	Soundtrack     ReleaseGroupSecondaryType = "Soundtrack"
	Spokenword     ReleaseGroupSecondaryType = "Spokenword"
)

type ReleaseQuery

type ReleaseQuery struct {
	MBReleaseID      string
	MBArtistID       string
	MBReleaseGroupID string

	Release      string
	Artist       string
	Date         time.Time
	Format       string
	Label        string
	CatalogueNum string
	Barcode      string
	NumTracks    int
}

type StatusError

type StatusError int

func (StatusError) Error

func (se StatusError) Error() string

type Track

type Track struct {
	ID        string `json:"id"`
	Length    int    `json:"length"`
	Recording struct {
		FirstReleaseDate string         `json:"first-release-date"`
		Genres           []Genre        `json:"genres"`
		Video            bool           `json:"video"`
		Disambiguation   string         `json:"disambiguation"`
		ID               string         `json:"id"`
		Length           int            `json:"length"`
		Title            string         `json:"title"`
		Artists          []ArtistCredit `json:"artist-credit"`
		Relations        []Relation     `json:"relations"`
		ISRCs            []string       `json:"isrcs"`
	} `json:"recording"`
	Number   string         `json:"number"`
	Position int            `json:"position"`
	Title    string         `json:"title"`
	Artists  []ArtistCredit `json:"artist-credit"`
}

type Work added in v0.15.0

type Work struct {
	Type           any        `json:"type"`
	Relations      []Relation `json:"relations"`
	Language       string     `json:"language"`
	Languages      []string   `json:"languages"`
	Disambiguation string     `json:"disambiguation"`
	Title          string     `json:"title"`
	Iswcs          []any      `json:"iswcs"`
	ID             string     `json:"id"`
	Attributes     []any      `json:"attributes"`
	TypeID         any        `json:"type-id"`
}

Jump to

Keyboard shortcuts

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