monstercat

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DownloadReleaseFormatFlac = "flac"
	DownloadReleaseFormatMP3  = "mp3_320"
	DownloadReleaseFormatWAV  = "wav"
)

define all known download formats

Variables

View Source
var (
	// ErrorInvalidCredentials is returned when a login fails because of invalid credentials supplied by the user
	ErrorInvalidCredentials = fmt.Errorf("invalid credentials")

	// ErrorClientNotLoggedIn is returned when an action fails because of missing authentication
	ErrorClientNotLoggedIn = fmt.Errorf("client not logged in")
)

Functions

func Default added in v2.2.0

func Default() url.Values

Default returns the default query parameters for the catalog endpoint.

Types

type Artist

type Artist struct {
	ID   string `json:"Id"`
	Name string `json:"Name"`
	Role string `json:"Role"`
	URI  string `json:"URI"`
}

Artist describes a single artist of a CatalogItem

type BrowseOption added in v2.2.0

type BrowseOption func(parameters *url.Values)

BrowseOption is a function that can be used to modify the query parameters of the catalog endpoint.

func IncludeGold added in v2.2.0

func IncludeGold(include bool) BrowseOption

IncludeGold decides whether to include gold tracks or not.

func IncludeUnreleased added in v2.2.0

func IncludeUnreleased(include bool) BrowseOption

IncludeUnreleased decides whether to include unreleased tracks or not.

func WithBrand added in v2.2.0

func WithBrand(brandID int) BrowseOption

WithBrand limits the results to the tracks released under the given brands. 1: Uncaged 2: Instinct 3: Call of the Wild 4: Silk 5: Silk Showcase

func WithGenre added in v2.2.0

func WithGenre(genre string) BrowseOption

WithGenre limits the results to the tracks matching the given genre. Examples are "dubstep", "acoustic" or "melodic house & techno". See the Monstercat Player for a full list of genres.

func WithLimit added in v2.2.0

func WithLimit(limit int) BrowseOption

WithLimit limits the results to the given number of items.

func WithOffset added in v2.2.0

func WithOffset(offset int) BrowseOption

WithOffset allows to skip the given number of items.

func WithReleaseType added in v2.2.0

func WithReleaseType(releaseType string) BrowseOption

WithReleaseType limits the results to the tracks matching the given release type. Either "Single", "EP" or "Album".

func WithSearch added in v2.2.0

func WithSearch(query string) BrowseOption

WithSearch limits the results to the tracks, albums or artists matching the given search query.

func WithSort added in v2.2.0

func WithSort(sortBy string) BrowseOption

WithSort sorts the results by the given field. Adding a minus sign to the field name will sort in descending order. Either "title", "artists", "release", "genre", "date", "bpm", "duration" or "brand".

func WithTag added in v2.2.0

func WithTag(tag string) BrowseOption

WithTag limits the results to the tracks matching the given tag. Examples are "chill", "badass" or "funky". See the Monstercat Player for a full list of genres.

type Catalog

type Catalog struct {
	Data   []CatalogItem `json:"Data"`
	Total  int           `json:"Total"`
	Limit  int           `json:"Limit"`
	Offset int           `json:"Offset"`
}

Catalog represents a list of catalog items from Monstercat API

func (Catalog) HasNextPage

func (catalog Catalog) HasNextPage() bool

HasNextPage returns true if the catalog list contains more pages, false otherwise.

type CatalogItem

type CatalogItem struct {
	ID           string    `json:"Id"`
	ISRC         string    `json:"ISRC"`
	Title        string    `json:"Title"`
	Artists      []Artist  `json:"Artists"`
	ArtistsTitle string    `json:"ArtistsTitle"`
	DebutDate    time.Time `json:"DebutDate"`
	Release      Release   `json:"Release"`
	Tags         []string  `json:"Tags"`
	Version      string    `json:"Version"`

	Brand   string `json:"Brand"`
	BrandID int    `json:"BrandId"`

	BPM            float32 `json:"BPM"`
	Duration       int     `json:"Duration"`
	Explicit       bool    `json:"Explicit"`
	GenrePrimary   string  `json:"GenrePrimary"`
	GenreSecondary string  `json:"GenreSecondary"`

	CreatorFriendly bool `json:"CreatorFriendly"`
	Downloadable    bool `json:"Downloadable"`
	InEarlyAccess   bool `json:"InEarlyAccess"`
	Streamable      bool `json:"Streamable"`
}

CatalogItem represents a single release from Monstercat API

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is used to handle all operations, especially stateful ones like Login

func NewClient

func NewClient() Client

NewClient creates and returns a new Client for interaction with the Monstercat API

func (Client) BrowseCatalog added in v2.2.0

func (client Client) BrowseCatalog(options ...BrowseOption) (Catalog, error)

BrowseCatalog returns a set of catalog items defined by the given BrowseOptions. All BrowseOptions will override their default values defined in Default().

func (Client) Catalog

func (client Client) Catalog(search string, releaseType string, limit int, offset int) (Catalog, error)

Catalog returns a set of catalog items containing the given search query, matching the given release type and being within the given range. While limit and offset are required, you may leave search and releaseType empty to ignore those filters. Deprecated: Use the BrowseCatalog function instead.

func (Client) DownloadCatalogItem added in v2.1.0

func (client Client) DownloadCatalogItem(catalogItem CatalogItem, downloadFormat DownloadFormat, downloadPath string) error

DownloadCatalogItem downloads the given catalog item in the requested format and stores it at the given path

func (Client) IsLoggedIn

func (client Client) IsLoggedIn() bool

IsLoggedIn returns true if the client is logged in, false otherwise

func (*Client) Login

func (client *Client) Login(email string, password string) error

Login performs a login request into your Monstercat account and stores the created authentication cookie on success for further requests

type DownloadFormat

type DownloadFormat string

DownloadFormat describes in what kind of formats we can download a catalog item

type Release

type Release struct {
	ArtistsTitle string      `json:"ArtistsTitle"`
	CatalogID    string      `json:"CatalogId"`
	Description  string      `json:"Description"`
	ID           string      `json:"Id"`
	ReleaseDate  time.Time   `json:"ReleaseDate"`
	Title        string      `json:"Title"`
	Type         ReleaseType `json:"Type"`
	UPC          string      `json:"UPC"`
	Version      string      `json:"Version"`
}

Release describes which release a CatalogItem belongs to

type ReleaseType

type ReleaseType string

ReleaseType describes what kind of release we are looking at

const (
	ReleaseTypeAlbum       ReleaseType = "Album"
	ReleaseTypeCompilation ReleaseType = "Compilation"
	ReleaseTypeEP          ReleaseType = "EP"
	ReleaseTypeMixes       ReleaseType = "Mixes"
	ReleaseTypePodcast     ReleaseType = "Podcast"
	ReleaseTypeSingle      ReleaseType = "Single"
)

define all known release types

Jump to

Keyboard shortcuts

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