spotify

package
v0.0.0-...-96f436b Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Artist

type Artist struct {
	NamedNode

	ExternalUrls ExternalUrls `json:"external_urls"`
	Followers    Followers    `json:"followers"`
	Genres       []string     `json:"genres"`
	Images       []Image      `json:"images"`
	Popularity   int          `json:"popularity"`
}

type AuthManager

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

func NewAuthManager

func NewAuthManager(cfg *Config) *AuthManager

func (*AuthManager) Server

func (manager *AuthManager) Server() Authorizer

func (*AuthManager) User

func (manager *AuthManager) User(code string) Authorizer

type Authorizer

type Authorizer interface {
	Token() Token
	SetToken(token Token)
	Authorize(context.Context) (*Token, error)
}

type Client

type Client struct {
	http.Client

	Authorizer Authorizer
}

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

type Config

type Config struct {
	Credentials `yaml:",inline"`

	RedirectURI string `yaml:"redirect_uri"`
}

type Credentials

type Credentials struct {
	ClientID     string `yaml:"client_id"`
	ClientSecret string `yaml:"client_secret"`
}

func (Credentials) Userinfo

func (c Credentials) Userinfo() string

type ExternalUrls

type ExternalUrls struct {
	Spotify string `json:"spotify"`
}

type Followers

type Followers struct {
	Href  *string `json:"href"`
	Total int     `json:"total"`
}

type Image

type Image struct {
	Url    string `json:"url"`
	Height int    `json:"height"`
	Width  int    `json:"width"`
}

type NamedNode

type NamedNode struct {
	Node

	Name string `json:"name"`
}

type Node

type Node struct {
	Href string `json:"href"`
	Id   string `json:"id"`
	Type string `json:"type"`
	Uri  string `json:"uri"`
}

type Page

type Page[T any] struct {
	Href     string `json:"href"`
	Next     string `json:"next"`
	Previous string `json:"previous"`
	Limit    int    `json:"limit"`
	Offset   int    `json:"offset"`
	Total    int    `json:"total"`
	Items    []T    `json:"items"`
}

type Restrictions

type Restrictions struct {
	Reason string `json:"reason"`
}

type SearchClient

type SearchClient struct{ Client }

func (*SearchClient) Search

func (c *SearchClient) Search(ctx context.Context, req *SearchRequest) (*SearchResponse, error)

type SearchRequest

type SearchRequest struct {
	Query  string
	Limit  int
	Offset int
}

type SearchResponse

type SearchResponse struct {
	Tracks    Page[Track]          `json:"tracks"`
	Artists   Page[Artist]         `json:"artists"`
	Albums    Page[SimpleAlbum]    `json:"albums"`
	Playlists Page[SimplePlaylist] `json:"playlists"`
}

type SimpleAlbum

type SimpleAlbum struct {
	NamedNode

	AlbumType            string         `json:"album_type"`
	Artists              []SimpleArtist `json:"artists"`
	AvailableMarkets     []string       `json:"available_markets"`
	ExternalUrls         ExternalUrls   `json:"external_urls"`
	Images               []Image        `json:"images"`
	ReleaseDate          string         `json:"release_date"`
	ReleaseDatePrecision string         `json:"release_date_precision"`
	Restrictions         Restrictions   `json:"restrictions"`
	TotalTracks          int            `json:"total_tracks"`
}

type SimpleArtist

type SimpleArtist struct {
	NamedNode

	ExternalUrls ExternalUrls `json:"external_urls"`
}

type SimplePlaylist

type SimplePlaylist struct {
	NamedNode

	Collaborative bool         `json:"collaborative"`
	Description   string       `json:"description"`
	ExternalUrls  ExternalUrls `json:"external_urls"`
	Images        []Image      `json:"images"`
	Public        bool         `json:"public"`
	SnapshotId    string       `json:"snapshot_id"`

	Owner struct {
		Node
		ExternalUrls ExternalUrls `json:"external_urls"`
		Followers    Followers    `json:"followers"`
		DisplayName  *string      `json:"display_name"`
	} `json:"owner"`

	Tracks struct {
		Href  string `json:"href"`
		Total int    `json:"total"`
	} `json:"tracks"`
}

type Token

type Token struct {
	AccessToken  string
	RefreshToken string
	TokenType    string
	ExpiresIn    time.Time
	Scope        string
}

func (*Token) UnmarshalJSON

func (t *Token) UnmarshalJSON(b []byte) error

type TopItemsRequest

type TopItemsRequest struct {
	TimeRange string
	Limit     int
	Offset    int
}

type TopItemsResponse

type TopItemsResponse[T TopItemsType] struct {
	Href     string `json:"href"`
	Next     string `json:"next"`
	Previous string `json:"previous"`
	Limit    int    `json:"limit"`
	Offset   int    `json:"offset"`
	Total    int    `json:"total"`
	Items    []T    `json:"items"`
}

type TopItemsType

type TopItemsType interface{ Track | Artist }

type Track

type Track struct {
	NamedNode

	Album            SimpleAlbum  `json:"album"`
	Artists          []Artist     `json:"artists"`
	AvailableMarkets []string     `json:"available_markets"`
	DiscNumber       int          `json:"disc_number"`
	DurationMs       int          `json:"duration_ms"`
	Explicit         bool         `json:"explicit"`
	ExternalUrls     ExternalUrls `json:"external_urls"`
	IsPlayable       bool         `json:"is_playable"`
	LinkedFrom       struct{}     `json:"linked_from"`
	Popularity       int          `json:"popularity"`
	PreviewUrl       *string      `json:"preview_url"`
	Restrictions     Restrictions `json:"restrictions"`
	TrackNumber      int          `json:"track_number"`
	IsLocal          bool         `json:"is_local"`

	ExternalIds struct {
		Isrc string `json:"isrc"`
		Ean  string `json:"ean"`
		Upc  string `json:"upc"`
	} `json:"external_ids"`
}

type User

type User struct {
	Node

	Country      string       `json:"country"`
	DisplayName  string       `json:"display_name"`
	ExternalUrls ExternalUrls `json:"external_urls"`
	Followers    Followers    `json:"followers"`
	Images       []Image      `json:"images"`
}

type UserClient

type UserClient struct{ Client }

func (*UserClient) Profile

func (c *UserClient) Profile(ctx context.Context) (*User, error)

func (*UserClient) TopArtists

func (c *UserClient) TopArtists(ctx context.Context, req TopItemsRequest) (*TopItemsResponse[Artist], error)

func (*UserClient) TopTracks

func (c *UserClient) TopTracks(ctx context.Context, req TopItemsRequest) (*TopItemsResponse[Track], error)

Jump to

Keyboard shortcuts

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