spotify

package
v0.0.0-...-12dd11f Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2015 License: Apache-2.0 Imports: 14 Imported by: 7

Documentation

Overview

Package spotify adds language bindings for spotify in Go. The libspotify C API package allows third-party developers to write applications which utilize the Spotify music streaming service.

Index

Constants

View Source
const (
	// The library version targeted does not match the one you claim you
	// support
	ErrBadAPIVersion Error = Error(C.SP_ERROR_BAD_API_VERSION)

	// Initialization of library failed - are cache locations etc. valid?
	ErrAPIInitializationFailed = Error(C.SP_ERROR_API_INITIALIZATION_FAILED)

	// The track specified for playing cannot be played
	ErrTrackNotPlayable = Error(C.SP_ERROR_TRACK_NOT_PLAYABLE)

	// The application key is invalid
	ErrBadApplicationKey = Error(C.SP_ERROR_BAD_APPLICATION_KEY)

	// Login failed because of bad username and/or password
	ErrBadUsernameOrPassword = Error(C.SP_ERROR_BAD_USERNAME_OR_PASSWORD)

	// The specified username is banned
	ErrUserBanned = Error(C.SP_ERROR_USER_BANNED)

	// Cannot connect to the Spotify backend system
	ErrUnableToContactServer = Error(C.SP_ERROR_UNABLE_TO_CONTACT_SERVER)

	// Client is too old, library will need to be updated
	ErrClientTooOld = Error(C.SP_ERROR_CLIENT_TOO_OLD)

	// Some other error occurred, and it is permanent (e.g. trying to relogin
	// will not help)
	ErrOtherPermanent = Error(C.SP_ERROR_OTHER_PERMANENT)

	// The user agent string is invalid or too long
	ErrBadUserAgent = Error(C.SP_ERROR_BAD_USER_AGENT)

	// No valid callback registered to handle events
	ErrMissingCallback = Error(C.SP_ERROR_MISSING_CALLBACK)

	// Input data was either missing or invalid
	ErrInvalidIndata = Error(C.SP_ERROR_INVALID_INDATA)

	// Index out of range
	ErrIndexOutOfRange = Error(C.SP_ERROR_INDEX_OUT_OF_RANGE)

	// The specified user needs a premium account
	ErrUserNeedsPremium = Error(C.SP_ERROR_USER_NEEDS_PREMIUM)

	// A transient error occurred.
	ErrOtherTransient = Error(C.SP_ERROR_OTHER_TRANSIENT)

	// The resource is currently loading
	ErrIsLoading = Error(C.SP_ERROR_IS_LOADING)

	// Could not find any suitable stream to play
	ErrNoStreamAvailable = Error(C.SP_ERROR_NO_STREAM_AVAILABLE)

	// Requested operation is not allowed
	ErrPermissionDenied = Error(C.SP_ERROR_PERMISSION_DENIED)

	// Target inbox is full
	ErrInboxIsFull = Error(C.SP_ERROR_INBOX_IS_FULL)

	// Cache is not enabled
	ErrNoCache = Error(C.SP_ERROR_NO_CACHE)

	// Requested user does not exist
	ErrNoSuchUser = Error(C.SP_ERROR_NO_SUCH_USER)

	// No credentials are stored
	ErrNoCredentials = Error(C.SP_ERROR_NO_CREDENTIALS)

	// Network disabled
	ErrNetworkDisabled = Error(C.SP_ERROR_NETWORK_DISABLED)

	// Invalid device ID
	ErrInvalidDeviceId = Error(C.SP_ERROR_INVALID_DEVICE_ID)

	// Unable to open trace file
	ErrCantOpenTraceFile = Error(C.SP_ERROR_CANT_OPEN_TRACE_FILE)

	// This application is no longer allowed to use the Spotify service
	ErrApplicationBanned = Error(C.SP_ERROR_APPLICATION_BANNED)

	// Reached the device limit for number of tracks to download
	ErrOfflineTooManyTracks = Error(C.SP_ERROR_OFFLINE_TOO_MANY_TRACKS)

	// Disk cache is full so no more tracks can be downloaded to offline mode
	ErrOfflineDiskCache = Error(C.SP_ERROR_OFFLINE_DISK_CACHE)

	// Offline key has expired, the user needs to go online again
	ErrOfflineExpired = Error(C.SP_ERROR_OFFLINE_EXPIRED)

	// This user is not allowed to use offline mode
	ErrOfflineNotAllowed = Error(C.SP_ERROR_OFFLINE_NOT_ALLOWED)

	// The license for this device has been lost. Most likely because the user
	// used offline on three other device
	ErrOfflineLicenseLost = Error(C.SP_ERROR_OFFLINE_LICENSE_LOST)

	// The Spotify license server does not respond correctly
	ErrOfflineLicenseError = Error(C.SP_ERROR_OFFLINE_LICENSE_ERROR)

	// A LastFM scrobble authentication error has occurred
	ErrLastFMAuthError = Error(C.SP_ERROR_LASTFM_AUTH_ERROR)

	// An invalid argument was specified
	ErrInvalidArgument = Error(C.SP_ERROR_INVALID_ARGUMENT)

	// An operating system error
	ErrSystemFailure = Error(C.SP_ERROR_SYSTEM_FAILURE)
)
View Source
const (
	// User not yet logged in
	ConnectionStateLoggedOut ConnectionState = C.SP_CONNECTION_STATE_LOGGED_OUT

	// Logged in against an Spotify accesspoint
	ConnectionStateLoggedIn = C.SP_CONNECTION_STATE_LOGGED_IN

	// Was logged in, but has now been disconnected
	ConnectionStateDisconnected = C.SP_CONNECTION_STATE_DISCONNECTED

	// Connection state is undefined
	ConnectionStateUndefined = C.SP_CONNECTION_STATE_UNDEFINED

	// Logged in, but in offline mode
	ConnectionStateOffline = C.SP_CONNECTION_STATE_OFFLINE
)
View Source
const (
	Bitrate96k  = Bitrate(C.SP_BITRATE_96k)
	Bitrate160k = Bitrate(C.SP_BITRATE_160k)
	Bitrate320k = Bitrate(C.SP_BITRATE_320k)
)
View Source
const (
	SocialProviderSpotify  = SocialProvider(C.SP_SOCIAL_PROVIDER_SPOTIFY)
	SocialProviderFacebook = SocialProvider(C.SP_SOCIAL_PROVIDER_FACEBOOK)
	SocialProviderLastFM   = SocialProvider(C.SP_SOCIAL_PROVIDER_LASTFM)
)
View Source
const (
	ScrobblingStateUseGlobalSetting = ScrobblingState(C.SP_SCROBBLING_STATE_USE_GLOBAL_SETTING)
	ScrobblingStateLocalEnabled     = ScrobblingState(C.SP_SCROBBLING_STATE_LOCAL_ENABLED)
	ScrobblingStateLocalDisabled    = ScrobblingState(C.SP_SCROBBLING_STATE_LOCAL_DISABLED)
	ScrobblingStateGlobalEnabled    = ScrobblingState(C.SP_SCROBBLING_STATE_GLOBAL_ENABLED)
	ScrobblingStateGlobalDisabled   = ScrobblingState(C.SP_SCROBBLING_STATE_GLOBAL_DISABLED)
)
View Source
const (
	// Connection type unknown (Default)
	ConnectionTypeUnknown = ConnectionType(C.SP_CONNECTION_TYPE_UNKNOWN)
	// No connection
	ConnectionTypeNone = ConnectionType(C.SP_CONNECTION_TYPE_NONE)
	// Mobile data (EDGE, 3G, etc)
	ConnectionTypeMobile = ConnectionType(C.SP_CONNECTION_TYPE_MOBILE)
	// Roamed mobile data (EDGE, 3G, etc)
	ConnectionTypeMobileRoaming = ConnectionType(C.SP_CONNECTION_TYPE_MOBILE_ROAMING)
	// Wireless connection
	ConnectionTypeWifi = ConnectionType(C.SP_CONNECTION_TYPE_WIFI)
	// Ethernet cable, etc
	ConnectionTypeWired = ConnectionType(C.SP_CONNECTION_TYPE_WIRED)
)
View Source
const (
	// A normal playlist.
	PlaylistTypePlaylist = PlaylistType(C.SP_PLAYLIST_TYPE_PLAYLIST)

	// Marks a folder's starting point
	PlaylistTypeStartFolder = PlaylistType(C.SP_PLAYLIST_TYPE_START_FOLDER)

	// Marks previous folder's ending point
	PlaylistTypeEndFolder = PlaylistType(C.SP_PLAYLIST_TYPE_END_FOLDER)

	// Placeholder
	PlaylistTypePlaceholder = PlaylistType(C.SP_PLAYLIST_TYPE_PLACEHOLDER)
)
View Source
const (
	// Link type not valid - default until the library has parsed the link, or
	// when parsing failed
	LinkTypeInvalid = LinkType(C.SP_LINKTYPE_INVALID)
	// Link type is track
	LinkTypeTrack = LinkType(C.SP_LINKTYPE_TRACK)
	// Link type is album
	LinkTypeAlbum = LinkType(C.SP_LINKTYPE_ALBUM)
	// Link type is artist
	LinkTypeArtist = LinkType(C.SP_LINKTYPE_ARTIST)
	// Link type is search
	LinkTypeSearch = LinkType(C.SP_LINKTYPE_SEARCH)
	// Link type is playlist
	LinkTypePlaylist = LinkType(C.SP_LINKTYPE_PLAYLIST)
	// Link type is user
	LinkTypeUser = LinkType(C.SP_LINKTYPE_PROFILE)
	// Link type is starred
	LinkTypeStarred = LinkType(C.SP_LINKTYPE_STARRED)
	// Link type is a local file
	LinkTypeLocalTrack = LinkType(C.SP_LINKTYPE_LOCALTRACK)
	// Link type is an image
	LinkTypeImage = LinkType(C.SP_LINKTYPE_IMAGE)
)
View Source
const (
	// Track is not available
	TrackAvailabilityUnavailable = TrackAvailability(C.SP_TRACK_AVAILABILITY_UNAVAILABLE)

	// Track is available and can be played
	TrackAvailabilityAvailable = TrackAvailability(C.SP_TRACK_AVAILABILITY_AVAILABLE)

	// Track can not be streamed using this account
	TrackAvailabilityNotStreamable = TrackAvailability(C.SP_TRACK_AVAILABILITY_NOT_STREAMABLE)

	// Track not available on artist's request
	TrackAvailabilityBannedByArtist = TrackAvailability(C.SP_TRACK_AVAILABILITY_BANNED_BY_ARTIST)
)
View Source
const (
	// Not marked for offline
	TrackOfflineNo = TrackOfflineStatus(C.SP_TRACK_OFFLINE_NO)
	// Waiting for download
	TrackOfflineWaiting = TrackOfflineStatus(C.SP_TRACK_OFFLINE_WAITING)
	// Currently downloading
	TrackOfflineDownloading = TrackOfflineStatus(C.SP_TRACK_OFFLINE_DOWNLOADING)
	// Downloaded OK and can be played
	TrackOfflineDone = TrackOfflineStatus(C.SP_TRACK_OFFLINE_DONE)
	// TrackOfflineStatus during download
	TrackOfflineTrackOfflineStatus = TrackOfflineStatus(C.SP_TRACK_OFFLINE_ERROR)
	// Downloaded OK but not playable due to expiery
	TrackOfflineDoneExpired = TrackOfflineStatus(C.SP_TRACK_OFFLINE_DONE_EXPIRED)
	// Waiting because device have reached max number of allowed tracks
	TrackOfflineLimitExceeded = TrackOfflineStatus(C.SP_TRACK_OFFLINE_LIMIT_EXCEEDED)
	// Downloaded OK and available but scheduled for re-download
	TrackOfflineDoneResync = TrackOfflineStatus(C.SP_TRACK_OFFLINE_DONE_RESYNC)
)
View Source
const (
	// Normal album
	AlbumTypeAlbum = AlbumType(C.SP_ALBUMTYPE_ALBUM)
	// Single
	AlbumTypeSingle = AlbumType(C.SP_ALBUMTYPE_SINGLE)
	// Compilation
	AlbumTypeCompilation = AlbumType(C.SP_ALBUMTYPE_COMPILATION)
	// Unknown type
	AlbumTypeUnknown = AlbumType(C.SP_ALBUMTYPE_UNKNOWN)
)
View Source
const (
	// Not yet known
	RelationTypeUnknown = RelationType(C.SP_RELATION_TYPE_UNKNOWN)
	// No relation
	RelationTypeNone = RelationType(C.SP_RELATION_TYPE_NONE)
	// The currently logged in user is following this uer
	RelationTypeUnIdirectional = RelationType(C.SP_RELATION_TYPE_UNIDIRECTIONAL)
	// Bidirectional friendship established
	RelationTypeBidirectional = RelationType(C.SP_RELATION_TYPE_BIDIRECTIONAL)
)
View Source
const (
	// Playlist is not offline enabled
	PlaylistOfflineStatusNo = PlaylistOfflineStatus(C.SP_PLAYLIST_OFFLINE_STATUS_NO)
	// Playlist is synchronized to local storage
	PlaylistOfflineStatusYes = PlaylistOfflineStatus(C.SP_PLAYLIST_OFFLINE_STATUS_YES)
	// This playlist is currently downloading. Only one playlist can be in this state any given time
	PlaylistOfflineStatusDownloading = PlaylistOfflineStatus(C.SP_PLAYLIST_OFFLINE_STATUS_DOWNLOADING)
	// Playlist is queued for download
	PlaylistOfflineStatusWaiting = PlaylistOfflineStatus(C.SP_PLAYLIST_OFFLINE_STATUS_WAITING)
)
View Source
const (
	// Normal image size
	ImageSizeNormal = ImageSize(C.SP_IMAGE_SIZE_NORMAL)

	// Small image size
	ImageSizeSmall = ImageSize(C.SP_IMAGE_SIZE_SMALL)

	// Large image size
	ImageSizeLarge = ImageSize(C.SP_IMAGE_SIZE_LARGE)
)
View Source
const (
	// Unknown image format
	ImageFormatUnknown = ImageFormat(C.SP_IMAGE_FORMAT_UNKNOWN)

	// JPEG image
	ImageFormatJpeg = ImageFormat(C.SP_IMAGE_FORMAT_JPEG)
)
View Source
const (
	// 16-bit signed integer samples
	SampleTypeInt16NativeEndian = SampleType(C.SP_SAMPLETYPE_INT16_NATIVE_ENDIAN)
)
View Source
const (
	// Global toplist
	ToplistRegionEverywhere = ToplistRegion(C.SP_TOPLIST_REGION_EVERYWHERE)
)

Variables

View Source
var (
	ErrMissingApplicationKey = errors.New("spotify: application key is required")
)

Functions

func BuildId

func BuildId() string

BuildId returns the libspotify build ID.

Types

type Album

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

func (*Album) Artist

func (a *Album) Artist() *Artist

func (*Album) Cover

func (a *Album) Cover(size ImageSize) (*Image, error)
func (a *Album) CoverLink(size ImageSize) *Link

func (*Album) IsAvailable

func (a *Album) IsAvailable() bool

IsAvailable returns true if the album is available in the current region and for playback.

func (a *Album) Link() *Link

Link creates a link object from the album.

func (*Album) Name

func (a *Album) Name() string

Name returns the name of the album.

func (*Album) Type

func (a *Album) Type() AlbumType

Type returns the type of album.

func (*Album) Wait

func (a *Album) Wait()

func (*Album) Year

func (a *Album) Year() int

Year returns the release year.

type AlbumType

type AlbumType C.sp_albumtype

type AlbumsToplist

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

TODO

func (*AlbumsToplist) Album

func (at *AlbumsToplist) Album(n int) *Album

func (*AlbumsToplist) Albums

func (at *AlbumsToplist) Albums() int

func (AlbumsToplist) Duration

func (t AlbumsToplist) Duration() time.Duration

Duration returns the time spent waiting for the Spotify backend to serve the toplist.

func (AlbumsToplist) Error

func (t AlbumsToplist) Error() error

func (AlbumsToplist) Wait

func (t AlbumsToplist) Wait()

type Artist

type Artist struct {
	// contains filtered or unexported fields
}
func (a *Artist) Link() *Link

Link creates a link object from the artist.

func (*Artist) Name

func (a *Artist) Name() string

Name returns the name of the artist.

func (*Artist) Portrait

func (a *Artist) Portrait(size ImageSize) (*Image, error)
func (a *Artist) PortraitLink(size ImageSize) *Link

func (*Artist) Wait

func (a *Artist) Wait()

type ArtistsToplist

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

TODO plural here, really?

func (*ArtistsToplist) Artist

func (at *ArtistsToplist) Artist(n int) *Artist

func (*ArtistsToplist) Artists

func (at *ArtistsToplist) Artists() int

func (ArtistsToplist) Duration

func (t ArtistsToplist) Duration() time.Duration

Duration returns the time spent waiting for the Spotify backend to serve the toplist.

func (ArtistsToplist) Error

func (t ArtistsToplist) Error() error

func (ArtistsToplist) Wait

func (t ArtistsToplist) Wait()

type AudioConsumer

type AudioConsumer interface {
	WriteAudio(AudioFormat, []byte) int
}

AudioConsumer is the interface used to deliver music. The data delivered will be available as []byte and the format contains information about it.

type AudioFormat

type AudioFormat struct {
	// Sample type
	SampleType SampleType

	// Audio sample rate, in samples per second.
	SampleRate int

	// Number of channels. Currently 1 or 2.
	Channels int
}

func (AudioFormat) Equal

func (af AudioFormat) Equal(u AudioFormat) bool

type Bitrate

type Bitrate C.sp_bitrate

type Config

type Config struct {
	// ApplicationKey is required and can be acquired from developer.spotify.com.
	ApplicationKey []byte

	// ApplicationName is used to determine cache locations and user agent.
	ApplicationName string

	// UserAgent is used when communicating with Spotify. If left empty, it
	// will automatically be created based on ApplicationName.
	UserAgent string

	// CacheLocation defines were Spotify will write any cache
	// files. This includes tracks, browse results and coverarts.
	// Leave empty to disable.
	CacheLocation string

	// SettingsLocation defines where Spotify will write settings
	// and per-user cache items. This includes playlists etc. It
	// may be the same location as the CacheLocation.
	//
	// Note: this directory will not be automatically created.
	SettingsLocation string

	// CompressPlaylists, if enabled, will compress local copies
	// of playlists to reduce disk space usage.
	CompressPlaylists bool

	// DisablePlaylistMetadataCache disables metadata caches for
	// playlists. It reduces disk space usage at the expense of
	// needing to request metadata from Spotify backend when
	// loading lists.
	DisablePlaylistMetadataCache bool

	// InitiallyUnloadPlaylists will avoid loading playlists into
	// RAM on startup if enabled.
	InitiallyUnloadPlaylists bool

	AudioConsumer AudioConsumer
}

Config represents the configuration setup when creating a new session.

type ConnectionRules

type ConnectionRules struct {
	Network          bool
	NetworkIfRoaming bool
	SyncOverMobile   bool
	SyncOverWifi     bool
}

type ConnectionState

type ConnectionState C.sp_connectionstate

Connection state describes the state of the connection of a session.

type ConnectionType

type ConnectionType C.sp_connection_type

type Credentials

type Credentials struct {
	// Username is the spotify username.
	Username string

	// Password for the spotify username.
	Password string

	// Blob is an opaque data chunk used when logging in instead of password. If
	// login is successful and the remember flag set to true, this should be the
	// data blob retrieved from CredentialsBlobUpdates.
	Blob []byte
}

Credentials are used when logging a user in.

type Error

type Error C.sp_error

func (Error) Error

func (e Error) Error() string

type Image

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

func (*Image) Data

func (i *Image) Data() []byte

Data returns the image data.

func (*Image) Decode

func (i *Image) Decode() (image.Image, string, error)

Decode returns a decoded image and the format name used during format registration.

func (*Image) Error

func (i *Image) Error() error

Error returns an error associated with an image.

func (*Image) Format

func (i *Image) Format() ImageFormat

Format returns the image format.

func (*Image) Wait

func (i *Image) Wait()

type ImageFormat

type ImageFormat C.sp_imageformat

type ImageSize

type ImageSize C.sp_image_size
type Link struct {
	// contains filtered or unexported fields
}

func (*Link) Album

func (l *Link) Album() (*Album, error)

func (*Link) Artist

func (l *Link) Artist() (*Artist, error)

func (*Link) Image

func (l *Link) Image() (*Image, error)

func (*Link) Playlist

func (l *Link) Playlist() (*Playlist, error)

func (*Link) String

func (l *Link) String() string

String implements the Stringer interface and returns the Link URI.

func (*Link) Track

func (l *Link) Track() (*Track, error)

func (*Link) TrackOffset

func (l *Link) TrackOffset() time.Duration

TrackOffset returns the offset for the track link.

func (*Link) Type

func (l *Link) Type() LinkType

LinkType returns the type of link.

func (*Link) User

func (l *Link) User() (*User, error)

type LinkType

type LinkType C.sp_linktype

type LogLevel

type LogLevel int
const (
	LogFatal LogLevel = iota
	LogError
	LogWarning
	LogInfo
	LogDebug
)

type LogMessage

type LogMessage struct {
	Time    time.Time
	Level   LogLevel
	Module  string
	Message string
}

func (*LogMessage) String

func (l *LogMessage) String() string

type OfflineSyncStatus

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

func (*OfflineSyncStatus) CopiedBytes

func (oss *OfflineSyncStatus) CopiedBytes() int

func (*OfflineSyncStatus) CopiedTracks

func (oss *OfflineSyncStatus) CopiedTracks() int

func (*OfflineSyncStatus) DoneBytes

func (oss *OfflineSyncStatus) DoneBytes() int

func (*OfflineSyncStatus) DoneTracks

func (oss *OfflineSyncStatus) DoneTracks() int

func (*OfflineSyncStatus) ErrorTracks

func (oss *OfflineSyncStatus) ErrorTracks() int

func (*OfflineSyncStatus) QueuedBytes

func (oss *OfflineSyncStatus) QueuedBytes() int

func (*OfflineSyncStatus) QueuedTracks

func (oss *OfflineSyncStatus) QueuedTracks() int

func (*OfflineSyncStatus) Synching

func (oss *OfflineSyncStatus) Synching() bool

func (*OfflineSyncStatus) WillNotCopyTracks

func (oss *OfflineSyncStatus) WillNotCopyTracks() int

type Player

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

func (*Player) Load

func (p *Player) Load(t *Track) error

func (*Player) Pause

func (p *Player) Pause()

func (*Player) Play

func (p *Player) Play()

func (*Player) Prefetch

func (p *Player) Prefetch(t *Track) error

func (*Player) Seek

func (p *Player) Seek(offset time.Duration)

func (*Player) Unload

func (p *Player) Unload()

type Playlist

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

func (*Playlist) Collaborative

func (p *Playlist) Collaborative() bool

func (*Playlist) Description

func (p *Playlist) Description() string

func (*Playlist) HasPendingChanges

func (p *Playlist) HasPendingChanges() bool

func (*Playlist) Image

func (p *Playlist) Image() (*Image, error)

func (*Playlist) InMemory

func (p *Playlist) InMemory() bool
func (p *Playlist) Link() *Link

func (*Playlist) LoadInMemory

func (p *Playlist) LoadInMemory(m bool)

func (*Playlist) Name

func (p *Playlist) Name() string

func (*Playlist) NumSubscribers

func (p *Playlist) NumSubscribers() int

func (*Playlist) Offline

func (p *Playlist) Offline() PlaylistOfflineStatus

func (*Playlist) Owner

func (p *Playlist) Owner() (*User, error)

func (*Playlist) SetAutolinkTracks

func (p *Playlist) SetAutolinkTracks(l bool)

SetAutolinkTracks sets the autolinking state for a playlist.

If a playlist is autolinked, unplayable tracks will be made playable by linking them to other Spotify tracks, where possible.

func (*Playlist) SetCollaborative

func (p *Playlist) SetCollaborative(c bool)

func (*Playlist) SetName

func (p *Playlist) SetName(n string) error

func (*Playlist) SetOffline

func (p *Playlist) SetOffline(o bool)

func (*Playlist) Track

func (p *Playlist) Track(n int) *PlaylistTrack

func (*Playlist) Tracks

func (p *Playlist) Tracks() int

func (*Playlist) Wait

func (p *Playlist) Wait()

type PlaylistContainer

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

func (*PlaylistContainer) Folder

func (pc *PlaylistContainer) Folder(n int) (*PlaylistFolder, error)

func (*PlaylistContainer) Owner

func (pc *PlaylistContainer) Owner() (*User, error)

func (*PlaylistContainer) Playlist

func (pc *PlaylistContainer) Playlist(n int) *Playlist

func (*PlaylistContainer) PlaylistType

func (pc *PlaylistContainer) PlaylistType(n int) PlaylistType

TODO rename to EntryType?

func (*PlaylistContainer) Playlists

func (pc *PlaylistContainer) Playlists() int

TODO rename to Entries?

func (*PlaylistContainer) Wait

func (pc *PlaylistContainer) Wait()

type PlaylistFolder

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

func (*PlaylistFolder) Id

func (pf *PlaylistFolder) Id() uint64

func (*PlaylistFolder) Name

func (pf *PlaylistFolder) Name() string

type PlaylistOfflineStatus

type PlaylistOfflineStatus C.sp_playlist_offline_status

type PlaylistTrack

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

func (*PlaylistTrack) Message

func (pt *PlaylistTrack) Message() string

Message returns the message attached to a playlist item. Typically used on inbox. TODO only expose this for inbox?

func (*PlaylistTrack) Seen

func (pt *PlaylistTrack) Seen() bool

Seen returns true if the entry has been marked as seen or not.

func (*PlaylistTrack) SetSeen

func (pt *PlaylistTrack) SetSeen(seen bool) error

SetSeen marks the playlist track item as seen or not.

func (*PlaylistTrack) Time

func (pt *PlaylistTrack) Time() time.Time

Time returns the time when the track was added to the playlist.

func (*PlaylistTrack) Track

func (pt *PlaylistTrack) Track() *Track

Track returns the track metadata object for the playlist entry.

func (*PlaylistTrack) User

func (pt *PlaylistTrack) User() *User

User returns the user that added the track to the playlist.

type PlaylistType

type PlaylistType C.sp_playlist_type

type Popularity

type Popularity int

Popularity is in the range [0, 100].

type Region

type Region int

func (Region) String

func (r Region) String() string

type RelationType

type RelationType C.sp_relation_type

type SampleType

type SampleType C.sp_sampletype

type ScrobblingState

type ScrobblingState C.sp_scrobbling_state
type Search struct {
	// contains filtered or unexported fields
}

func (*Search) Album

func (s *Search) Album(n int) *Album

func (*Search) Albums

func (s *Search) Albums() int

func (*Search) Artist

func (s *Search) Artist(n int) *Artist

func (*Search) Artists

func (s *Search) Artists() int

func (*Search) DidYouMean

func (s *Search) DidYouMean() string

func (*Search) Error

func (s *Search) Error() error
func (s *Search) Link() *Link

func (*Search) Playlist

func (s *Search) Playlist(n int) *Playlist

func (*Search) PlaylistImageUri

func (s *Search) PlaylistImageUri(n int) string

func (*Search) PlaylistName

func (s *Search) PlaylistName(n int) string

func (*Search) PlaylistUri

func (s *Search) PlaylistUri(n int) string

func (*Search) Playlists

func (s *Search) Playlists() int

func (*Search) Query

func (s *Search) Query() string

func (*Search) TotalAlbums

func (s *Search) TotalAlbums() int

func (*Search) TotalArtists

func (s *Search) TotalArtists() int

func (*Search) TotalPlaylists

func (s *Search) TotalPlaylists() int

func (*Search) TotalTracks

func (s *Search) TotalTracks() int

func (*Search) Track

func (s *Search) Track(n int) *Track

func (*Search) Tracks

func (s *Search) Tracks() int

func (*Search) Wait

func (s *Search) Wait()

type SearchOptions

type SearchOptions struct {
	// Tracks is the number of tracks to search for
	Tracks SearchSpec

	// Albums is the number of albums to search for
	Albums SearchSpec

	// Artists is the number of artists to search for
	Artists SearchSpec

	// Playlist is the number of playlists to search for
	Playlists SearchSpec

	// Type is the search type. Defaults to normal searching.
	Type SearchType
}

SearchOptions contains offsets and limits for the search query.

type SearchSpec

type SearchSpec struct {
	// Search result offset
	Offset int

	// Search result limitation
	Count int
}

type SearchType

type SearchType C.sp_search_type
const (
	SearchStandard SearchType = SearchType(C.SP_SEARCH_STANDARD)
	SearchSuggest             = SearchType(C.SP_SEARCH_SUGGEST)
)

type Session

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

Session is the representation of a Spotify session.

func NewSession

func NewSession(config *Config) (*Session, error)

NewSession creates a new session based on the given configuration.

func (*Session) AlbumsToplist

func (s *Session) AlbumsToplist(region ToplistRegion) *AlbumsToplist

func (*Session) ArtistsToplist

func (s *Session) ArtistsToplist(region ToplistRegion) *ArtistsToplist

func (*Session) Close

func (s *Session) Close() error

Close closes the session, making the session unusable for any future calls. This call releases the session internally back to libspotify and shuts the background processing thread down.

func (*Session) ConnectionErrorUpdates

func (s *Session) ConnectionErrorUpdates() <-chan error

ConnectionErrorUpdates returns a channel containing connection errors.

func (*Session) ConnectionState

func (s *Session) ConnectionState() ConnectionState

ConnectionState returns the current connection state for the session.

func (*Session) ConnectionStateUpdates

func (s *Session) ConnectionStateUpdates() <-chan struct{}

ConnectionStateUpdates returns a channel used to get updates on the connection state.

func (*Session) CredentialsBlobUpdates

func (s *Session) CredentialsBlobUpdates() <-chan []byte

CredentialsBlobUpdates returns a channel used to get updates for credential blobs.

func (*Session) CurrentUser

func (s *Session) CurrentUser() (*User, error)

CurrentUser returns a user object for the currently logged in user.

func (*Session) EndOfTrackUpdates

func (s *Session) EndOfTrackUpdates() <-chan struct{}

EndOfTrackUpdates returns a channel used to get updates when a track ends playing

func (*Session) FlushCaches

func (s *Session) FlushCaches() error

FlushCaches makes libspotify write all data that is meant to be stored on disk to the disk immediately. libspotify does this periodically by itself and also on logout. Under normal conditions this shouldn't be needed.

func (*Session) ForgetMe

func (s *Session) ForgetMe() error

ForgetMe removes any stored credentials. If no credentials are currently stored, nothing will happen.

func (*Session) GetUser

func (s *Session) GetUser(username string) (*User, error)

func (*Session) IsScrobblingPossible

func (s *Session) IsScrobblingPossible(provider SocialProvider) bool

func (*Session) LogMessages

func (s *Session) LogMessages() <-chan *LogMessage

LogMessages returns a channel used to get log messages.

func (*Session) LoggedInUpdates

func (s *Session) LoggedInUpdates() <-chan error

LoggedInUpdates returns a channel used to get notified when the login has been processed.

func (*Session) LoggedOutUpdates

func (s *Session) LoggedOutUpdates() <-chan struct{}

LoggedOutUpdates returns a channel used to get notified when the session has been logged out.

func (*Session) Login

func (s *Session) Login(c Credentials, remember bool) error

Login logs the the specified username and password combo. This initiates the login in the background.

An application MUST NEVER store the user's password in clear text. If automatic relogin is required, use Relogin.

func (*Session) LoginUsername

func (s *Session) LoginUsername() string

LoginUsername returns the user's login username.

func (*Session) Logout

func (s *Session) Logout() error

Logout logs the currently logged in user out

Always call this before terminating the application and libspotify is currently logged in. Otherwise, the settings and cache may be lost.

func (*Session) MessagesToUser

func (s *Session) MessagesToUser() <-chan string

MessagesToUser returns a channel containing messages which the access point wants to display to a user.

In the desktop client, these are shown in a blueish toolbar just below the search box.

func (*Session) OfflineErrors

func (s *Session) OfflineErrors() <-chan error

OfflineErrors returns a channel containing offline synchronization status status updates.

func (*Session) OfflinePlaylists

func (s *Session) OfflinePlaylists() int

func (*Session) OfflineStatusUpdates

func (s *Session) OfflineStatusUpdates() <-chan struct{}

OfflineStatusUpdates returns a channel containing offline synchronization status updates.

func (*Session) OfflineSyncStatus

func (s *Session) OfflineSyncStatus() (*OfflineSyncStatus, error)

func (*Session) OfflineTimeLeft

func (s *Session) OfflineTimeLeft() time.Duration

func (*Session) OfflineTracksToSync

func (s *Session) OfflineTracksToSync() int
func (s *Session) ParseLink(link string) (*Link, error)

ParseLink parses a Spotify URI / URL string.

func (*Session) PlayTokenLostUpdates

func (s *Session) PlayTokenLostUpdates() <-chan struct{}

PlayTokenLostUpdates returns a channel used to get updates when user loses the play token.

func (*Session) Player

func (s *Session) Player() *Player

func (*Session) Playlists

func (s *Session) Playlists() (*PlaylistContainer, error)

func (*Session) PreferredBitrate

func (s *Session) PreferredBitrate(bitrate Bitrate) error

func (*Session) PreferredOfflineBitrate

func (s *Session) PreferredOfflineBitrate(bitrate Bitrate, resync bool) error

func (*Session) PrivateSession

func (s *Session) PrivateSession() bool

func (*Session) PrivateSessionModeChanges

func (s *Session) PrivateSessionModeChanges() <-chan bool

PrivateSessionModeChanges returns a channel where private session changes are published.

If the value is true, the user is in private mode.

func (*Session) Region

func (s *Session) Region() Region

func (*Session) Relogin

func (s *Session) Relogin() error

Relogin logs the remembered user in if the last user which logged in, logged in with the remember flag set to true.

If no credentials are stored, this will return ErrNoCredentials.

func (*Session) RememberedUser

func (s *Session) RememberedUser() string

func (*Session) ScrobbleErrors

func (s *Session) ScrobbleErrors() <-chan error

ScrobbleErrors returns a channel with scrobble errors.

Called when there is a scrobble error event.

func (*Session) Scrobbling

func (s *Session) Scrobbling(provider SocialProvider) (ScrobblingState, error)

func (*Session) Search

func (s *Session) Search(query string, opts *SearchOptions) (*Search, error)

Search searches Spotify for track, album, artist and / or playlists.

func (*Session) SetAudioConsumer

func (s *Session) SetAudioConsumer(c AudioConsumer)

SetAudioConsumer sets the audio consumer.

func (*Session) SetCacheSize

func (s *Session) SetCacheSize(size int)

SetCacheSize sets the maximum cache size in megabytes.

Setting it to 0 (the default) will let libspotify automatically resize the cache (10% of disk free space).

func (*Session) SetConnectionRules

func (s *Session) SetConnectionRules(r ConnectionRules)

func (*Session) SetConnectionType

func (s *Session) SetConnectionType(t ConnectionType)

func (*Session) SetPrivateSession

func (s *Session) SetPrivateSession(private bool) error

func (*Session) SetScrobbling

func (s *Session) SetScrobbling(provider SocialProvider, state ScrobblingState) error

func (*Session) SetVolumeNormalization

func (s *Session) SetVolumeNormalization(normalize bool)

func (*Session) Starred

func (s *Session) Starred() *Playlist

func (*Session) StreamingErrors

func (s *Session) StreamingErrors() <-chan error

StreamingErrors returns a channel with streaming errors.

func (*Session) TracksToplist

func (s *Session) TracksToplist(region ToplistRegion) *TracksToplist

func (*Session) VolumeNormalization

func (s *Session) VolumeNormalization() bool

type SocialProvider

type SocialProvider C.sp_social_provider

type ToplistRegion

type ToplistRegion Region

func NewToplistRegion

func NewToplistRegion(region string) (ToplistRegion, error)

NewToplistRegion returns the toplist region for a ISO 3166-1 country code.

Also see ToplistRegionEverywhere and ToplistRegionUser for some special constants.

func (ToplistRegion) String

func (r ToplistRegion) String() string

type Track

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

func (*Track) Album

func (t *Track) Album() *Album

Album returns the album of the track.

func (*Track) Artist

func (t *Track) Artist(n int) *Artist

Artist returns the artist on the specified index. Use Artists to know how many artists that performed on the track.

func (*Track) Artists

func (t *Track) Artists() int

Artists returns the number of artists performing on the track.

func (*Track) Availability

func (t *Track) Availability() TrackAvailability

Availability returns the track availability.

func (*Track) Disc

func (t *Track) Disc() int

Disc returns the disc number for the track.

func (*Track) Duration

func (t *Track) Duration() time.Duration

Duration returns the length of the current track.

func (*Track) Error

func (t *Track) Error() error

Error returns an error associated with a track.

func (*Track) Index

func (t *Track) Index() int

Position returns the position of a track on its disc. It starts at 1 (relative the corresponding disc).

This function returns valid data only for tracks appearing in a browse artist or browse album result (otherwise returns 0).

func (*Track) IsAutoLinked

func (t *Track) IsAutoLinked() bool

IsAutoLinked returns true if the track is auto-linked to another track.

func (*Track) IsLocal

func (t *Track) IsLocal() bool

IsLocal returns true if the track is a local file.

func (*Track) IsPlaceholder

func (t *Track) IsPlaceholder() bool

IsPlaceholder returns true if the track is a placeholder. Placeholder tracks are used to store other objects than tracks in the playlist. Currently this is used in the inbox to store artists, albums and playlists.

Use Link() to get a link object that points to the real object this "track" points to.

func (*Track) IsStarred

func (t *Track) IsStarred() bool

IsStarred returns true if the track is starred by the currently logged in user.

func (t *Track) Link() *Link

Link returns a link object representing the track.

func (*Track) LinkOffset

func (t *Track) LinkOffset(offset time.Duration) *Link

Link returns a link object representing the track at the given offset.

func (*Track) Name

func (t *Track) Name() string

Name returns the track name.

func (*Track) OfflineStatus

func (t *Track) OfflineStatus() TrackOfflineStatus

func (*Track) PlayableTrack

func (t *Track) PlayableTrack() *Track

PlayableTrack returns the track which is the actual track that will be played if the given track is played.

func (*Track) Popularity

func (t *Track) Popularity() Popularity

Popularity returns the popularity for the track.

func (*Track) Wait

func (t *Track) Wait()

type TrackAvailability

type TrackAvailability C.sp_track_availability

type TrackOfflineStatus

type TrackOfflineStatus C.sp_track_offline_status

type TracksToplist

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

func (TracksToplist) Duration

func (t TracksToplist) Duration() time.Duration

Duration returns the time spent waiting for the Spotify backend to serve the toplist.

func (TracksToplist) Error

func (t TracksToplist) Error() error

func (*TracksToplist) Track

func (tt *TracksToplist) Track(n int) *Track

Track returns the track given the index from the toplist.

func (*TracksToplist) Tracks

func (tt *TracksToplist) Tracks() int

Tracks returns the numbers of tracks in the toplist.

func (TracksToplist) Wait

func (t TracksToplist) Wait()

type User

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

func (*User) AlbumsToplist

func (u *User) AlbumsToplist() *AlbumsToplist

AlbumsToplist loads the album toplist for the user.

func (*User) ArtistsToplist

func (u *User) ArtistsToplist() *ArtistsToplist

ArtistsToplist loads the artist toplist for the user.

func (*User) CanonicalName

func (u *User) CanonicalName() string

CanonicalName returns the user's canonical username.

func (*User) DisplayName

func (u *User) DisplayName() string

DisplayName returns the user's displayable username.

func (*User) Starred

func (u *User) Starred() *Playlist

func (*User) TracksToplist

func (u *User) TracksToplist() *TracksToplist

TracksToplist loads the track toplist for the user.

func (*User) Wait

func (u *User) Wait()

Jump to

Keyboard shortcuts

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