api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package api interacts with the spotify api

Index

Constants

This section is empty.

Variables

View Source
var ErrUnauthorized = errors.New("access and refresh token expired")

Functions

This section is empty.

Types

type Album

type Album struct {
	SpotifyID   string   `json:"id"`
	Name        string   `json:"name"`
	TrackAmount int      `json:"total_tracks"`
	Popularity  int      `json:"popularity"`
	Images      []Image  `json:"images"`
	Artists     []Artist `json:"artists"`
}

func (Album) ToModel

func (a Album) ToModel() model.Album

type Artist

type Artist struct {
	SpotifyID string `json:"id"`
	Name      string `json:"name"`
	Followers struct {
		Total int `json:"total"`
	} `json:"followers"`
	Popularity int     `json:"popularity"`
	Images     []Image `json:"images"`
}

func (Artist) ToModel

func (a Artist) ToModel() model.Artist

type Client

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

func New

func New() (*Client, error)

func (*Client) AlbumGet

func (c *Client) AlbumGet(ctx context.Context, user model.User, spotifyID string) (Album, error)

func (*Client) AlbumGetAll

func (c *Client) AlbumGetAll(ctx context.Context, user model.User, albumIDs []string) ([]Album, error)

func (*Client) AlbumGetTrackAll

func (c *Client) AlbumGetTrackAll(ctx context.Context, user model.User, spotifyID string) ([]Track, error)

func (*Client) AlbumGetUser

func (c *Client) AlbumGetUser(ctx context.Context, user model.User) ([]Album, error)

func (*Client) ArtistGet

func (c *Client) ArtistGet(ctx context.Context, user model.User, spotifyID string) (Artist, error)

func (*Client) ArtistGetAll

func (c *Client) ArtistGetAll(ctx context.Context, user model.User, artistIDs []string) ([]Artist, error)

func (*Client) ImageGet

func (c *Client) ImageGet(ctx context.Context, url string) ([]byte, error)

func (*Client) NewUser

func (c *Client) NewUser(ctx context.Context, user model.User, accessToken, refreshToken string, expiresIn time.Duration) error

func (*Client) PlayerGetCurrent

func (c *Client) PlayerGetCurrent(ctx context.Context, user model.User) (Current, error)

func (*Client) PlayerGetHistory

func (c *Client) PlayerGetHistory(ctx context.Context, user model.User) ([]History, error)

func (*Client) PlaylistDeleteTrackAll

func (c *Client) PlaylistDeleteTrackAll(ctx context.Context, user model.User, spotifyID, snapshotID string, tracks []model.Track) error

func (*Client) PlaylistGet

func (c *Client) PlaylistGet(ctx context.Context, user model.User, spotifyID string) (Playlist, error)

func (*Client) PlaylistGetTrackAll

func (c *Client) PlaylistGetTrackAll(ctx context.Context, user model.User, spotifyID string) ([]Track, error)

func (*Client) PlaylistGetUser

func (c *Client) PlaylistGetUser(ctx context.Context, user model.User) ([]Playlist, error)

func (*Client) PlaylistPostTrackAll

func (c *Client) PlaylistPostTrackAll(ctx context.Context, user model.User, spotifyID string, tracks []model.Track) error

func (*Client) ShowGet

func (c *Client) ShowGet(ctx context.Context, user model.User, spotifyID string) (Show, error)

func (*Client) ShowGetAll

func (c *Client) ShowGetAll(ctx context.Context, user model.User, showsIDs []string) ([]Show, error)

func (*Client) ShowGetUser

func (c *Client) ShowGetUser(ctx context.Context, user model.User) ([]Show, error)

func (*Client) TrackGet

func (c *Client) TrackGet(ctx context.Context, user model.User, spotifyID string) (Track, error)

func (*Client) TrackGetAll

func (c *Client) TrackGetAll(ctx context.Context, user model.User, trackIDs []string) ([]Track, error)

func (*Client) UserGet

func (c *Client) UserGet(ctx context.Context, user, spotifyUser model.User) (model.User, error)

type Context

type Context struct {
	Type string `json:"type"`
	URI  string `json:"uri"`
}

type Current

type Current struct {
	Track      Track   `json:"item"`
	ProgressMs int     `json:"progress_ms"`
	IsPlaying  bool    `json:"is_playing"`
	Context    Context `json:"context"`
}

type History

type History struct {
	Track    Track     `json:"track"`
	PlayedAt time.Time `json:"played_at"`
	Context  Context   `json:"context"`
}

func (History) ToModel

func (h History) ToModel(user model.User) model.History

type Image

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

type Playlist

type Playlist struct {
	SpotifyID string `json:"id"`
	Owner     struct {
		UID         string `json:"id"`
		DisplayName string `json:"display_name"`
	} `json:"owner"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Public      bool   `json:"public"`
	Tracks      struct {
		Total int `json:"total"`
	} `json:"tracks"`
	Collaborative bool    `json:"collaborative"`
	Images        []Image `json:"images"`
	SnapshotID    string  `json:"snapshot_id"`
}

func (*Playlist) ToModel

func (p *Playlist) ToModel() model.Playlist

type Show

type Show struct {
	SpotifyID     string  `json:"id"`
	Name          string  `json:"name"`
	EpisodeAmount int     `json:"total_episodes"`
	Images        []Image `json:"images"`
}

func (Show) ToModel

func (s Show) ToModel() model.Show

type Track

type Track struct {
	SpotifyID  string   `json:"id"`
	Name       string   `json:"name"`
	Popularity int      `json:"popularity"`
	Artists    []Artist `json:"artists"`
	LinkedFrom struct {
		SpotifyID string `json:"id"`
	} `json:"linked_from"`
}

func (*Track) ToModel

func (t *Track) ToModel() model.Track

Jump to

Keyboard shortcuts

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