spotify

package
v0.0.0-...-56d3c23 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: GPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSpotifyClient

func InitSpotifyClient(ctx context.Context)

Types

type Album

type Album struct {
	ReleaseDatePrecision string      `json:"release_date_precision"`
	ExternalUrls         ExternalURL `json:"external_urls"`
	Href                 string      `json:"href"`
	ID                   string      `json:"id"`
	Name                 string      `json:"name"`
	ReleaseDate          string      `json:"release_date"`
	AlbumType            string      `json:"album_type"`
	Type                 string      `json:"type"`
	URI                  string      `json:"uri"`
	Artists              []Artist    `json:"artists"`
	AvailableMarkets     []string    `json:"available_markets"`
	Images               []Image     `json:"images"`
	TotalTracks          int         `json:"total_tracks"`
}

type AlbumItem

type AlbumItem struct {
	ReleaseDatePrecision string      `json:"release_date_precision"`
	ExternalURLs         ExternalURL `json:"external_urls"`
	Href                 string      `json:"href"`
	ID                   string      `json:"id"`
	Name                 string      `json:"name"`
	ReleaseDate          string      `json:"release_date"`
	AlbumType            string      `json:"album_type"`
	Type                 string      `json:"type"`
	URI                  string      `json:"uri"`
	Artists              []Artist    `json:"artists"`
	Images               []Image     `json:"images"`
	TotalTracks          int         `json:"total_tracks"`
	IsPlayable           bool        `json:"is_playable"`
}

type AlbumResponse

type AlbumResponse struct {
	SearchResult SearchResult[AlbumItem] `json:"albums"`
}

type Artist

type Artist struct {
	ExternalUrls ExternalURL `json:"external_urls"`
	Href         string      `json:"href"`
	ID           string      `json:"id"`
	Name         string      `json:"name"`
	Type         string      `json:"type"`
	URI          string      `json:"uri"`
}

type ExternalID

type ExternalID struct {
	ISRC string `json:"isrc"`
}

type ExternalURL

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

type Image

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

type SearchResult

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

type SpotifyAuthResponse

type SpotifyAuthResponse struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int    `json:"expires_in"` // seconds
}

type SpotifyClient

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

func GetSpotifyClient

func GetSpotifyClient() (*SpotifyClient, error)

func (*SpotifyClient) GetAlbumInfo

func (c *SpotifyClient) GetAlbumInfo(
	ctx context.Context,
	albumName string,
	artistName string,
) (clients.AlbumInfo, error)

func (*SpotifyClient) GetTrackInfo

func (c *SpotifyClient) GetTrackInfo(
	ctx context.Context,
	trackName string,
	artistName string,
) (clients.TrackInfo, error)

type Token

type Token struct {
	AccessToken string

	ExpiresIn int
	// contains filtered or unexported fields
}

func (*Token) KeepAlive

func (t *Token) KeepAlive(ctx context.Context)

func (*Token) Refresh

func (t *Token) Refresh() error

type TrackItem

type TrackItem struct {
	Album            Album       `json:"album"`
	Name             string      `json:"name"`
	URI              string      `json:"uri"`
	Type             string      `json:"type"`
	ExternalIds      ExternalID  `json:"external_ids"`
	ExternalUrls     ExternalURL `json:"external_urls"`
	Href             string      `json:"href"`
	ID               string      `json:"id"`
	PreviewURL       string      `json:"preview_url"`
	Artists          []Artist    `json:"artists"`
	AvailableMarkets []string    `json:"available_markets"`
	DurationMs       int         `json:"duration_ms"`
	Popularity       int         `json:"popularity"`
	TrackNumber      int         `json:"track_number"`
	DiscNumber       int         `json:"disc_number"`
	IsLocal          bool        `json:"is_local"`
	Explicit         bool        `json:"explicit"`
}

type TracksResponse

type TracksResponse struct {
	SearchResult SearchResult[TrackItem] `json:"tracks"`
}

Jump to

Keyboard shortcuts

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