spotify

package
v0.0.0-...-95a56b9 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopePlaylistModifyPrivate   = scope("playlist-modify-private")
	ScopePlaylistModifyPublic    = scope("playlist-modify-public")
	ScopeUserReadPlaybackState   = scope("user-read-playback-state")
	ScopeUserModifyPlaybackState = scope("user-modify-playback-state")
	ScopeUserLibraryRead         = scope("user-library-read")
	ScopeUserReadRecentlyPlayed  = scope("user-read-recently-played")
	ScopeUserReadEmail           = scope("user-read-email")
	ScopeUserReadPrivate         = scope("user-read-private")
)
View Source
const (
	RepeatModeTrack   = repeatMode("track")
	RepeatModeContext = repeatMode("context")
	RepeatModeOff     = repeatMode("off")
)
View Source
const (
	ItemTypeTrack    = itemType("track")
	ItemTypeAlbum    = itemType("album")
	ItemTypePlaylist = itemType("playlist")
)

Variables

This section is empty.

Functions

func WithStrideSongsAccessToken

func WithStrideSongsAccessToken() requestConfigOption

Types

type AddTracksToPlaylistRequest

type AddTracksToPlaylistRequest struct {
	PlaylistID string
	Tracks     []Track
}

type AnalyzedTrack

type AnalyzedTrack struct {
	Track
	Tempo float64 `json:"tempo"`
}

type AuthResponse

type AuthResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	Scope        string `json:"scope"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

type Client

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

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

func (*Client) AddTracksToPlaylist

func (c *Client) AddTracksToPlaylist(ctx context.Context, inp AddTracksToPlaylistRequest, opts ...requestConfigOption) error

func (*Client) AnalyzedTracks

func (c *Client) AnalyzedTracks(ctx context.Context, tracks []Track) ([]AnalyzedTrack, error)

func (*Client) Auth

func (c *Client) Auth(ctx context.Context, authorizationCode string) (*AuthResponse, error)

func (*Client) CreatePlaylist

func (c *Client) CreatePlaylist(ctx context.Context, inp CreatePlaylistRequest, opts ...requestConfigOption) (*Playlist, error)

func (*Client) Me

func (c *Client) Me(ctx context.Context) (*User, error)

func (*Client) Play

func (c *Client) Play(ctx context.Context, inp PlayRequest, opts ...requestConfigOption) error

func (*Client) SetRepeatMode

func (c *Client) SetRepeatMode(ctx context.Context, mode repeatMode, opts ...requestConfigOption) error

func (*Client) ToggleShuffle

func (c *Client) ToggleShuffle(ctx context.Context, shuffle bool, opts ...requestConfigOption) error

func (*Client) WithStrideSongsAccessToken

func (c *Client) WithStrideSongsAccessToken(ctx context.Context) (context.Context, error)

note: at some point it may make more sense to have a goroutine that fetches a new access token whenever the previous access token expires, and use that kept-fresh access token for all requests across the Client.

func (*Client) WithUserAccessToken

func (c *Client) WithUserAccessToken(ctx context.Context, refreshToken string) (context.Context, error)

func (*Client) WithUserAccessTokenDirect

func (c *Client) WithUserAccessTokenDirect(ctx context.Context, accessToken string) (context.Context, error)

type ClientOption

type ClientOption func(c *Client)

func WithBaseAuthUrl

func WithBaseAuthUrl(baseAuthURL string) ClientOption

func WithBaseUrl

func WithBaseUrl(baseURL string) ClientOption

func WithClientID

func WithClientID(clientID string) ClientOption

func WithClientSecret

func WithClientSecret(clientSecret string) ClientOption

func WithRedirectURI

func WithRedirectURI(redirectURI string) ClientOption

func WithStrideSongsRefreshToken

func WithStrideSongsRefreshToken(refreshToken string) ClientOption

type CreatePlaylistRequest

type CreatePlaylistRequest struct {
	Name          string  `json:"name"`
	Public        bool    `json:"public"`
	Collaborative bool    `json:"collaborative"`
	Description   *string `json:"description"`
	UserID        string  `json:"-"`
}

type CurrentPlayback

type CurrentPlayback struct {
	IsPlaying    bool           `json:"is_playing"`
	ShuffleState bool           `json:"shuffle_state"`
	RepeatState  repeatMode     `json:"repeat_state"`
	Context      SpotifyContext `json:"context"`
}

type MockSpotify

type MockSpotify struct {
	Tracks []AnalyzedTrack
	Users  []mockUser
}

func NewMockSpotify

func NewMockSpotify() *MockSpotify

func (*MockSpotify) AddTracks

func (s *MockSpotify) AddTracks(tracks []AnalyzedTrack)

func (*MockSpotify) AddUser

func (s *MockSpotify) AddUser(userID string)

func (*MockSpotify) AddUserTracks

func (s *MockSpotify) AddUserTracks(userID string, trackIDs []string) error

func (*MockSpotify) Clear

func (s *MockSpotify) Clear()

func (*MockSpotify) Mux

func (s *MockSpotify) Mux() http.Handler

func (*MockSpotify) Track

func (s *MockSpotify) Track(trackID string) (*AnalyzedTrack, bool)

func (*MockSpotify) User

func (s *MockSpotify) User(userID string) (*mockUser, bool)

type PlayRequest

type PlayRequest struct {
	ItemType itemType
	ItemID   string
}

func (*PlayRequest) ToRequestPayload

func (p *PlayRequest) ToRequestPayload() *playRequest

type Playlist

type Playlist struct {
	ID   string `json:"id"`
	Name string `json:"string"`
}

type SpotifyContext

type SpotifyContext struct {
	URI string `json:"uri"`
}

type Track

type Track struct {
	ID string `json:"id"`
}

type User

type User struct {
	ID string `json:"id"`
}

Jump to

Keyboard shortcuts

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