spotify

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package spotify contains an implementation of the spotify service.

Index

Constants

View Source
const ErrInvalidID = "Invalid playlist Id"

ErrInvalidID is the error for an invalid playlist id

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	spotify.Client
	Auth              spotify.Authenticator
	AuthURL           string
	Session           string
	AuthChan          chan bool
	MusicChan         chan Music
	Spotify           spotify.Client
	SubredditPlaylist map[string]spotify.ID
	User              *spotify.PrivateUser
	Logger            *log.Entry
}

Client is the spotify client

func New

func New(cfg *config.Config) (*Client, error)

New sets up a new spotify client. It takes the configuration and returns a client or an error.

func (*Client) AuthHandler

func (c *Client) AuthHandler() http.HandlerFunc

AuthHandler is a simple http handler for the authentication callback.

func (*Client) Authenticate

func (c *Client) Authenticate(openBrowser bool) error

Authenticate handles the authentication against the Spotify API. It either opens the browser or tells the user to navigate to a URL. It will also block until authentication is done.

func (*Client) Close

func (c *Client) Close()

Close properly closes the Spotify client

func (*Client) Listen

func (c *Client) Listen()

Listen listens for incoming data on the music channel.

func (*Client) PreparePlaylists

func (c *Client) PreparePlaylists(cfg *config.Config) error

PreparePlaylists checks the playlists defined in the config and fetches them from Spotify. If a playlist is passed by name, it's created if it doesn't exist. It also connects the subreddits to a corresponding playlist id.

func (*Client) SetUser

func (c *Client) SetUser() error

SetUser fetches the authenticated users and sets it on the client.

type Music

type Music struct {
	Subreddit        string
	PostTitle        string
	MediaTitle       string
	SecureMediaTitle string
	URL              string
}

Music contains data about potential new music to add to a spotify list.

Jump to

Keyboard shortcuts

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