Documentation
¶
Index ¶
- Constants
- Variables
- func BuildPutStateRequest(opts PutStateOpts, reason connectpb.PutStateReason) *connectpb.PutStateRequest
- func ContextTrackToProvidedTrack(typ SpotifyIdType, track *connectpb.ContextTrack) *connectpb.ProvidedTrack
- func DefaultDeviceInfo(opts DeviceInfoOpts) *connectpb.DeviceInfo
- func GetBestImageIdForSize(images []*metadatapb.Image, size string) []byte
- func GetCpuFamily() spotifypb.CpuFamily
- func GetOS() spotifypb.Os
- func GetPlatform() spotifypb.Platform
- func GetPlatformSpecificData() *clienttokenpb.PlatformSpecificData
- func GidToBase62(id []byte) string
- func NewPlayerState() *connectpb.PlayerState
- func NormalizeSpotifyId(uriOrId string) string
- func ObfuscateUsername(username string) string
- func PlayOrigin(state *connectpb.PlayerState) string
- func SetPaused(state *connectpb.PlayerState, paused bool)
- func SpotifyLikeClientVersion() string
- func SystemInfoString() string
- func TrackPosition(state *connectpb.PlayerState, durationMs int64) int64
- func UpdateTimestamp(state *connectpb.PlayerState, durationMs int64)
- func UserAgent() string
- func VersionNumberString() string
- func VersionString() string
- type AppState
- type AudioSource
- type DeviceInfoOpts
- type Float32Reader
- type GetAddressFunc
- type GetLogin5TokenFunc
- type Logger
- type LogrusAdapter
- func (l LogrusAdapter) Debug(args ...any)
- func (l LogrusAdapter) Debugf(format string, args ...any)
- func (l LogrusAdapter) Error(args ...any)
- func (l LogrusAdapter) Errorf(format string, args ...any)
- func (l LogrusAdapter) Info(args ...any)
- func (l LogrusAdapter) Infof(format string, args ...any)
- func (l LogrusAdapter) Trace(args ...any)
- func (l LogrusAdapter) Tracef(format string, args ...any)
- func (l LogrusAdapter) Warn(args ...any)
- func (l LogrusAdapter) Warnf(format string, args ...any)
- func (l LogrusAdapter) WithError(err error) Logger
- func (l LogrusAdapter) WithField(key string, value any) Logger
- type LogrusAdapterWithStderrAuth
- func (l LogrusAdapterWithStderrAuth) Debug(args ...any)
- func (l LogrusAdapterWithStderrAuth) Debugf(format string, args ...any)
- func (l LogrusAdapterWithStderrAuth) Error(args ...any)
- func (l LogrusAdapterWithStderrAuth) Errorf(format string, args ...any)
- func (l LogrusAdapterWithStderrAuth) Info(args ...any)
- func (l LogrusAdapterWithStderrAuth) Infof(format string, args ...any)
- func (l LogrusAdapterWithStderrAuth) Trace(args ...any)
- func (l LogrusAdapterWithStderrAuth) Tracef(format string, args ...any)
- func (l LogrusAdapterWithStderrAuth) Warn(args ...any)
- func (l LogrusAdapterWithStderrAuth) Warnf(format string, args ...any)
- func (l LogrusAdapterWithStderrAuth) WithError(err error) Logger
- func (l LogrusAdapterWithStderrAuth) WithField(key string, value any) Logger
- type Media
- func (te Media) Duration() int32
- func (te Media) Episode() *metadatapb.Episode
- func (te Media) Id() SpotifyId
- func (te Media) IsEpisode() bool
- func (te Media) IsTrack() bool
- func (te Media) Name() string
- func (te Media) Restriction() []*metadatapb.Restriction
- func (te Media) Track() *metadatapb.Track
- type NullLogger
- func (l *NullLogger) Debug(...any)
- func (l *NullLogger) Debugf(string, ...any)
- func (l *NullLogger) Error(...any)
- func (l *NullLogger) Errorf(string, ...any)
- func (l *NullLogger) Info(...any)
- func (l *NullLogger) Infof(string, ...any)
- func (l *NullLogger) Trace(...any)
- func (l *NullLogger) Tracef(string, ...any)
- func (l *NullLogger) Warn(...any)
- func (l *NullLogger) Warnf(string, ...any)
- func (l *NullLogger) WithError(error) Logger
- func (l *NullLogger) WithField(string, any) Logger
- type PageResolver
- type PutStateOpts
- type SizedReadAtSeeker
- type SpotifyId
- type SpotifyIdType
Constants ¶
const MaxStateVolume uint32 = 65535
MaxStateVolume is the maximum volume value used in DeviceInfo and PlayerState. Duplicated from player package to avoid circular imports.
const SpotifyVersionCode = 127700358
Variables ¶
var ( ErrMediaRestricted = errors.New("media is restricted") ErrNoSupportedFormats = errors.New("no supported formats") )
var ClientId = []byte{0x65, 0xb7, 0x8, 0x7, 0x3f, 0xc0, 0x48, 0xe, 0xa9, 0x2a, 0x7, 0x72, 0x33, 0xca, 0x87, 0xbd}
var ClientIdHex = hex.EncodeToString(ClientId)
var UriRegexp = regexp.MustCompile("^spotify:([a-z]+):([0-9a-zA-Z]{21,22})$")
Functions ¶
func BuildPutStateRequest ¶
func BuildPutStateRequest(opts PutStateOpts, reason connectpb.PutStateReason) *connectpb.PutStateRequest
BuildPutStateRequest constructs a PutStateRequest for the given reason. For BECAME_INACTIVE, callers should use Spclient.PutConnectStateInactive directly.
func ContextTrackToProvidedTrack ¶
func ContextTrackToProvidedTrack(typ SpotifyIdType, track *connectpb.ContextTrack) *connectpb.ProvidedTrack
func DefaultDeviceInfo ¶
func DefaultDeviceInfo(opts DeviceInfoOpts) *connectpb.DeviceInfo
DefaultDeviceInfo creates a DeviceInfo with standard capabilities for a Spotify Connect device. Only consumer-specific values need to be provided via opts.
func GetBestImageIdForSize ¶
func GetBestImageIdForSize(images []*metadatapb.Image, size string) []byte
func GetCpuFamily ¶
func GetPlatform ¶
func GetPlatformSpecificData ¶
func GetPlatformSpecificData() *clienttokenpb.PlatformSpecificData
func GidToBase62 ¶
func NewPlayerState ¶
func NewPlayerState() *connectpb.PlayerState
NewPlayerState creates a fresh PlayerState with sensible defaults.
func NormalizeSpotifyId ¶
func ObfuscateUsername ¶
func PlayOrigin ¶
func PlayOrigin(state *connectpb.PlayerState) string
PlayOrigin returns the FeatureIdentifier from a PlayerState's PlayOrigin.
func SetPaused ¶
func SetPaused(state *connectpb.PlayerState, paused bool)
SetPaused sets the IsPaused flag and PlaybackSpeed on a PlayerState. PlaybackSpeed must be 0 when paused, or Spotify Android will have subtle bugs.
func SpotifyLikeClientVersion ¶
func SpotifyLikeClientVersion() string
func SystemInfoString ¶
func SystemInfoString() string
func TrackPosition ¶
func TrackPosition(state *connectpb.PlayerState, durationMs int64) int64
TrackPosition computes the current playback position in milliseconds from the PlayerState's timestamp and position fields. It handles paused/playback state, stale timestamps, and negative values. If durationMs > 0, the result is clamped to not exceed the duration.
func UpdateTimestamp ¶
func UpdateTimestamp(state *connectpb.PlayerState, durationMs int64)
UpdateTimestamp refreshes the PlayerState's timestamp and position fields to reflect how much playback has advanced since the last update. If durationMs > 0, the position is clamped to not exceed the duration.
func VersionNumberString ¶
func VersionNumberString() string
func VersionString ¶
func VersionString() string
Types ¶
type AppState ¶
type AppState struct {
sync.Mutex
DeviceId string `json:"device_id"`
EventManager json.RawMessage `json:"event_manager"`
Credentials struct {
Username string `json:"username"`
Data []byte `json:"data"`
} `json:"credentials"`
LastVolume *uint32 `json:"last_volume"`
// contains filtered or unexported fields
}
type AudioSource ¶
type DeviceInfoOpts ¶
type DeviceInfoOpts struct {
DeviceName string
DeviceId string
DeviceType devicespb.DeviceType
ClientId string
VolumeSteps uint32
ZeroconfEnabled bool
}
DeviceInfoOpts holds consumer-specific values for DefaultDeviceInfo.
type Float32Reader ¶
type GetAddressFunc ¶
GetAddressFunc is a function that everytime it is called returns a different address for that type of endpoint.
type GetLogin5TokenFunc ¶
GetLogin5TokenFunc is a function that everytime it is called returns a valid login5 access token.
type Logger ¶
type Logger interface {
Tracef(format string, args ...any)
Debugf(format string, args ...any)
Infof(format string, args ...any)
Warnf(format string, args ...any)
Errorf(format string, args ...any)
Trace(args ...any)
Debug(args ...any)
Info(args ...any)
Warn(args ...any)
Error(args ...any)
WithField(key string, value any) Logger
WithError(err error) Logger
}
type LogrusAdapter ¶
func (LogrusAdapter) Debug ¶
func (l LogrusAdapter) Debug(args ...any)
func (LogrusAdapter) Debugf ¶
func (l LogrusAdapter) Debugf(format string, args ...any)
func (LogrusAdapter) Error ¶
func (l LogrusAdapter) Error(args ...any)
func (LogrusAdapter) Errorf ¶
func (l LogrusAdapter) Errorf(format string, args ...any)
func (LogrusAdapter) Info ¶
func (l LogrusAdapter) Info(args ...any)
func (LogrusAdapter) Infof ¶
func (l LogrusAdapter) Infof(format string, args ...any)
func (LogrusAdapter) Trace ¶
func (l LogrusAdapter) Trace(args ...any)
func (LogrusAdapter) Tracef ¶
func (l LogrusAdapter) Tracef(format string, args ...any)
func (LogrusAdapter) Warn ¶
func (l LogrusAdapter) Warn(args ...any)
func (LogrusAdapter) Warnf ¶
func (l LogrusAdapter) Warnf(format string, args ...any)
func (LogrusAdapter) WithError ¶
func (l LogrusAdapter) WithError(err error) Logger
type LogrusAdapterWithStderrAuth ¶
type LogrusAdapterWithStderrAuth struct {
Log *logrus.Entry
StderrPrefix string
AuthKeywords []string
}
func (LogrusAdapterWithStderrAuth) Debug ¶
func (l LogrusAdapterWithStderrAuth) Debug(args ...any)
func (LogrusAdapterWithStderrAuth) Debugf ¶
func (l LogrusAdapterWithStderrAuth) Debugf(format string, args ...any)
func (LogrusAdapterWithStderrAuth) Error ¶
func (l LogrusAdapterWithStderrAuth) Error(args ...any)
func (LogrusAdapterWithStderrAuth) Errorf ¶
func (l LogrusAdapterWithStderrAuth) Errorf(format string, args ...any)
func (LogrusAdapterWithStderrAuth) Info ¶
func (l LogrusAdapterWithStderrAuth) Info(args ...any)
func (LogrusAdapterWithStderrAuth) Infof ¶
func (l LogrusAdapterWithStderrAuth) Infof(format string, args ...any)
func (LogrusAdapterWithStderrAuth) Trace ¶
func (l LogrusAdapterWithStderrAuth) Trace(args ...any)
func (LogrusAdapterWithStderrAuth) Tracef ¶
func (l LogrusAdapterWithStderrAuth) Tracef(format string, args ...any)
func (LogrusAdapterWithStderrAuth) Warn ¶
func (l LogrusAdapterWithStderrAuth) Warn(args ...any)
func (LogrusAdapterWithStderrAuth) Warnf ¶
func (l LogrusAdapterWithStderrAuth) Warnf(format string, args ...any)
func (LogrusAdapterWithStderrAuth) WithError ¶
func (l LogrusAdapterWithStderrAuth) WithError(err error) Logger
type Media ¶
type Media struct {
// contains filtered or unexported fields
}
func NewMediaFromEpisode ¶
func NewMediaFromEpisode(episode *metadatapb.Episode) *Media
func NewMediaFromTrack ¶
func NewMediaFromTrack(track *metadatapb.Track) *Media
func (Media) Episode ¶
func (te Media) Episode() *metadatapb.Episode
func (Media) Restriction ¶
func (te Media) Restriction() []*metadatapb.Restriction
func (Media) Track ¶
func (te Media) Track() *metadatapb.Track
type NullLogger ¶
type NullLogger struct{}
func (*NullLogger) Debug ¶
func (l *NullLogger) Debug(...any)
func (*NullLogger) Debugf ¶
func (l *NullLogger) Debugf(string, ...any)
func (*NullLogger) Error ¶
func (l *NullLogger) Error(...any)
func (*NullLogger) Errorf ¶
func (l *NullLogger) Errorf(string, ...any)
func (*NullLogger) Info ¶
func (l *NullLogger) Info(...any)
func (*NullLogger) Infof ¶
func (l *NullLogger) Infof(string, ...any)
func (*NullLogger) Trace ¶
func (l *NullLogger) Trace(...any)
func (*NullLogger) Tracef ¶
func (l *NullLogger) Tracef(string, ...any)
func (*NullLogger) Warn ¶
func (l *NullLogger) Warn(...any)
func (*NullLogger) Warnf ¶
func (l *NullLogger) Warnf(string, ...any)
func (*NullLogger) WithError ¶
func (l *NullLogger) WithError(error) Logger
type PageResolver ¶
type PutStateOpts ¶
type PutStateOpts struct {
Device *connectpb.DeviceInfo
PlayerState *connectpb.PlayerState
Active bool
ActiveSince time.Time
LastCommandMsgId uint32
LastCommandSentByDeviceId string
HasBeenPlayingForMs uint64
}
PutStateOpts holds the values needed to build a PutStateRequest.
type SizedReadAtSeeker ¶
type SizedReadAtSeeker interface {
io.ReadSeeker
io.ReaderAt
Size() int64
}
type SpotifyId ¶
type SpotifyId struct {
// contains filtered or unexported fields
}
func SpotifyIdFromBase62 ¶
func SpotifyIdFromBase62(typ SpotifyIdType, id string) (*SpotifyId, error)
func SpotifyIdFromGid ¶
func SpotifyIdFromGid(typ SpotifyIdType, id []byte) SpotifyId
func SpotifyIdFromUri ¶
func (SpotifyId) Type ¶
func (id SpotifyId) Type() SpotifyIdType
type SpotifyIdType ¶
type SpotifyIdType string
const ( SpotifyIdTypeTrack SpotifyIdType = "track" SpotifyIdTypeEpisode SpotifyIdType = "episode" SpotifyIdTypePlaylist SpotifyIdType = "playlist" )
func InferSpotifyIdTypeFromContextUri ¶
func InferSpotifyIdTypeFromContextUri(uri string) SpotifyIdType