spotigo

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 15 Imported by: 0

README

Spotigo - COS 316 Final Project

By Adam Gamba and Adam Ziff

This project implements a Go wrapper for the Spotify API to make it as simple as possible for developers to access this robust API in Go while preserving all of the powerful functionality it enables. Our primary goal was to abstract away as much complexity as possible to enable developers to get up and running with the API as quickly as possible, while simultaneously giving developers the ability to seamlessly access as much of the API’s powerful functionality as possible.

Authentication

There are two distinct sets of API calls in the Spotify API: those that require a user to log in to their account, and those that do not. These different sets of API calls require different authentication paths, but we have simplified these processes to one line of code each.

To create a Query struct (not requiring browser authentication), one would call:

client := "API client key..."
secret := "API secret key..."
query, ok := spotigo.NewUser(client, secret)

Creating a Query struct with the newQuery(client, secret string) method performs the necessary authentication to enable the developer to access all endpoints that don’t require this login flow.

Similarly, to create a User struct (requiring browser authentication), one would call:

client := "API client key..."
secret := "API secret key..."
user, ok := spotigo.NewUser(client, secret)

Creating a User struct with the newUser(client, secret string) method prompts the user to login to their account; once they have done so, the developer can then use this struct to access all API calls implemented that require this user-level authentication.

URI Abstraction

Each of these structs are created in one line of code, providing the developer’s application Client Key and Secret Key (as created in the Spotify Developer Dashboard); this format builds on the existing Go Spotify API wrappers to further simplify the authentication process and improve ease of use for developers. One other important element we sought to abstract away from developers were URIs. URIs are Spotify’s unique IDs for any piece of content on its platform: songs, artists, albums, etc. Existing libraries only enable developers to get these pieces of content from the API by URI; however, we leveraged Spotify’s powerful general search endpoint to enable developers to search for any type of content in a plain text query as well. Notably, the implicit assumption of these functions is that the user provides enough information in the search query string and that Spotify’s search algorithm finds the element they’re looking for; without the precision of the exact URI, we rely on the accuracy of this search engine in our results.

Functionality

With the Query struct, developers can search for albums, artists, tracks, and playlists, all of which can be accessed either by their URI or through a plain text search query. We’ve created structs for the return values of each of these endpoints: the Album, Artist, Track, and Playlist structs exactly correspond to the JSON data returned by the API. We have implemented a few Get methods for each struct to simplify access to what we believe to be the most important and frequently accessed fields, while simultaneously exporting every field of the struct so that developers are free to access any field they need for their application. With the User struct, developers have access to a few distinct sets of functionality. They can control playback from a user’s account; this includes features like playing and pausing music, adding tracks to the queue, switching playback between devices, and more. They can get and set information on a user’s profile; this includes getting a list of saved tracks, albums, or playlists, saving or unsaving any of these elements, and following or unfollowing artists. Finally, they can access all of the detailed information that Spotify saves for a given track through the audio-analysis and audio-features endpoints.

Safety

An important final note to add: through all these design decisions, we sought to prioritize safety and code security. We made intentional design choices around which fields and methods should be exported, trying to balance code security with maximizing the amount of flexibility developers have. This is most apparent in the User.go, where the User struct is exported but none of its fields are, and only a few methods are exported.

Outcome

For this project, we feel that we were able to successfully build a robust wrapper for the Spotify API to enable applications developers to access this API in a simple and effective manner in Go. We implemented a significant subset of the API’s functionality, choosing to focus on the music-related functionality as deeply as possible. Future work for this project would be to implement the rest of the API’s endpoints in methods in our library, which would entail delving into the podcast-related functionality that the API offers in addition to the music-focused endpoints. Barring unforeseen errors that our tests have not caught, we are confident that our library works and is sufficiently documented for other developers to start building with Spotigo.

Documentation

Overview

Package spotify provides utilties for interfacing with Spotify's Web API.

Index

Constants

View Source
const (
	// ScopeImageUpload seeks permission to upload images to Spotify on your behalf.
	ScopeImageUpload = "ugc-image-upload"
	// ScopePlaylistReadPrivate seeks permission to read
	// a user's private playlists.
	ScopePlaylistReadPrivate = "playlist-read-private"
	// ScopePlaylistModifyPublic seeks write access
	// to a user's public playlists.
	ScopePlaylistModifyPublic = "playlist-modify-public"
	// ScopePlaylistModifyPrivate seeks write access to
	// a user's private playlists.
	ScopePlaylistModifyPrivate = "playlist-modify-private"
	// ScopePlaylistReadCollaborative seeks permission to
	// access a user's collaborative playlists.
	ScopePlaylistReadCollaborative = "playlist-read-collaborative"
	// ScopeUserFollowModify seeks write/delete access to
	// the list of artists and other users that a user follows.
	ScopeUserFollowModify = "user-follow-modify"
	// ScopeUserFollowRead seeks read access to the list of
	// artists and other users that a user follows.
	ScopeUserFollowRead = "user-follow-read"
	// ScopeUserLibraryModify seeks write/delete access to a
	// user's "Your Music" library.
	ScopeUserLibraryModify = "user-library-modify"
	// ScopeUserLibraryRead seeks read access to a user's "Your Music" library.
	ScopeUserLibraryRead = "user-library-read"
	// ScopeUserReadPrivate seeks read access to a user's
	// subsription details (type of user account).
	ScopeUserReadPrivate = "user-read-private"
	// ScopeUserReadEmail seeks read access to a user's email address.
	ScopeUserReadEmail = "user-read-email"
	// ScopeUserReadCurrentlyPlaying seeks read access to a user's currently playing track
	ScopeUserReadCurrentlyPlaying = "user-read-currently-playing"
	// ScopeUserReadPlaybackState seeks read access to the user's current playback state
	ScopeUserReadPlaybackState = "user-read-playback-state"
	// ScopeUserModifyPlaybackState seeks write access to the user's current playback state
	ScopeUserModifyPlaybackState = "user-modify-playback-state"
	// ScopeUserReadRecentlyPlayed allows access to a user's recently-played songs
	ScopeUserReadRecentlyPlayed = "user-read-recently-played"
	// ScopeUserTopRead seeks read access to a user's top tracks and artists
	ScopeUserTopRead = "user-top-read"
	// ScopeStreaming seeks permission to play music and control playback on your other devices.
	ScopeStreaming = "streaming"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Album

type Album struct {
	AlbumType string `json:"album_type"`
	Artists   []struct {
		ExternalUrls struct {
			Spotify string `json:"spotify"`
		} `json:"external_urls"`
		Href string `json:"href"`
		ID   string `json:"id"`
		Name string `json:"name"`
		Type string `json:"type"`
		URI  string `json:"uri"`
	} `json:"artists"`
	AvailableMarkets []string `json:"available_markets"`
	Copyrights       []struct {
		Text string `json:"text"`
		Type string `json:"type"`
	} `json:"copyrights"`
	ExternalIds struct {
		Upc string `json:"upc"`
	} `json:"external_ids"`
	ExternalUrls struct {
		Spotify string `json:"spotify"`
	} `json:"external_urls"`
	Genres []interface{} `json:"genres"`
	Href   string        `json:"href"`
	ID     string        `json:"id"`
	Images []struct {
		Height int    `json:"height"`
		URL    string `json:"url"`
		Width  int    `json:"width"`
	} `json:"images"`
	Label                string `json:"label"`
	Name                 string `json:"name"`
	Popularity           int    `json:"popularity"`
	ReleaseDate          string `json:"release_date"`
	ReleaseDatePrecision string `json:"release_date_precision"`
	TotalTracks          int    `json:"total_tracks"`
	Tracks               struct {
		Href  string `json:"href"`
		Items []struct {
			Artists []struct {
				ExternalUrls struct {
					Spotify string `json:"spotify"`
				} `json:"external_urls"`
				Href string `json:"href"`
				ID   string `json:"id"`
				Name string `json:"name"`
				Type string `json:"type"`
				URI  string `json:"uri"`
			} `json:"artists"`
			AvailableMarkets []string `json:"available_markets"`
			DiscNumber       int      `json:"disc_number"`
			DurationMs       int      `json:"duration_ms"`
			Explicit         bool     `json:"explicit"`
			ExternalUrls     struct {
				Spotify string `json:"spotify"`
			} `json:"external_urls"`
			Href        string      `json:"href"`
			ID          string      `json:"id"`
			IsLocal     bool        `json:"is_local"`
			Name        string      `json:"name"`
			PreviewURL  interface{} `json:"preview_url"`
			TrackNumber int         `json:"track_number"`
			Type        string      `json:"type"`
			URI         string      `json:"uri"`
		} `json:"items"`
		Limit    int         `json:"limit"`
		Next     interface{} `json:"next"`
		Offset   int         `json:"offset"`
		Previous interface{} `json:"previous"`
		Total    int         `json:"total"`
	} `json:"tracks"`
	Type string `json:"type"`
	URI  string `json:"uri"`
}

Album struct- maps to Spotify JSON response format by tag `json: "var_name"` Struct generated by putting Spotify JSON data into JSON to Go struct generator at: https://mholt.github.io/json-to-go/

func (*Album) GetArtistURIs

func (a *Album) GetArtistURIs() []string

Get all Artist URIs on Album

func (*Album) GetName

func (a *Album) GetName() string

Get Album Name

func (*Album) GetTrackURIs

func (a *Album) GetTrackURIs() []string

Get all Track URIs on Album

func (*Album) GetURI

func (a *Album) GetURI() string

Get Album URI

type Artist

type Artist struct {
	ExternalUrls struct {
		Spotify string `json:"spotify"`
	} `json:"external_urls"`
	Followers struct {
		Href  interface{} `json:"href"`
		Total int         `json:"total"`
	} `json:"followers"`
	Genres []string `json:"genres"`
	Href   string   `json:"href"`
	ID     string   `json:"id"`
	Images []struct {
		Height int    `json:"height"`
		URL    string `json:"url"`
		Width  int    `json:"width"`
	} `json:"images"`
	Name       string `json:"name"`
	Popularity int    `json:"popularity"`
	Type       string `json:"type"`
	URI        string `json:"uri"`
}

Artist struct- maps to Spotify JSON response format by tag `json: "var_name"` Struct generated by putting Spotify JSON data into JSON to Go struct generator at: https://mholt.github.io/json-to-go/

func (*Artist) GetName

func (a *Artist) GetName() string

Get Artist Name

func (*Artist) GetNumFollowers

func (a *Artist) GetNumFollowers() int

Get Artist's Number of Followers

func (*Artist) GetURI

func (a *Artist) GetURI() string

Get Artist URI

type AudioAnalysis

type AudioAnalysis struct {
	Meta struct {
		AnalyzerVersion string  `json:"analyzer_version"`
		Platform        string  `json:"platform"`
		DetailedStatus  string  `json:"detailed_status"`
		StatusCode      int     `json:"status_code"`
		Timestamp       int     `json:"timestamp"`
		AnalysisTime    float64 `json:"analysis_time"`
		InputProcess    string  `json:"input_process"`
	} `json:"meta"`
	Track struct {
		NumSamples              int     `json:"num_samples"`
		Duration                float64 `json:"duration"`
		SampleMd5               string  `json:"sample_md5"`
		OffsetSeconds           int     `json:"offset_seconds"`
		WindowSeconds           int     `json:"window_seconds"`
		AnalysisSampleRate      int     `json:"analysis_sample_rate"`
		AnalysisChannels        int     `json:"analysis_channels"`
		EndOfFadeIn             float64 `json:"end_of_fade_in"`
		StartOfFadeOut          float64 `json:"start_of_fade_out"`
		Loudness                float64 `json:"loudness"`
		Tempo                   float64 `json:"tempo"`
		TempoConfidence         float64 `json:"tempo_confidence"`
		TimeSignature           int     `json:"time_signature"`
		TimeSignatureConfidence float64 `json:"time_signature_confidence"`
		Key                     int     `json:"key"`
		KeyConfidence           float64 `json:"key_confidence"`
		Mode                    int     `json:"mode"`
		ModeConfidence          float64 `json:"mode_confidence"`
		Codestring              string  `json:"codestring"`
		CodeVersion             float64 `json:"code_version"`
		Echoprintstring         string  `json:"echoprintstring"`
		EchoprintVersion        float64 `json:"echoprint_version"`
		Synchstring             string  `json:"synchstring"`
		SynchVersion            float64 `json:"synch_version"`
		Rhythmstring            string  `json:"rhythmstring"`
		RhythmVersion           float64 `json:"rhythm_version"`
	} `json:"track"`
	Bars []struct {
		Start      float64 `json:"start"`
		Duration   float64 `json:"duration"`
		Confidence float64 `json:"confidence"`
	} `json:"bars"`
	Beats []struct {
		Start      float64 `json:"start"`
		Duration   float64 `json:"duration"`
		Confidence float64 `json:"confidence"`
	} `json:"beats"`
	Sections []struct {
		Start                   float64 `json:"start"`
		Duration                float64 `json:"duration"`
		Confidence              float64 `json:"confidence"`
		Loudness                float64 `json:"loudness"`
		Tempo                   float64 `json:"tempo"`
		TempoConfidence         float64 `json:"tempo_confidence"`
		Key                     int     `json:"key"`
		KeyConfidence           float64 `json:"key_confidence"`
		Mode                    int     `json:"mode"`
		ModeConfidence          float64 `json:"mode_confidence"`
		TimeSignature           int     `json:"time_signature"`
		TimeSignatureConfidence float64 `json:"time_signature_confidence"`
	} `json:"sections"`
	Segments []struct {
		Start           float64   `json:"start"`
		Duration        float64   `json:"duration"`
		Confidence      float64   `json:"confidence"`
		LoudnessStart   float64   `json:"loudness_start"`
		LoudnessMaxTime float64   `json:"loudness_max_time"`
		LoudnessMax     float64   `json:"loudness_max"`
		LoudnessEnd     float64   `json:"loudness_end"`
		Pitches         []float64 `json:"pitches"`
		Timbre          []float64 `json:"timbre"`
	} `json:"segments"`
	Tatums []struct {
		Start      float64 `json:"start"`
		Duration   float64 `json:"duration"`
		Confidence float64 `json:"confidence"`
	} `json:"tatums"`
}

Audio Analysis struct- maps to Spotify JSON response format by tag `json: "var_name"` Struct generated by putting Spotify JSON data into JSON to Go struct generator at: https://mholt.github.io/json-to-go/

type AudioFeatures

type AudioFeatures struct {
	Danceability     float64 `json:"danceability"`
	Energy           float64 `json:"energy"`
	Key              int     `json:"key"`
	Loudness         float64 `json:"loudness"`
	Mode             int     `json:"mode"`
	Speechiness      float64 `json:"speechiness"`
	Acousticness     float64 `json:"acousticness"`
	Instrumentalness float64 `json:"instrumentalness"`
	Liveness         float64 `json:"liveness"`
	Valence          float64 `json:"valence"`
	Tempo            float64 `json:"tempo"`
	Type             string  `json:"type"`
	ID               string  `json:"id"`
	URI              string  `json:"uri"`
	TrackHref        string  `json:"track_href"`
	AnalysisURL      string  `json:"analysis_url"`
	DurationMs       int     `json:"duration_ms"`
	TimeSignature    int     `json:"time_signature"`
}

Audio Features struct- maps to Spotify JSON response format by tag `json: "var_name"` Struct generated by putting Spotify JSON data into JSON to Go struct generator at: https://mholt.github.io/json-to-go/

type Device

type Device struct {
	// ID of the device. This may be empty.
	ID string `json:"id"`
	// Active If this device is the currently active device.
	Active bool `json:"is_active"`
	// Restricted Whether controlling this device is restricted. At present if
	// this is "true" then no Web API commands will be accepted by this device.
	Restricted bool `json:"is_restricted"`
	// Name The name of the device.
	Name string `json:"name"`
	// Type of device, such as "Computer", "Smartphone" or "Speaker".
	Type string `json:"type"`
	// Volume The current volume in percent.
	Volume int `json:"volume_percent"`
}

Device contains information about a device that a user can play music on Source: https://github.com/zmb3/spotify/

type Playlist

type Playlist struct {
	Collaborative bool   `json:"collaborative"`
	Description   string `json:"description"`
	ExternalUrls  struct {
		Spotify string `json:"spotify"`
	} `json:"external_urls"`
	Followers struct {
		Href  interface{} `json:"href"`
		Total int         `json:"total"`
	} `json:"followers"`
	Href   string `json:"href"`
	ID     string `json:"id"`
	Images []struct {
		Height int    `json:"height"`
		URL    string `json:"url"`
		Width  int    `json:"width"`
	} `json:"images"`
	Name  string `json:"name"`
	Owner struct {
		DisplayName  string `json:"display_name"`
		ExternalUrls struct {
			Spotify string `json:"spotify"`
		} `json:"external_urls"`
		Href string `json:"href"`
		ID   string `json:"id"`
		Type string `json:"type"`
		URI  string `json:"uri"`
	} `json:"owner"`
	PrimaryColor interface{} `json:"primary_color"`
	Public       bool        `json:"public"`
	SnapshotID   string      `json:"snapshot_id"`
	Tracks       struct {
		Href  string `json:"href"`
		Items []struct {
			AddedAt time.Time `json:"added_at"`
			AddedBy struct {
				ExternalUrls struct {
					Spotify string `json:"spotify"`
				} `json:"external_urls"`
				Href string `json:"href"`
				ID   string `json:"id"`
				Type string `json:"type"`
				URI  string `json:"uri"`
			} `json:"added_by"`
			IsLocal        bool        `json:"is_local"`
			PrimaryColor   interface{} `json:"primary_color"`
			Track          Track       `json:"track"`
			VideoThumbnail struct {
				URL interface{} `json:"url"`
			} `json:"video_thumbnail"`
		} `json:"items"`
		Limit    int         `json:"limit"`
		Next     string      `json:"next"`
		Offset   int         `json:"offset"`
		Previous interface{} `json:"previous"`
		Total    int         `json:"total"`
	} `json:"tracks"`
	Type string `json:"type"`
	URI  string `json:"uri"`
}

Playlist struct- maps to Spotify JSON response format by tag `json: "var_name"` Struct generated by putting Spotify JSON data into JSON to Go struct generator at: https://mholt.github.io/json-to-go/

func (*Playlist) GetArtistURIs

func (p *Playlist) GetArtistURIs() []string

Get all Artist URIs for Playlist

func (*Playlist) GetName

func (p *Playlist) GetName() string

Get Playlist Name

func (*Playlist) GetNumFollowers

func (p *Playlist) GetNumFollowers() int

Get number of Playlist followers

func (*Playlist) GetTrackURIs

func (p *Playlist) GetTrackURIs(u User) []string

Get all Track URIs for Playlist

func (*Playlist) GetTracks

func (p *Playlist) GetTracks(u User) []Track

Get all Tracks on a Playlist

func (*Playlist) GetURI

func (p *Playlist) GetURI() string

Get Playlist URI

type Profile

type Profile struct {
	Country         string `json:"country"`
	DisplayName     string `json:"display_name"`
	Email           string `json:"email"`
	ExplicitContent struct {
		FilterEnabled bool `json:"filter_enabled"`
		FilterLocked  bool `json:"filter_locked"`
	} `json:"explicit_content"`
	ExternalUrls struct {
		Spotify string `json:"spotify"`
	} `json:"external_urls"`
	Followers struct {
		Href  string `json:"href"`
		Total int    `json:"total"`
	} `json:"followers"`
	Href   string `json:"href"`
	ID     string `json:"id"`
	Images []struct {
		URL    string `json:"url"`
		Height int    `json:"height"`
		Width  int    `json:"width"`
	} `json:"images"`
	Product string `json:"product"`
	Type    string `json:"type"`
	URI     string `json:"uri"`
}

Profile struct- maps to Spotify JSON response format by tag `json: "var_name"` Struct generated by putting Spotify JSON data into JSON to Go struct generator at: https://mholt.github.io/json-to-go/

func (*Profile) GetDisplayName

func (p *Profile) GetDisplayName() string

Get a user's Display Name from their Profile

func (*Profile) GetID

func (p *Profile) GetID() string

Get a user's Profile ID from their Profile

type Query

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

Query struct- stores developer's client and secret IDs and their API access token

func NewQuery

func NewQuery(client string, secret string) (Query, error)

Constructor- create a new Query

func (Query) GetAlbumByName

func (q Query) GetAlbumByName(input string) (Album, bool)

Get Album by name input is a string search query as described in the search function

func (Query) GetAlbumByURI

func (q Query) GetAlbumByURI(uri string) (Album, bool)

Get Album by URI

func (Query) GetAlbumsByNames

func (q Query) GetAlbumsByNames(names ...string) ([]Album, bool)

Get multiple Albums by names

func (Query) GetAlbumsByURIs

func (q Query) GetAlbumsByURIs(uris ...string) ([]Album, bool)

Get multiple Albums by URIs

func (Query) GetArtistByName

func (q Query) GetArtistByName(input string) (Artist, bool)

Get Artist by name input is a string search query as described in the search function

func (Query) GetArtistByURI

func (q Query) GetArtistByURI(uri string) (Artist, bool)

Get Artist by URI

func (Query) GetArtistsByNames

func (q Query) GetArtistsByNames(names ...string) ([]Artist, bool)

Get multiple Artists by names

func (Query) GetArtistsByURIs

func (q Query) GetArtistsByURIs(uris ...string) ([]Artist, bool)

Get multiple Artists by URIs

func (Query) GetPlaylistByName

func (q Query) GetPlaylistByName(input string) (Playlist, bool)

Get Playlist by name input is a string search query as described in the search function

func (Query) GetPlaylistByURI

func (q Query) GetPlaylistByURI(uri string) (Playlist, bool)

Get Playlist by URI

func (Query) GetPlaylistsByNames

func (q Query) GetPlaylistsByNames(names ...string) ([]Playlist, bool)

Get multiple Playlists by names

func (Query) GetPlaylistsByURIs

func (q Query) GetPlaylistsByURIs(uris ...string) ([]Playlist, bool)

Get multiple Playlists by URIs

func (Query) GetTrackByName

func (q Query) GetTrackByName(input string) (Track, bool)

Get Track by name input is a string search query as described in the search function

func (Query) GetTrackByURI

func (q Query) GetTrackByURI(uri string) (Track, bool)

Get Track by URI

func (Query) GetTracksByNames

func (q Query) GetTracksByNames(names ...string) ([]Track, bool)

Get multiple Tracks by names

func (Query) GetTracksByURIs

func (q Query) GetTracksByURIs(uris ...string) ([]Track, bool)

Get multiple Tracks by URIs

type Track

type Track struct {
	Album struct {
		AlbumType string `json:"album_type"`
		Artists   []struct {
			ExternalUrls struct {
				Spotify string `json:"spotify"`
			} `json:"external_urls"`
			Href string `json:"href"`
			ID   string `json:"id"`
			Name string `json:"name"`
			Type string `json:"type"`
			URI  string `json:"uri"`
		} `json:"artists"`
		AvailableMarkets []string `json:"available_markets"`
		ExternalUrls     struct {
			Spotify string `json:"spotify"`
		} `json:"external_urls"`
		Href   string `json:"href"`
		ID     string `json:"id"`
		Images []struct {
			Height int    `json:"height"`
			URL    string `json:"url"`
			Width  int    `json:"width"`
		} `json:"images"`
		Name                 string `json:"name"`
		ReleaseDate          string `json:"release_date"`
		ReleaseDatePrecision string `json:"release_date_precision"`
		TotalTracks          int    `json:"total_tracks"`
		Type                 string `json:"type"`
		URI                  string `json:"uri"`
	} `json:"album"`
	Artists []struct {
		ExternalUrls struct {
			Spotify string `json:"spotify"`
		} `json:"external_urls"`
		Href string `json:"href"`
		ID   string `json:"id"`
		Name string `json:"name"`
		Type string `json:"type"`
		URI  string `json:"uri"`
	} `json:"artists"`
	AvailableMarkets []string `json:"available_markets"`
	DiscNumber       int      `json:"disc_number"`
	DurationMs       int      `json:"duration_ms"`
	Explicit         bool     `json:"explicit"`
	ExternalIds      struct {
		Isrc string `json:"isrc"`
	} `json:"external_ids"`
	ExternalUrls struct {
		Spotify string `json:"spotify"`
	} `json:"external_urls"`
	Href        string `json:"href"`
	ID          string `json:"id"`
	IsLocal     bool   `json:"is_local"`
	Name        string `json:"name"`
	Popularity  int    `json:"popularity"`
	PreviewURL  string `json:"preview_url"`
	TrackNumber int    `json:"track_number"`
	Type        string `json:"type"`
	URI         string `json:"uri"`
}

Track struct- maps to Spotify JSON response format by tag `json: "var_name"` Struct generated by putting Spotify JSON data into JSON to Go struct generator at: https://mholt.github.io/json-to-go/

func (*Track) GetAlbumName

func (t *Track) GetAlbumName() string

Get Album Name forTrack

func (*Track) GetAlbumURI

func (t *Track) GetAlbumURI() string

Get Album URI for Track

func (*Track) GetArtistURIs

func (t *Track) GetArtistURIs() []string

Get all Artist URIs for Track

func (*Track) GetDurationMs

func (t *Track) GetDurationMs() int

Get Track Duration in milliseconds

func (*Track) GetName

func (t *Track) GetName() string

Get Track Name

func (*Track) GetURI

func (t *Track) GetURI() string

Get Track URI

type User

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

User struct- used for making queries that require authentication access to a User's account

func NewUser

func NewUser(client_key, secret_key string, scopes ...string) (*User, bool)

Create and authenticate new User Defaults to using all (relevant) scopes if none are declared

func (*User) ActiveDevice

func (u *User) ActiveDevice() (Device, bool)

Return User's active Device

func (*User) AddTrackToQueue

func (u *User) AddTrackToQueue(q Query, i interface{}) bool

Add track to User's Queue

func (*User) CurrentRepeatState

func (u *User) CurrentRepeatState() (string, bool)

Return User's current repeat state

func (*User) CurrentTrackProgress

func (u *User) CurrentTrackProgress() (float64, bool)

Return User's current location in their currently playing track in seconds

func (*User) DoesFollowArtists

func (u *User) DoesFollowArtists(q Query, i ...interface{}) ([]bool, bool)

Check if a User is following a set of artists Returns a list of booleans corresponding to whether that artist in the parameter list is followed by the User

func (*User) FollowArtists

func (u *User) FollowArtists(q Query, i ...interface{}) bool

Follow Artists for User

func (*User) FollowUsers

func (u *User) FollowUsers(q Query, i ...interface{}) bool

Follow Users for User

func (*User) GetCurrentProfile

func (u *User) GetCurrentProfile() (Profile, bool)

func (*User) GetCurrentlyPlayingTrack

func (u *User) GetCurrentlyPlayingTrack() (Track, bool)

Return User's currently playing track

func (*User) GetFollowedArtists

func (u *User) GetFollowedArtists(getAll bool, limit int) ([]Artist, bool)

Get a User's Saved Artists limit sets the number of artists to return If getAll is true, limit is disregarded

func (*User) GetNumFollowedArtists

func (u *User) GetNumFollowedArtists() (int, bool)

func (*User) GetNumSavedAlbums

func (u *User) GetNumSavedAlbums() (int, bool)

func (*User) GetNumSavedPlaylists

func (u *User) GetNumSavedPlaylists() (int, bool)

func (*User) GetNumSavedTracks

func (u *User) GetNumSavedTracks() (int, bool)

Get the number of tracks a User has saved

func (*User) GetPlaybackDevices

func (u *User) GetPlaybackDevices() ([]Device, bool)

Return a user's available playback devices

func (*User) GetSavedAlbums

func (u *User) GetSavedAlbums(getAll bool, limit int) ([]Album, bool)

Get a User's Saved Albums limit sets the number of albums to return If getAll is true, limit is disregarded

func (*User) GetSavedPlaylists

func (u *User) GetSavedPlaylists(getAll bool, limit int) ([]Playlist, bool)

Get a User's Saved Playlists limit sets the number of playlists to return If getAll is true, limit is disregarded

func (*User) GetSavedTracks

func (u *User) GetSavedTracks(getAll bool, limit int) ([]Track, bool)

Get a User's Saved Tracks limit sets the number of tracks to return If getAll is true, limit is disregarded

func (*User) GetScopes

func (u *User) GetScopes() []string

Get all scopes for a user See scopes.go for details on Scopes

func (*User) GetTrackAudioAnalysis

func (u *User) GetTrackAudioAnalysis(q Query, i interface{}) (AudioAnalysis, bool)

Get the audio analysis of a track Returned values include duration, number of samples, and loudness

func (*User) GetTrackAudioFeatures

func (u *User) GetTrackAudioFeatures(q Query, i interface{}) (AudioFeatures, bool)

Get audio features for a track Examples of audio features include Danceability, Energy, Valence

func (*User) HasSavedAlbums

func (u *User) HasSavedAlbums(q Query, i ...interface{}) ([]bool, bool)

Check if a User has saved a set of albums Returns a list of booleans corresponding to whether that album in the parameter list is followed by the User

func (*User) HasSavedTracks

func (u *User) HasSavedTracks(q Query, i ...interface{}) ([]bool, bool)

Check if a User has saved a set of tracks Returns a list of booleans corresponding to whether that track in the parameter list is followed by the User

func (*User) IsPlaying

func (u *User) IsPlaying() (bool, bool)

Return whether a user has music playing or not

func (*User) IsShuffling

func (u *User) IsShuffling() (bool, bool)

Return whether a user is in shuffle mode or not

func (*User) Pause

func (u *User) Pause() bool

Pause playback for a User

func (*User) Play

func (u *User) Play() bool

Continue playback for a User (i.e. press play)

func (*User) SaveAlbums

func (u *User) SaveAlbums(q Query, i ...interface{}) bool

Save Albums for User

func (*User) SavePlaylists

func (u *User) SavePlaylists(q Query, i ...interface{}) bool

Save Playlists for User

func (*User) SaveTracks

func (u *User) SaveTracks(q Query, i ...interface{}) bool

Save tracks for User

func (*User) SeekToPosition

func (u *User) SeekToPosition(seconds float64) bool

Move to specific position in a song (by seconds)

func (*User) SetRepeat

func (u *User) SetRepeat(on bool, track bool) bool

Set User's repeat mode On boolean determines if repeat mode should be on or off Track boolean repeats track if true, repeats context (album, playlist, etc) if false

func (*User) SetShuffle

func (u *User) SetShuffle(on bool) bool

Set shuffle mode for User

func (*User) SetVolume

func (u *User) SetVolume(vol int) bool

Set User's Spotify volume vol = the volume to set (should be a value from 0 to 100 inclusive)

func (*User) SkipToNext

func (u *User) SkipToNext() bool

Skip forward 1 track

func (*User) SkipToPrev

func (u *User) SkipToPrev() bool

Skip backwards 1 track

func (*User) TransferPlayback

func (u *User) TransferPlayback(device interface{}, play bool) bool

Transfer playback between devices

func (*User) UnfollowArtists

func (u *User) UnfollowArtists(q Query, i ...interface{}) bool

Unfollow Artists for User

func (*User) UnfollowUsers

func (u *User) UnfollowUsers(q Query, i ...interface{}) bool

Unfollow Users for User

func (*User) UnsaveAlbums

func (u *User) UnsaveAlbums(q Query, i ...interface{}) bool

Unsave Albums for User

func (*User) UnsavePlaylists

func (u *User) UnsavePlaylists(q Query, i ...interface{}) bool

Unsave Playlists for User

func (*User) UnsaveTracks

func (u *User) UnsaveTracks(q Query, i ...interface{}) bool

Unsave tracks for User

Jump to

Keyboard shortcuts

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