spotify

package
v0.0.0-...-4679d7b Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	SpotifyClient(ctx context.Context, token *oauth2.Token, opts ...spotify.ClientOption) SpotifyClient
	AuthURL(state string, opts ...oauth2.AuthCodeOption) string
	Token(ctx context.Context, state string, r *http.Request, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
	Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
}

Authenticator is used to authenticate to spotify via oauth2 flow

type Client

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

func NewClient

func NewClient(ctx context.Context, token *oauth2.Token, auth Authenticator) (Client, error)

func (Client) AppendToPlaylist

func (c Client) AppendToPlaylist(ctx context.Context, playlistID string, artists []string) error

func (Client) CreatePlaylist

func (c Client) CreatePlaylist(ctx context.Context, name string, artists []string) (spotify.ID, error)

type DefaultAuthenticator

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

func NewDefaultAuthenticator

func NewDefaultAuthenticator(opts ...spotifyauth.AuthenticatorOption) *DefaultAuthenticator

func (*DefaultAuthenticator) AuthURL

func (a *DefaultAuthenticator) AuthURL(state string, opts ...oauth2.AuthCodeOption) string

func (*DefaultAuthenticator) Exchange

func (a *DefaultAuthenticator) Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)

Exchange implements Authenticator

func (*DefaultAuthenticator) SpotifyClient

func (a *DefaultAuthenticator) SpotifyClient(ctx context.Context, token *oauth2.Token, opts ...spotify.ClientOption) SpotifyClient

func (*DefaultAuthenticator) Token

Token implements Authenticator

type NoOpAuthenticator

type NoOpAuthenticator struct{}

func (*NoOpAuthenticator) AuthURL

func (*NoOpAuthenticator) AuthURL(state string, opts ...oauth2.AuthCodeOption) string

AuthURL implements Authenticator

func (*NoOpAuthenticator) Exchange

func (*NoOpAuthenticator) Exchange(ctx context.Context, code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)

Exchange implements Authenticator

func (*NoOpAuthenticator) SpotifyClient

func (*NoOpAuthenticator) SpotifyClient(ctx context.Context, token *oauth2.Token, opts ...spotify.ClientOption) SpotifyClient

SpotifyClient implements Authenticator

func (*NoOpAuthenticator) Token

Token implements Authenticator

type SpotifyClient

type SpotifyClient interface {
	CurrentUser(ctx context.Context) (*spotify.PrivateUser, error)
	Search(ctx context.Context, query string, t spotify.SearchType, opts ...spotify.RequestOption) (*spotify.SearchResult, error)
	GetAlbumTracks(ctx context.Context, id spotify.ID, opts ...spotify.RequestOption) (*spotify.SimpleTrackPage, error)
	CreatePlaylistForUser(ctx context.Context, userID string, playlistName string, description string, public bool, collaborative bool) (*spotify.FullPlaylist, error)
	AddTracksToPlaylist(ctx context.Context, playlistID spotify.ID, trackIDs ...spotify.ID) (snapshotID string, err error)
}

SpotifyClient is the interface to interact with spotify

Jump to

Keyboard shortcuts

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