Documentation
¶
Index ¶
- Constants
- Variables
- func IsPlaylistPageUrl(url string) bool
- func NewNarrationRequest(ssml string, voice narrationpb.ResolveRequest_TtsVoice, ...) *narrationpb.TtsRequest
- type ContextResolveError
- type ContextResolver
- func (r *ContextResolver) Metadata() map[string]string
- func (r *ContextResolver) Page(ctx context.Context, idx int) ([]*connectpb.ContextTrack, error)
- func (r *ContextResolver) Restrictions() *connectpb.Restrictions
- func (r *ContextResolver) Type() librespot.SpotifyIdType
- func (r *ContextResolver) Uri() string
- type RateLimitedError
- type Spclient
- func (c *Spclient) CollectionContains(ctx context.Context, username, set string, uris []string) ([]bool, error)
- func (c *Spclient) CollectionWrite(ctx context.Context, username, set string, uris []string, remove bool) error
- func (c *Spclient) ContextResolve(ctx context.Context, uri string) (*connectpb.Context, error)
- func (c *Spclient) ContextResolveAutoplay(ctx context.Context, reqProto *playerpb.AutoplayContextRequest) (*connectpb.Context, error)
- func (c *Spclient) ContextResolveUrl(ctx context.Context, hmUrl string) (*connectpb.Context, error)
- func (c *Spclient) CreateResumePointRevision(ctx context.Context, reqProto *resumptionpb.CreateResumePointRevisionRequest) (*resumptionpb.CreateResumePointRevisionResponse, error)
- func (c *Spclient) ExtendedMetadata(ctx context.Context, req *extmetadatapb.BatchedEntityRequest) (*extmetadatapb.BatchedExtensionResponse, error)
- func (c *Spclient) ExtendedMetadataSimple(ctx context.Context, id librespot.SpotifyId, ext extmetadatapb.ExtensionKind, ...) error
- func (c *Spclient) GetAccessToken(ctx context.Context, force bool) (string, error)
- func (c *Spclient) ListCurrentStates(ctx context.Context, reqProto *resumptionpb.ListCurrentStatesRequest) (*resumptionpb.ListCurrentStatesResponse, error)
- func (c *Spclient) NarrationUrl(ctx context.Context, req *narrationpb.TtsRequest) (string, error)
- func (c *Spclient) NetFortune(ctx context.Context, bandwidth int) (*netfortunepb.NetFortuneV2Response, error)
- func (c *Spclient) PlayPlayRequest(ctx context.Context, fileId []byte, ...) (*streamingpb.PlayPlayLicenseResponse, error)
- func (c *Spclient) PlaylistAppend(ctx context.Context, playlist librespot.SpotifyId, username string, ...) error
- func (c *Spclient) PlaylistContext(ctx context.Context, playlist librespot.SpotifyId) (*connectpb.Context, error)
- func (c *Spclient) PlaylistPage(ctx context.Context, pageUrl string) (*connectpb.ContextPage, error)
- func (c *Spclient) PlaylistRevision(ctx context.Context, playlist librespot.SpotifyId) ([]byte, error)
- func (c *Spclient) PlaylistSignals(ctx context.Context, playlist librespot.SpotifyId, ...) (*playlist4pb.SelectedListContent, error)
- func (c *Spclient) PublishEvents(ctx context.Context, reqProto *eventsenderpb.PublishEventsRequest) (*eventsenderpb.PublishEventsResponse, error)
- func (c *Spclient) PutConnectState(ctx context.Context, spotConnId string, reqProto *connectpb.PutStateRequest) (*connectpb.Cluster, error)
- func (c *Spclient) PutConnectStateInactive(ctx context.Context, spotConnId string, notify bool) error
- func (c *Spclient) PutConnectStateRaw(ctx context.Context, spotConnId string, reason connectpb.PutStateReason, ...) (*connectpb.Cluster, error)
- func (c *Spclient) Request(ctx context.Context, method string, path string, query url.Values, ...) (*http.Response, error)
- func (c *Spclient) RequestHm(ctx context.Context, method string, hmUrl string, header http.Header, ...) (*http.Response, error)
- func (c *Spclient) RequestNoRedirect(ctx context.Context, method string, path string, query url.Values, ...) (*http.Response, error)
- func (c *Spclient) RequestOnce(ctx context.Context, method string, path string, query url.Values, ...) (*http.Response, error)
- func (c *Spclient) ResolveStorageInteractive(ctx context.Context, fileId []byte, format *metadatapb.AudioFile_Format, ...) (*storagepb.StorageResolveResponse, error)
- func (c *Spclient) ResumePositionMs(ctx context.Context, id librespot.SpotifyId) (int64, error)
- func (c *Spclient) Rootlist(ctx context.Context, username string, from, length int) (*playlist4pb.SelectedListContent, error)
- func (c *Spclient) SetResumeFinished(ctx context.Context, id librespot.SpotifyId) error
- func (c *Spclient) SetResumePositionMs(ctx context.Context, id librespot.SpotifyId, positionMs int64) error
- type StatusError
Constants ¶
const CollectionSetLikedSongs = "collection"
CollectionSetLikedSongs is the collection set holding the user's Liked Songs.
Variables ¶
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
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 (*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 (r *ContextResolver) Type() librespot.SpotifyIdType
func (*ContextResolver) Uri ¶
func (r *ContextResolver) Uri() string
type RateLimitedError ¶ added in v0.8.0
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 (*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 (*Spclient) ContextResolveAutoplay ¶
func (*Spclient) ContextResolveUrl ¶ added in v0.9.0
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 (c *Spclient) CreateResumePointRevision(ctx context.Context, reqProto *resumptionpb.CreateResumePointRevisionRequest) (*resumptionpb.CreateResumePointRevisionResponse, error)
func (*Spclient) ExtendedMetadata ¶ added in v0.3.3
func (c *Spclient) ExtendedMetadata(ctx context.Context, req *extmetadatapb.BatchedEntityRequest) (*extmetadatapb.BatchedExtensionResponse, error)
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 (*Spclient) ListCurrentStates ¶ added in v0.8.0
func (c *Spclient) ListCurrentStates(ctx context.Context, reqProto *resumptionpb.ListCurrentStatesRequest) (*resumptionpb.ListCurrentStatesResponse, error)
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 (c *Spclient) PublishEvents(ctx context.Context, reqProto *eventsenderpb.PublishEventsRequest) (*eventsenderpb.PublishEventsResponse, error)
func (*Spclient) PutConnectState ¶
func (*Spclient) PutConnectStateInactive ¶
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) 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
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
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.
type StatusError ¶ added in v0.10.3
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