spclient

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: GPL-3.0 Imports: 32 Imported by: 1

Documentation

Index

Constants

View Source
const CollectionSetLikedSongs = "collection"

CollectionSetLikedSongs is the collection set holding the user's Liked Songs.

Variables

View Source
var ErrPlaylistConflict = errors.New("playlist changed concurrently")

ErrPlaylistConflict reports that a playlist changed between reading its revision and writing to it.

Functions

func IsPlaylistPageUrl added in v0.10.3

func IsPlaylistPageUrl(url string) bool

IsPlaylistPageUrl reports whether a context page url names a page of a playlist context, to be loaded with PlaylistPage.

func NewNarrationRequest added in v0.9.0

func NewNarrationRequest(ssml string, voice narrationpb.ResolveRequest_TtsVoice,
	provider narrationpb.ResolveRequest_TtsProvider, sampleRate int32) *narrationpb.TtsRequest

Types

type ContextResolveError added in v0.10.1

type ContextResolveError struct {
	StatusCode int
	// contains filtered or unexported fields
}

ContextResolveError reports that the backend answered a context resolve with something other than 200. Transient statuses never get this far, they are retried by the request itself, so what arrives here is the backend's final word: 403 and 404 in particular mean this account may not have the context.

func (*ContextResolveError) Error added in v0.10.1

func (e *ContextResolveError) Error() string

func (*ContextResolveError) IsAccessDenied added in v0.10.1

func (e *ContextResolveError) IsAccessDenied() bool

IsAccessDenied reports whether the backend refused the context to this account rather than failing to produce it.

type ContextResolver

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

func NewContextResolver

func NewContextResolver(ctx context.Context, log librespot.Logger, sp *Spclient, spotCtx *connectpb.Context) (_ *ContextResolver, err error)

func (*ContextResolver) Metadata

func (r *ContextResolver) Metadata() map[string]string

func (*ContextResolver) Page

func (r *ContextResolver) Page(ctx context.Context, idx int) ([]*connectpb.ContextTrack, error)

func (*ContextResolver) Restrictions

func (r *ContextResolver) Restrictions() *connectpb.Restrictions

func (*ContextResolver) Type

func (*ContextResolver) Uri

func (r *ContextResolver) Uri() string

type RateLimitedError added in v0.8.0

type RateLimitedError struct {
	RetryAfter time.Duration
	// contains filtered or unexported fields
}

RateLimitedError reports a connect-state 429; RetryAfter is the advised cooldown.

func (*RateLimitedError) Error added in v0.8.0

func (e *RateLimitedError) Error() string

func (*RateLimitedError) Unwrap added in v0.8.0

func (e *RateLimitedError) Unwrap() error

type Spclient

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

func NewSpclient

func NewSpclient(ctx context.Context, log librespot.Logger, client *http.Client, addr librespot.GetAddressFunc, accessToken librespot.GetLogin5TokenFunc, deviceId, clientToken string) (*Spclient, error)

func (*Spclient) CollectionContains added in v0.10.3

func (c *Spclient) CollectionContains(ctx context.Context, username, set string, uris []string) ([]bool, error)

CollectionContains tells for each of uris whether it is in one of the user's collection sets, in one round trip.

func (*Spclient) CollectionWrite added in v0.10.3

func (c *Spclient) CollectionWrite(ctx context.Context, username, set string, uris []string, remove bool) error

CollectionWrite adds uris to, or with remove set removes them from, one of the user's collection sets.

func (*Spclient) ContextResolve

func (c *Spclient) ContextResolve(ctx context.Context, uri string) (*connectpb.Context, error)

func (*Spclient) ContextResolveAutoplay

func (c *Spclient) ContextResolveAutoplay(ctx context.Context, reqProto *playerpb.AutoplayContextRequest) (*connectpb.Context, error)

func (*Spclient) ContextResolveUrl added in v0.9.0

func (c *Spclient) ContextResolveUrl(ctx context.Context, hmUrl string) (*connectpb.Context, error)

ContextResolveUrl resolves a context through the hm:// url the Context carries rather than through /context-resolve/v1.

func (*Spclient) CreateResumePointRevision added in v0.8.0

func (*Spclient) ExtendedMetadata added in v0.3.3

func (*Spclient) ExtendedMetadataSimple added in v0.3.3

func (c *Spclient) ExtendedMetadataSimple(ctx context.Context, id librespot.SpotifyId, ext extmetadatapb.ExtensionKind, data proto.Message) error

func (*Spclient) GetAccessToken

func (c *Spclient) GetAccessToken(ctx context.Context, force bool) (string, error)

func (*Spclient) ListCurrentStates added in v0.8.0

func (*Spclient) NarrationUrl added in v0.9.0

func (c *Spclient) NarrationUrl(ctx context.Context, req *narrationpb.TtsRequest) (string, error)

NarrationUrl turns a narration script into the url of its synthesized audio.

func (*Spclient) NetFortune added in v0.3.0

func (c *Spclient) NetFortune(ctx context.Context, bandwidth int) (*netfortunepb.NetFortuneV2Response, error)

func (*Spclient) PlayPlayRequest added in v0.5.1

func (c *Spclient) PlayPlayRequest(ctx context.Context, fileId []byte, reqProto *streamingpb.PlayPlayLicenseRequest) (*streamingpb.PlayPlayLicenseResponse, error)

func (*Spclient) PlaylistAppend added in v0.10.3

func (c *Spclient) PlaylistAppend(ctx context.Context, playlist librespot.SpotifyId, username string, revision []byte, uris []string) error

PlaylistAppend appends uris to the end of a playlist, as a change based on revision. It returns ErrPlaylistConflict when the playlist moved on since.

func (*Spclient) PlaylistContext added in v0.10.3

func (c *Spclient) PlaylistContext(ctx context.Context, playlist librespot.SpotifyId) (*connectpb.Context, error)

PlaylistContext builds the context of a playlist from the playlist service, as the official client does, rather than through context resolve. Context resolve leaves out the podcast episodes of a playlist that mixes them with tracks; the playlist service lists every item, and the rest of what context resolve answers is derived from it unchanged: the same uids, and the same context and track metadata.

Only the first page is fetched here. The pages after it are named by NextPageUrl, and loaded with PlaylistPage.

func (*Spclient) PlaylistPage added in v0.10.3

func (c *Spclient) PlaylistPage(ctx context.Context, pageUrl string) (*connectpb.ContextPage, error)

PlaylistPage loads the page of a playlist context a page url names.

func (*Spclient) PlaylistRevision added in v0.10.3

func (c *Spclient) PlaylistRevision(ctx context.Context, playlist librespot.SpotifyId) ([]byte, error)

PlaylistRevision returns the current revision of a playlist, which a change has to be based on.

func (*Spclient) PlaylistSignals

func (c *Spclient) PlaylistSignals(ctx context.Context, playlist librespot.SpotifyId, reqProto *playlist4pb.ListSignals, lenses []string) (*playlist4pb.SelectedListContent, error)

func (*Spclient) PublishEvents added in v0.3.0

func (*Spclient) PutConnectState

func (c *Spclient) PutConnectState(ctx context.Context, spotConnId string, reqProto *connectpb.PutStateRequest) (*connectpb.Cluster, error)

func (*Spclient) PutConnectStateInactive

func (c *Spclient) PutConnectStateInactive(ctx context.Context, spotConnId string, notify bool) error

func (*Spclient) PutConnectStateRaw added in v0.10.0

func (c *Spclient) PutConnectStateRaw(ctx context.Context, spotConnId string, reason connectpb.PutStateReason, reqBody []byte) (*connectpb.Cluster, error)

PutConnectStateRaw PUTs an already marshalled PutStateRequest. Marshalling in the caller lets it hand over a snapshot of state it goes on mutating, rather than a proto this call would walk from another goroutine.

func (*Spclient) Request added in v0.1.3

func (c *Spclient) Request(ctx context.Context, method string, path string, query url.Values, header http.Header, body []byte) (*http.Response, error)

func (*Spclient) RequestHm added in v0.9.0

func (c *Spclient) RequestHm(ctx context.Context, method string, hmUrl string, header http.Header, body []byte) (*http.Response, error)

RequestHm issues a request against an hm:// URL, the form Spotify uses to name spclient endpoints inside payloads.

The remainder cannot simply be handed to Request as a path: JoinPath escapes the "?" of a query string. The query is kept verbatim rather than being parsed and re-encoded, so that a contextUri keeps its unescaped colons.

func (*Spclient) RequestNoRedirect added in v0.9.0

func (c *Spclient) RequestNoRedirect(ctx context.Context, method string, path string, query url.Values, header http.Header, body []byte) (*http.Response, error)

RequestNoRedirect is Request but returns the redirect itself rather than following it, for endpoints that answer with a Location instead of a body.

func (*Spclient) RequestOnce added in v0.10.3

func (c *Spclient) RequestOnce(ctx context.Context, method string, path string, query url.Values, header http.Header, body []byte) (*http.Response, error)

RequestOnce is Request for requests that are not idempotent: it does not repeat them on network errors or transient statuses, since the server may already have acted on them, and leaves such failures to the caller. A 401 is still answered by renewing the token and sending again, as the server refused the request.

func (*Spclient) ResolveStorageInteractive

func (c *Spclient) ResolveStorageInteractive(ctx context.Context, fileId []byte, format *metadatapb.AudioFile_Format, prefetch bool) (*storagepb.StorageResolveResponse, error)

func (*Spclient) ResumePositionMs added in v0.8.0

func (c *Spclient) ResumePositionMs(ctx context.Context, id librespot.SpotifyId) (int64, error)

ResumePositionMs returns where playback of the given entity should start, in milliseconds. Zero means "from the beginning": either the backend has never seen the entity, or it was listened to the end and the next play is meant to restart it.

Only episodes and audiobook chapters have resume points; callers should not bother asking for tracks.

func (*Spclient) Rootlist added in v0.10.3

func (c *Spclient) Rootlist(ctx context.Context, username string, from, length int) (*playlist4pb.SelectedListContent, error)

Rootlist fetches a page of the user's rootlist: the playlists and folders shown in the library sidebar, in the user's order. Folders appear as spotify:start-group and spotify:end-group entries around their contents.

func (*Spclient) SetResumeFinished added in v0.8.0

func (c *Spclient) SetResumeFinished(ctx context.Context, id librespot.SpotifyId) error

SetResumeFinished marks the given entity as listened to the end, so the next play starts it over rather than resuming a position near the end.

func (*Spclient) SetResumePositionMs added in v0.8.0

func (c *Spclient) SetResumePositionMs(ctx context.Context, id librespot.SpotifyId, positionMs int64) error

SetResumePositionMs stores how far into the given entity playback has got.

type StatusError added in v0.10.3

type StatusError struct {
	Op         string
	StatusCode int
}

StatusError reports a status the collection or playlist service answered a library request with, so callers can tell a permission problem (403) or a missing playlist (404) from a fault.

func (*StatusError) Error added in v0.10.3

func (e *StatusError) Error() string

Jump to

Keyboard shortcuts

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