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
- Variables
- func BuildId() string
- type Album
- func (a *Album) Artist() *Artist
- func (a *Album) Cover(size ImageSize) (*Image, error)
- func (a *Album) CoverLink(size ImageSize) *Link
- func (a *Album) IsAvailable() bool
- func (a *Album) Link() *Link
- func (a *Album) Name() string
- func (a *Album) Type() AlbumType
- func (a *Album) Wait()
- func (a *Album) Year() int
- type AlbumType
- type AlbumsToplist
- type Artist
- type ArtistsToplist
- type AudioConsumer
- type AudioFormat
- type Bitrate
- type Config
- type ConnectionRules
- type ConnectionState
- type ConnectionType
- type Credentials
- type Error
- type Image
- type ImageFormat
- type ImageSize
- type Link
- func (l *Link) Album() (*Album, error)
- func (l *Link) Artist() (*Artist, error)
- func (l *Link) Image() (*Image, error)
- func (l *Link) Playlist() (*Playlist, error)
- func (l *Link) String() string
- func (l *Link) Track() (*Track, error)
- func (l *Link) TrackOffset() time.Duration
- func (l *Link) Type() LinkType
- func (l *Link) User() (*User, error)
- type LinkType
- type LogLevel
- type LogMessage
- type OfflineSyncStatus
- func (oss *OfflineSyncStatus) CopiedBytes() int
- func (oss *OfflineSyncStatus) CopiedTracks() int
- func (oss *OfflineSyncStatus) DoneBytes() int
- func (oss *OfflineSyncStatus) DoneTracks() int
- func (oss *OfflineSyncStatus) ErrorTracks() int
- func (oss *OfflineSyncStatus) QueuedBytes() int
- func (oss *OfflineSyncStatus) QueuedTracks() int
- func (oss *OfflineSyncStatus) Synching() bool
- func (oss *OfflineSyncStatus) WillNotCopyTracks() int
- type Player
- type Playlist
- func (p *Playlist) Collaborative() bool
- func (p *Playlist) Description() string
- func (p *Playlist) HasPendingChanges() bool
- func (p *Playlist) Image() (*Image, error)
- func (p *Playlist) InMemory() bool
- func (p *Playlist) Link() *Link
- func (p *Playlist) LoadInMemory(m bool)
- func (p *Playlist) Name() string
- func (p *Playlist) NumSubscribers() int
- func (p *Playlist) Offline() PlaylistOfflineStatus
- func (p *Playlist) Owner() (*User, error)
- func (p *Playlist) SetAutolinkTracks(l bool)
- func (p *Playlist) SetCollaborative(c bool)
- func (p *Playlist) SetName(n string) error
- func (p *Playlist) SetOffline(o bool)
- func (p *Playlist) Track(n int) *PlaylistTrack
- func (p *Playlist) Tracks() int
- func (p *Playlist) Wait()
- type PlaylistContainer
- func (pc *PlaylistContainer) Folder(n int) (*PlaylistFolder, error)
- func (pc *PlaylistContainer) Owner() (*User, error)
- func (pc *PlaylistContainer) Playlist(n int) *Playlist
- func (pc *PlaylistContainer) PlaylistType(n int) PlaylistType
- func (pc *PlaylistContainer) Playlists() int
- func (pc *PlaylistContainer) Wait()
- type PlaylistFolder
- type PlaylistOfflineStatus
- type PlaylistTrack
- type PlaylistType
- type Popularity
- type Region
- type RelationType
- type SampleType
- type ScrobblingState
- type Search
- func (s *Search) Album(n int) *Album
- func (s *Search) Albums() int
- func (s *Search) Artist(n int) *Artist
- func (s *Search) Artists() int
- func (s *Search) DidYouMean() string
- func (s *Search) Error() error
- func (s *Search) Link() *Link
- func (s *Search) Playlist(n int) *Playlist
- func (s *Search) PlaylistImageUri(n int) string
- func (s *Search) PlaylistName(n int) string
- func (s *Search) PlaylistUri(n int) string
- func (s *Search) Playlists() int
- func (s *Search) Query() string
- func (s *Search) TotalAlbums() int
- func (s *Search) TotalArtists() int
- func (s *Search) TotalPlaylists() int
- func (s *Search) TotalTracks() int
- func (s *Search) Track(n int) *Track
- func (s *Search) Tracks() int
- func (s *Search) Wait()
- type SearchOptions
- type SearchSpec
- type SearchType
- type Session
- func (s *Session) AlbumsToplist(region ToplistRegion) *AlbumsToplist
- func (s *Session) ArtistsToplist(region ToplistRegion) *ArtistsToplist
- func (s *Session) Close() error
- func (s *Session) ConnectionErrorUpdates() <-chan error
- func (s *Session) ConnectionState() ConnectionState
- func (s *Session) ConnectionStateUpdates() <-chan struct{}
- func (s *Session) CredentialsBlobUpdates() <-chan []byte
- func (s *Session) CurrentUser() (*User, error)
- func (s *Session) EndOfTrackUpdates() <-chan struct{}
- func (s *Session) FlushCaches() error
- func (s *Session) ForgetMe() error
- func (s *Session) GetUser(username string) (*User, error)
- func (s *Session) IsScrobblingPossible(provider SocialProvider) bool
- func (s *Session) LogMessages() <-chan *LogMessage
- func (s *Session) LoggedInUpdates() <-chan error
- func (s *Session) LoggedOutUpdates() <-chan struct{}
- func (s *Session) Login(c Credentials, remember bool) error
- func (s *Session) LoginUsername() string
- func (s *Session) Logout() error
- func (s *Session) MessagesToUser() <-chan string
- func (s *Session) OfflineErrors() <-chan error
- func (s *Session) OfflinePlaylists() int
- func (s *Session) OfflineStatusUpdates() <-chan struct{}
- func (s *Session) OfflineSyncStatus() (*OfflineSyncStatus, error)
- func (s *Session) OfflineTimeLeft() time.Duration
- func (s *Session) OfflineTracksToSync() int
- func (s *Session) ParseLink(link string) (*Link, error)
- func (s *Session) PlayTokenLostUpdates() <-chan struct{}
- func (s *Session) Player() *Player
- func (s *Session) Playlists() (*PlaylistContainer, error)
- func (s *Session) PreferredBitrate(bitrate Bitrate) error
- func (s *Session) PreferredOfflineBitrate(bitrate Bitrate, resync bool) error
- func (s *Session) PrivateSession() bool
- func (s *Session) PrivateSessionModeChanges() <-chan bool
- func (s *Session) Region() Region
- func (s *Session) Relogin() error
- func (s *Session) RememberedUser() string
- func (s *Session) ScrobbleErrors() <-chan error
- func (s *Session) Scrobbling(provider SocialProvider) (ScrobblingState, error)
- func (s *Session) Search(query string, opts *SearchOptions) (*Search, error)
- func (s *Session) SetAudioConsumer(c AudioConsumer)
- func (s *Session) SetCacheSize(size int)
- func (s *Session) SetConnectionRules(r ConnectionRules)
- func (s *Session) SetConnectionType(t ConnectionType)
- func (s *Session) SetPrivateSession(private bool) error
- func (s *Session) SetScrobbling(provider SocialProvider, state ScrobblingState) error
- func (s *Session) SetVolumeNormalization(normalize bool)
- func (s *Session) Starred() *Playlist
- func (s *Session) StreamingErrors() <-chan error
- func (s *Session) TracksToplist(region ToplistRegion) *TracksToplist
- func (s *Session) VolumeNormalization() bool
- type SocialProvider
- type ToplistRegion
- type Track
- func (t *Track) Album() *Album
- func (t *Track) Artist(n int) *Artist
- func (t *Track) Artists() int
- func (t *Track) Availability() TrackAvailability
- func (t *Track) Disc() int
- func (t *Track) Duration() time.Duration
- func (t *Track) Error() error
- func (t *Track) Index() int
- func (t *Track) IsAutoLinked() bool
- func (t *Track) IsLocal() bool
- func (t *Track) IsPlaceholder() bool
- func (t *Track) IsStarred() bool
- func (t *Track) Link() *Link
- func (t *Track) LinkOffset(offset time.Duration) *Link
- func (t *Track) Name() string
- func (t *Track) OfflineStatus() TrackOfflineStatus
- func (t *Track) PlayableTrack() *Track
- func (t *Track) Popularity() Popularity
- func (t *Track) Wait()
- type TrackAvailability
- type TrackOfflineStatus
- type TracksToplist
- type User
Constants ¶
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) )
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 )
const ( Bitrate96k = Bitrate(C.SP_BITRATE_96k) Bitrate160k = Bitrate(C.SP_BITRATE_160k) Bitrate320k = Bitrate(C.SP_BITRATE_320k) )
const ( SocialProviderSpotify = SocialProvider(C.SP_SOCIAL_PROVIDER_SPOTIFY) SocialProviderFacebook = SocialProvider(C.SP_SOCIAL_PROVIDER_FACEBOOK) SocialProviderLastFM = SocialProvider(C.SP_SOCIAL_PROVIDER_LASTFM) )
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) )
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) )
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) )
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) )
const ( 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) )TrackAvailabilityUnavailable =
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) )
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) )
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) )
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) )
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) )
const ( // Unknown image format ImageFormatUnknown = ImageFormat(C.SP_IMAGE_FORMAT_UNKNOWN) // JPEG image ImageFormatJpeg = ImageFormat(C.SP_IMAGE_FORMAT_JPEG) )
const ( // 16-bit signed integer samples SampleTypeInt16NativeEndian = SampleType(C.SP_SAMPLETYPE_INT16_NATIVE_ENDIAN) )
const ( // Global toplist ToplistRegionEverywhere = ToplistRegion(C.SP_TOPLIST_REGION_EVERYWHERE) )
Variables ¶
var (
ErrMissingApplicationKey = errors.New("spotify: application key is required")
)
Functions ¶
Types ¶
type Album ¶
type Album struct {
// contains filtered or unexported fields
}
func (*Album) IsAvailable ¶
IsAvailable returns true if the album is available in the current region and for playback.
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
type Artist ¶
type Artist struct {
// contains filtered or unexported fields
}
func (*Artist) PortraitLink ¶
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
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 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 Image ¶
type Image struct {
// contains filtered or unexported fields
}
func (*Image) Decode ¶
Decode returns a decoded image and the format name used during format registration.
type ImageFormat ¶
type ImageFormat C.sp_imageformat
type ImageSize ¶
type ImageSize C.sp_image_size
type Link ¶
type Link struct {
// contains filtered or unexported fields
}
func (*Link) TrackOffset ¶
TrackOffset returns the offset for the track link.
type LinkType ¶
type LinkType C.sp_linktype
type LogMessage ¶
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 Playlist ¶
type Playlist struct {
// contains filtered or unexported fields
}
func (*Playlist) Collaborative ¶
func (*Playlist) Description ¶
func (*Playlist) HasPendingChanges ¶
func (*Playlist) LoadInMemory ¶
func (*Playlist) NumSubscribers ¶
func (*Playlist) Offline ¶
func (p *Playlist) Offline() PlaylistOfflineStatus
func (*Playlist) SetAutolinkTracks ¶
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 (*Playlist) SetOffline ¶
func (*Playlist) Track ¶
func (p *Playlist) Track(n int) *PlaylistTrack
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 RelationType ¶
type RelationType C.sp_relation_type
type SampleType ¶
type SampleType C.sp_sampletype
type ScrobblingState ¶
type ScrobblingState C.sp_scrobbling_state
type Search ¶
type Search struct {
// contains filtered or unexported fields
}
func (*Search) DidYouMean ¶
func (*Search) PlaylistImageUri ¶
func (*Search) PlaylistName ¶
func (*Search) PlaylistUri ¶
func (*Search) TotalAlbums ¶
func (*Search) TotalArtists ¶
func (*Search) TotalPlaylists ¶
func (*Search) TotalTracks ¶
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 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 ¶
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 ¶
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 ¶
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 ¶
CredentialsBlobUpdates returns a channel used to get updates for credential blobs.
func (*Session) CurrentUser ¶
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 ¶
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 ¶
ForgetMe removes any stored credentials. If no credentials are currently stored, nothing will happen.
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 ¶
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 ¶
LoginUsername returns the user's login username.
func (*Session) Logout ¶
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 ¶
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 ¶
OfflineErrors returns a channel containing offline synchronization status status updates.
func (*Session) OfflinePlaylists ¶
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 (*Session) OfflineTracksToSync ¶
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) Playlists ¶
func (s *Session) Playlists() (*PlaylistContainer, error)
func (*Session) PreferredBitrate ¶
func (*Session) PreferredOfflineBitrate ¶
func (*Session) PrivateSession ¶
func (*Session) PrivateSessionModeChanges ¶
PrivateSessionModeChanges returns a channel where private session changes are published.
If the value is true, the user is in private mode.
func (*Session) Relogin ¶
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 (*Session) ScrobbleErrors ¶
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 ¶
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 (*Session) SetScrobbling ¶
func (s *Session) SetScrobbling(provider SocialProvider, state ScrobblingState) error
func (*Session) SetVolumeNormalization ¶
func (*Session) StreamingErrors ¶
StreamingErrors returns a channel with streaming errors.
func (*Session) TracksToplist ¶
func (s *Session) TracksToplist(region ToplistRegion) *TracksToplist
func (*Session) VolumeNormalization ¶
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) Artist ¶
Artist returns the artist on the specified index. Use Artists to know how many artists that performed on the track.
func (*Track) Availability ¶
func (t *Track) Availability() TrackAvailability
Availability returns the track availability.
func (*Track) Index ¶
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 ¶
IsAutoLinked returns true if the track is auto-linked to another track.
func (*Track) IsPlaceholder ¶
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 ¶
IsStarred returns true if the track is starred by the currently logged in user.
func (*Track) LinkOffset ¶
Link returns a link object representing the track at the given offset.
func (*Track) OfflineStatus ¶
func (t *Track) OfflineStatus() TrackOfflineStatus
func (*Track) PlayableTrack ¶
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.
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 ¶
Duration returns the time spent waiting for the Spotify backend to serve the toplist.
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.
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 ¶
CanonicalName returns the user's canonical username.
func (*User) DisplayName ¶
DisplayName returns the user's displayable username.
func (*User) TracksToplist ¶
func (u *User) TracksToplist() *TracksToplist
TracksToplist loads the track toplist for the user.