Documentation ¶
Overview ¶
Package spotify provides utilties for interfacing with Spotify's Web API.
Index ¶
- Constants
- type Album
- type Artist
- type AudioAnalysis
- type AudioFeatures
- type Device
- type Playlist
- type Profile
- type Query
- func (q Query) GetAlbumByName(input string) (Album, bool)
- func (q Query) GetAlbumByURI(uri string) (Album, bool)
- func (q Query) GetAlbumsByNames(names ...string) ([]Album, bool)
- func (q Query) GetAlbumsByURIs(uris ...string) ([]Album, bool)
- func (q Query) GetArtistByName(input string) (Artist, bool)
- func (q Query) GetArtistByURI(uri string) (Artist, bool)
- func (q Query) GetArtistsByNames(names ...string) ([]Artist, bool)
- func (q Query) GetArtistsByURIs(uris ...string) ([]Artist, bool)
- func (q Query) GetPlaylistByName(input string) (Playlist, bool)
- func (q Query) GetPlaylistByURI(uri string) (Playlist, bool)
- func (q Query) GetPlaylistsByNames(names ...string) ([]Playlist, bool)
- func (q Query) GetPlaylistsByURIs(uris ...string) ([]Playlist, bool)
- func (q Query) GetTrackByName(input string) (Track, bool)
- func (q Query) GetTrackByURI(uri string) (Track, bool)
- func (q Query) GetTracksByNames(names ...string) ([]Track, bool)
- func (q Query) GetTracksByURIs(uris ...string) ([]Track, bool)
- type Track
- type User
- func (u *User) ActiveDevice() (Device, bool)
- func (u *User) AddTrackToQueue(q Query, i interface{}) bool
- func (u *User) CurrentRepeatState() (string, bool)
- func (u *User) CurrentTrackProgress() (float64, bool)
- func (u *User) DoesFollowArtists(q Query, i ...interface{}) ([]bool, bool)
- func (u *User) FollowArtists(q Query, i ...interface{}) bool
- func (u *User) FollowUsers(q Query, i ...interface{}) bool
- func (u *User) GetCurrentProfile() (Profile, bool)
- func (u *User) GetCurrentlyPlayingTrack() (Track, bool)
- func (u *User) GetFollowedArtists(getAll bool, limit int) ([]Artist, bool)
- func (u *User) GetNumFollowedArtists() (int, bool)
- func (u *User) GetNumSavedAlbums() (int, bool)
- func (u *User) GetNumSavedPlaylists() (int, bool)
- func (u *User) GetNumSavedTracks() (int, bool)
- func (u *User) GetPlaybackDevices() ([]Device, bool)
- func (u *User) GetSavedAlbums(getAll bool, limit int) ([]Album, bool)
- func (u *User) GetSavedPlaylists(getAll bool, limit int) ([]Playlist, bool)
- func (u *User) GetSavedTracks(getAll bool, limit int) ([]Track, bool)
- func (u *User) GetScopes() []string
- func (u *User) GetTrackAudioAnalysis(q Query, i interface{}) (AudioAnalysis, bool)
- func (u *User) GetTrackAudioFeatures(q Query, i interface{}) (AudioFeatures, bool)
- func (u *User) HasSavedAlbums(q Query, i ...interface{}) ([]bool, bool)
- func (u *User) HasSavedTracks(q Query, i ...interface{}) ([]bool, bool)
- func (u *User) IsPlaying() (bool, bool)
- func (u *User) IsShuffling() (bool, bool)
- func (u *User) Pause() bool
- func (u *User) Play() bool
- func (u *User) SaveAlbums(q Query, i ...interface{}) bool
- func (u *User) SavePlaylists(q Query, i ...interface{}) bool
- func (u *User) SaveTracks(q Query, i ...interface{}) bool
- func (u *User) SeekToPosition(seconds float64) bool
- func (u *User) SetRepeat(on bool, track bool) bool
- func (u *User) SetShuffle(on bool) bool
- func (u *User) SetVolume(vol int) bool
- func (u *User) SkipToNext() bool
- func (u *User) SkipToPrev() bool
- func (u *User) TransferPlayback(device interface{}, play bool) bool
- func (u *User) UnfollowArtists(q Query, i ...interface{}) bool
- func (u *User) UnfollowUsers(q Query, i ...interface{}) bool
- func (u *User) UnsaveAlbums(q Query, i ...interface{}) bool
- func (u *User) UnsavePlaylists(q Query, i ...interface{}) bool
- func (u *User) UnsaveTracks(q Query, i ...interface{}) bool
Constants ¶
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/
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) GetNumFollowers ¶
Get Artist's Number of Followers
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 ¶
Get all Artist URIs for Playlist
func (*Playlist) GetNumFollowers ¶
Get number of Playlist followers
func (*Playlist) GetTrackURIs ¶
Get all Track URIs for Playlist
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 ¶
Get a user's Display Name 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 (Query) GetAlbumByName ¶
Get Album by name input is a string search query as described in the search function
func (Query) GetAlbumByURI ¶
Get Album by URI
func (Query) GetAlbumsByNames ¶
Get multiple Albums by names
func (Query) GetAlbumsByURIs ¶
Get multiple Albums by URIs
func (Query) GetArtistByName ¶
Get Artist by name input is a string search query as described in the search function
func (Query) GetArtistByURI ¶
Get Artist by URI
func (Query) GetArtistsByNames ¶
Get multiple Artists by names
func (Query) GetArtistsByURIs ¶
Get multiple Artists by URIs
func (Query) GetPlaylistByName ¶
Get Playlist by name input is a string search query as described in the search function
func (Query) GetPlaylistByURI ¶
Get Playlist by URI
func (Query) GetPlaylistsByNames ¶
Get multiple Playlists by names
func (Query) GetPlaylistsByURIs ¶
Get multiple Playlists by URIs
func (Query) GetTrackByName ¶
Get Track by name input is a string search query as described in the search function
func (Query) GetTrackByURI ¶
Get Track by URI
func (Query) GetTracksByNames ¶
Get multiple Tracks by names
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) GetArtistURIs ¶
Get all Artist URIs for Track
func (*Track) GetDurationMs ¶
Get Track Duration in milliseconds
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 ¶
Create and authenticate new User Defaults to using all (relevant) scopes if none are declared
func (*User) ActiveDevice ¶
Return User's active Device
func (*User) AddTrackToQueue ¶
Add track to User's Queue
func (*User) CurrentRepeatState ¶
Return User's current repeat state
func (*User) CurrentTrackProgress ¶
Return User's current location in their currently playing track in seconds
func (*User) DoesFollowArtists ¶
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 ¶
Follow Artists for User
func (*User) FollowUsers ¶
Follow Users for User
func (*User) GetCurrentProfile ¶
func (*User) GetCurrentlyPlayingTrack ¶
Return User's currently playing track
func (*User) GetFollowedArtists ¶
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 (*User) GetNumSavedAlbums ¶
func (*User) GetNumSavedPlaylists ¶
func (*User) GetNumSavedTracks ¶
Get the number of tracks a User has saved
func (*User) GetPlaybackDevices ¶
Return a user's available playback devices
func (*User) GetSavedAlbums ¶
Get a User's Saved Albums limit sets the number of albums to return If getAll is true, limit is disregarded
func (*User) GetSavedPlaylists ¶
Get a User's Saved Playlists limit sets the number of playlists to return If getAll is true, limit is disregarded
func (*User) GetSavedTracks ¶
Get a User's Saved Tracks limit sets the number of tracks to return If getAll is true, limit is disregarded
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 ¶
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 ¶
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) IsShuffling ¶
Return whether a user is in shuffle mode or not
func (*User) SaveAlbums ¶
Save Albums for User
func (*User) SavePlaylists ¶
Save Playlists for User
func (*User) SaveTracks ¶
Save tracks for User
func (*User) SeekToPosition ¶
Move to specific position in a song (by seconds)
func (*User) SetRepeat ¶
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) SetVolume ¶
Set User's Spotify volume vol = the volume to set (should be a value from 0 to 100 inclusive)
func (*User) TransferPlayback ¶
Transfer playback between devices
func (*User) UnfollowArtists ¶
Unfollow Artists for User
func (*User) UnfollowUsers ¶
Unfollow Users for User
func (*User) UnsaveAlbums ¶
Unsave Albums for User
func (*User) UnsavePlaylists ¶
Unsave Playlists for User
func (*User) UnsaveTracks ¶
Unsave tracks for User