Documentation
¶
Overview ¶
Package providers reads playlist metadata through public HTTP APIs and asks a service for the audio address the account is entitled to. The only media it decrypts is Beatport's player stream for the account's own Essential subscription (beatport_hls.go). Each instance belongs to one account.
Index ¶
- Constants
- Variables
- func Camelot(pitch, mode int) string
- func IsDeezerUserID(s string) bool
- func JSON(ctx context.Context, c *http.Client, method, endpoint string, body io.Reader, ...) error
- func LoadSpotifyDeviceID(stateDir string) (string, error)
- func ParseSpotifyLinks(text string) [][2]string
- func RandomID() string
- func SaveJSON(path string, v any) error
- func SpotifyDeviceID(seed string) string
- type Album
- type AppleMusic
- func (a *AppleMusic) CredGen() uint64
- func (a *AppleMusic) DeveloperToken(ctx context.Context) (string, error)
- func (a *AppleMusic) Download(ctx context.Context, t Track) (*AppleMusicAudio, error)
- func (a *AppleMusic) DownloadTo(ctx context.Context, t Track, dstDir, name string) (*AppleMusicAudio, error)
- func (a *AppleMusic) FavoriteAlbums(ctx context.Context) ([]AppleMusicAlbum, error)
- func (a *AppleMusic) Forget() error
- func (a *AppleMusic) HelperConfig() AppleMusicHelperConfig
- func (a *AppleMusic) HelperLogin2FA(ctx context.Context, code string) (AppleMusicHelperStatus, error)
- func (a *AppleMusic) HelperLoginBegin(ctx context.Context, username, password string) (AppleMusicHelperStatus, error)
- func (a *AppleMusic) HelperStatus(ctx context.Context) AppleMusicHelperStatus
- func (a *AppleMusic) Load() error
- func (a *AppleMusic) Logout() error
- func (a *AppleMusic) Owner() AppleMusicOwner
- func (a *AppleMusic) Playlists(ctx context.Context) ([]Playlist, error)
- func (a *AppleMusic) ProbeHelper(ctx context.Context, cooldown time.Duration) AppleMusicHelperStatus
- func (a *AppleMusic) Ready() bool
- func (a *AppleMusic) Search(ctx context.Context, query string) ([]Track, error)
- func (a *AppleMusic) SearchPlaylists(ctx context.Context, query string) ([]Playlist, error)
- func (a *AppleMusic) SetHelper(helperURL, loginURL, token string)
- func (a *AppleMusic) SetOwner(ctx context.Context, o AppleMusicOwner) error
- func (a *AppleMusic) Tracks(ctx context.Context, id string) ([]Track, error)
- type AppleMusicAlbum
- type AppleMusicAudio
- type AppleMusicHelperConfig
- type AppleMusicHelperStatus
- type AppleMusicLink
- type AppleMusicOwner
- type AudioFeatures
- func ExtractReccoBeatsAudioFeatures(ctx context.Context, client *http.Client, baseURL string, audio io.Reader) (AudioFeatures, error)
- func FetchReccoBeatsAudioFeatures(ctx context.Context, client *http.Client, baseURL, trackID string) (AudioFeatures, error)
- func FilterByAudioFeatures(items []AudioFeatures, ...) []AudioFeatures
- type BPMConfig
- type BPMInfo
- type BPMStore
- func (b *BPMStore) Apply(tracks []Track)
- func (b *BPMStore) Config() BPMConfig
- func (b *BPMStore) Enrich(ctx context.Context, tracks []Track)
- func (b *BPMStore) Put(t Track, info BPMInfo) error
- func (b *BPMStore) SaveConfig(v BPMConfig) error
- func (b *BPMStore) UpdateConfig(fn func(*BPMConfig)) error
- type Beatport
- func (b *Beatport) Download(ctx context.Context, id string, lossless bool) (location, ext string, err error)
- func (b *Beatport) Forget() error
- func (b *Beatport) Login(ctx context.Context, username, password string) error
- func (b *Beatport) Playlists(ctx context.Context) ([]Playlist, error)
- func (b *Beatport) Ready() bool
- func (b *Beatport) SaveStream(ctx context.Context, id string, w io.WriteSeeker) error
- func (b *Beatport) Search(ctx context.Context, query string) ([]Track, error)
- func (b *Beatport) SetToken(t BeatportToken) error
- func (b *Beatport) Token() BeatportToken
- func (b *Beatport) Tracks(ctx context.Context, id string) ([]Track, error)
- type BeatportToken
- type Deezer
- func (d *Deezer) ByID(ctx context.Context, id string) (Track, error)
- func (d *Deezer) ByISRC(ctx context.Context, isrc string) (Track, error)
- func (d *Deezer) ChartPlaylists(ctx context.Context) ([]Playlist, error)
- func (d *Deezer) IdentifyARL(ctx context.Context, arl string) (string, error)
- func (d *Deezer) Playlists(ctx context.Context) ([]Playlist, error)
- func (d *Deezer) ResolveUser(ctx context.Context, raw string) (string, error)
- func (d *Deezer) Search(ctx context.Context, query string) ([]Track, error)
- func (d *Deezer) SearchPlaylists(ctx context.Context, query string) ([]Playlist, error)
- func (d *Deezer) Tracks(ctx context.Context, id string) ([]Track, error)
- type NASConfig
- type Netease
- func (n *Netease) AudioURL(ctx context.Context, id string, lossless, allowLossy bool) (string, error)
- func (n *Netease) BeginQR(ctx context.Context) (QRLogin, error)
- func (n *Netease) FavoriteAlbums(ctx context.Context) ([]Album, error)
- func (n *Netease) LoggedIn() bool
- func (n *Netease) Playlists(ctx context.Context) ([]Playlist, error)
- func (n *Netease) PollQR(ctx context.Context, key string) (int, error)
- func (n *Netease) Search(ctx context.Context, query string) ([]Track, error)
- func (n *Netease) SearchPlaylists(ctx context.Context, query string) ([]Playlist, error)
- func (n *Netease) Tracks(ctx context.Context, id string) ([]Track, error)
- type Playlist
- type Provider
- type QRLogin
- type RateLimited
- type SelfHostedProvider
- func (p *SelfHostedProvider) Config() NASConfig
- func (p *SelfHostedProvider) DownloadTrack(ctx context.Context, trackID, destDir string) (string, error)
- func (p *SelfHostedProvider) PlaylistTracks(ctx context.Context, playlistID string) ([]Track, error)
- func (p *SelfHostedProvider) Playlists(ctx context.Context) ([]Playlist, error)
- func (p *SelfHostedProvider) Search(ctx context.Context, query string) ([]Track, error)
- func (p *SelfHostedProvider) Tracks(ctx context.Context, playlistID string) ([]Track, error)
- type SoundCloud
- func (s *SoundCloud) HasGoPlus(ctx context.Context) bool
- func (s *SoundCloud) Identify(ctx context.Context) error
- func (s *SoundCloud) Media(ctx context.Context, id string, lossless bool) (SoundCloudMedia, error)
- func (s *SoundCloud) Playlists(ctx context.Context) ([]Playlist, error)
- func (s *SoundCloud) ResolveUser(ctx context.Context, raw string) error
- func (s *SoundCloud) Search(ctx context.Context, query string) ([]Track, error)
- func (s *SoundCloud) SearchPlaylists(ctx context.Context, query string) ([]Playlist, error)
- func (s *SoundCloud) Tracks(ctx context.Context, id string) ([]Track, error)
- type SoundCloudAuth
- type SoundCloudMedia
- type Spotify
- func (s *Spotify) AcceptToken(ctx context.Context, t Token) error
- func (s *Spotify) BeginDeviceAuth(ctx context.Context) (*SpotifyDeviceAuth, error)
- func (s *Spotify) BeginPKCE(state, redirect string) (authURL, verifier string)
- func (s *Spotify) Close()
- func (s *Spotify) CompletePKCE(ctx context.Context, code, verifier, redirect string) error
- func (s *Spotify) ConnectZeroconf(ctx context.Context, username string, blob []byte) error
- func (s *Spotify) DeviceAuthorizationEnabled() bool
- func (p *Spotify) DownloadAudio(ctx context.Context, trackID, dstDir string) (string, error)
- func (s *Spotify) ExchangeOAuthCredentials(ctx context.Context) error
- func (s *Spotify) HasLinks() bool
- func (s *Spotify) HasStoredCredentials() bool
- func (s *Spotify) HasToken() bool
- func (s *Spotify) LoadToken() error
- func (s *Spotify) Logout() error
- func (s *Spotify) Playlists(ctx context.Context) ([]Playlist, error)
- func (s *Spotify) PollDeviceAuthorization(ctx context.Context, d *SpotifyDeviceAuth) (bool, error)
- func (s *Spotify) Search(ctx context.Context, query string) ([]Track, error)
- func (s *Spotify) SearchPlaylists(ctx context.Context, query string) ([]Playlist, error)
- func (s *Spotify) SetClientID(id string)
- func (s *Spotify) SetLinks(ctx context.Context, text string) (int, error)
- func (s *Spotify) SetToken(t Token) error
- func (s *Spotify) Tracks(ctx context.Context, id string) ([]Track, error)
- type SpotifyConnectInfo
- type SpotifyConnectKey
- type SpotifyConnectResponse
- type SpotifyConnectUser
- type SpotifyDeviceAuth
- type StatusError
- type Token
- type Track
Constants ¶
const AppleMusicLikedID = "liked"
AppleMusicLikedID names the owner's library & favourite songs view.
const (
// BeatportClientID is the public client of Beatport's own API documentation page.
BeatportClientID = "ryZ8LuyQVPqbK2mBX2Hwt4qSMtnWuTYSqBPO92yQ"
)
const (
DefaultReccoURL = "https://api.reccobeats.com"
)
const GuestPlaylist = "[Guest / 临时加歌]"
const OwnerPlaylist = "[Stream / 临时下载]"
const SpotifyLikedID = "liked"
SpotifyLikedID names the owner's Liked Songs, which Spotify keeps outside playlists.
Variables ¶
var ErrNoFullAudio = errors.New("netease: no full-length audio for this account")
ErrNoFullAudio means the account only gets a preview of this track, or nothing.
var ErrNoFullStream = errors.New("soundcloud: no full-length stream for this track")
ErrNoFullStream means the API only offers a preview of the track.
var ErrSpotifyAuthentication = errors.New("spotify: permanent authentication failure")
var ErrSpotifyDeviceAuthExpired = errors.New("spotify: device authorization expired or denied")
var ErrSpotifyPairingBusy = errors.New("spotify: authentication is busy")
var SpotifyBuiltinClientID = librespot.ClientIdHex
SpotifyBuiltinClientID is go-librespot's public desktop identity.
Functions ¶
func IsDeezerUserID ¶
IsDeezerUserID reports whether s has the form of a Deezer user ID.
func JSON ¶
func JSON(ctx context.Context, c *http.Client, method, endpoint string, body io.Reader, headers http.Header, out any) error
JSON performs bounded HTTP I/O and deliberately omits response bodies from errors: authentication services sometimes echo cookies or access tokens.
func LoadSpotifyDeviceID ¶
LoadSpotifyDeviceID gives each deck its own identity, shared by AP and Zeroconf. O_CREATE|O_EXCL creates a 0600 file on exFAT/vfat as well as POSIX filesystems without ever overwriting an existing identity.
func ParseSpotifyLinks ¶
ParseSpotifyLinks returns the playlist/album references (kind, id) found in text.
func SaveJSON ¶
SaveJSON replaces an owner credential file atomically with mode 0600. Guest credentials stay in memory and must never be passed here.
func SpotifyDeviceID ¶
Types ¶
type AppleMusic ¶
type AppleMusic struct {
BaseURL, WebURL string // api.music.apple.com and music.apple.com; tests override
HTTP *http.Client
OwnerPath string // where the owner's links and token are saved, mode 0600
// HelperURL is the enginex-amd helper (LAN/VPS); empty disables downloads.
HelperURL, HelperLoginURL, HelperToken string
// contains filtered or unexported fields
}
AppleMusic reads playlists from Apple Music's catalog (public playlist and album links, no account) and, with the owner's media-user-token, from their library (#65). Audio downloads are supplied by the enginex-amd helper.
func (*AppleMusic) CredGen ¶
func (a *AppleMusic) CredGen() uint64
CredGen returns a monotonic counter incremented when owner credentials change.
func (*AppleMusic) DeveloperToken ¶
func (a *AppleMusic) DeveloperToken(ctx context.Context) (string, error)
DeveloperToken is the token the phone page hands to MusicKit JS.
func (*AppleMusic) Download ¶
func (a *AppleMusic) Download(ctx context.Context, t Track) (*AppleMusicAudio, error)
func (*AppleMusic) DownloadTo ¶
func (a *AppleMusic) DownloadTo(ctx context.Context, t Track, dstDir, name string) (*AppleMusicAudio, error)
DownloadTo writes on the destination filesystem and publishes only a complete file.
func (*AppleMusic) FavoriteAlbums ¶
func (a *AppleMusic) FavoriteAlbums(ctx context.Context) ([]AppleMusicAlbum, error)
FavoriteAlbums lists saved library albums and any pasted album links.
func (*AppleMusic) Forget ¶
func (a *AppleMusic) Forget() error
Forget clears the owner's account credentials and links in memory and removes the persisted owner file, leaving any configured download helper intact.
func (*AppleMusic) HelperConfig ¶
func (a *AppleMusic) HelperConfig() AppleMusicHelperConfig
func (*AppleMusic) HelperLogin2FA ¶
func (a *AppleMusic) HelperLogin2FA(ctx context.Context, code string) (AppleMusicHelperStatus, error)
func (*AppleMusic) HelperLoginBegin ¶
func (a *AppleMusic) HelperLoginBegin(ctx context.Context, username, password string) (AppleMusicHelperStatus, error)
func (*AppleMusic) HelperStatus ¶
func (a *AppleMusic) HelperStatus(ctx context.Context) AppleMusicHelperStatus
func (*AppleMusic) Load ¶
func (a *AppleMusic) Load() error
Load reads the saved owner login; a missing file is no login.
func (*AppleMusic) Logout ¶
func (a *AppleMusic) Logout() error
Logout clears the owner's account credentials on sign-out.
func (*AppleMusic) Owner ¶
func (a *AppleMusic) Owner() AppleMusicOwner
Owner is the saved login, for the phone page to amend.
func (*AppleMusic) Playlists ¶
func (a *AppleMusic) Playlists(ctx context.Context) ([]Playlist, error)
Playlists lists the saved links first, then the library. One broken link does not hide the others.
func (*AppleMusic) ProbeHelper ¶
func (a *AppleMusic) ProbeHelper(ctx context.Context, cooldown time.Duration) AppleMusicHelperStatus
ProbeHelper checks helper status at most once per cooldown when unready so an offline helper does not stall every gateway browse or search request.
func (*AppleMusic) Ready ¶
func (a *AppleMusic) Ready() bool
Ready reports whether there is anything to show: a link, a library login, or an active helper session.
func (*AppleMusic) SearchPlaylists ¶
SearchPlaylists looks up catalog playlists in the owner's storefront.
func (*AppleMusic) SetHelper ¶
func (a *AppleMusic) SetHelper(helperURL, loginURL, token string)
func (*AppleMusic) SetOwner ¶
func (a *AppleMusic) SetOwner(ctx context.Context, o AppleMusicOwner) error
SetOwner checks and saves a login from the phone page. Links that do not open are refused, so a typo never becomes an empty playlist on the deck.
type AppleMusicAlbum ¶
type AppleMusicAlbum struct {
ID string
ListID string
Name string
ArtistName string
TrackCount int
}
AppleMusicAlbum is a saved album from the owner's library or pasted album links.
type AppleMusicAudio ¶
Download asks the enginex-amd helper for a FLAC of t. The helper owns the Apple Music session; the deck only receives the finished file. AppleMusicAudio is the helper's finished file and quality.
type AppleMusicHelperConfig ¶
type AppleMusicHelperConfig struct {
URL string `json:"url"`
LoginURL string `json:"loginUrl"`
Token string `json:"token"`
}
AppleMusicHelperConfig is persisted separately from the browsing account.
type AppleMusicHelperStatus ¶
type AppleMusicLink ¶
type AppleMusicLink struct{ Storefront, Kind, ID string }
AppleMusicLink is one parsed music.apple.com playlist or album address.
func ParseAppleMusicLinks ¶
func ParseAppleMusicLinks(text string) []AppleMusicLink
ParseAppleMusicLinks finds every playlist or album link in pasted text, as Share → Copy Link gives them. Unknown text is ignored.
func (AppleMusicLink) URL ¶
func (l AppleMusicLink) URL() string
URL is the short form saved for the owner.
type AppleMusicOwner ¶
type AppleMusicOwner struct {
Links []string `json:"links,omitempty"`
UserToken string `json:"mediaUserToken,omitempty"`
Storefront string `json:"storefront,omitempty"`
DevToken string `json:"developerToken,omitempty"` // optional override of the web player's token
}
AppleMusicOwner is what the phone page saves.
type AudioFeatures ¶
type AudioFeatures struct {
ID string `json:"id"`
Energy float64 `json:"energy"`
Danceability float64 `json:"danceability"`
Valence float64 `json:"valence"`
Acousticness float64 `json:"acousticness"`
Instrumentalness float64 `json:"instrumentalness"`
Speechiness float64 `json:"speechiness"`
Liveness float64 `json:"liveness"`
Tempo float64 `json:"tempo"`
}
AudioFeatures represents the audio feature metrics returned by ReccoBeats.
func ExtractReccoBeatsAudioFeatures ¶
func ExtractReccoBeatsAudioFeatures(ctx context.Context, client *http.Client, baseURL string, audio io.Reader) (AudioFeatures, error)
ExtractReccoBeatsAudioFeatures extracts audio features from an audio stream via POST /v1/analysis/audio-features.
func FetchReccoBeatsAudioFeatures ¶
func FetchReccoBeatsAudioFeatures(ctx context.Context, client *http.Client, baseURL, trackID string) (AudioFeatures, error)
FetchReccoBeatsAudioFeatures retrieves the audio features for a given track ID via GET /v1/track/{id}/audio-features.
func FilterByAudioFeatures ¶
func FilterByAudioFeatures(items []AudioFeatures, minEnergy, maxEnergy, minDance, maxDance, minValence, maxValence float64) []AudioFeatures
FilterByAudioFeatures filters items by energy, danceability, and valence min/max bounds.
type BPMConfig ¶
type BPMConfig struct {
SoundCloudClientID string `json:"soundcloudClientId,omitempty"`
SoundCloudSecret string `json:"soundcloudClientSecret,omitempty"`
SoundCloudToken string `json:"soundcloudToken,omitempty"`
GetSongBPMKey string `json:"getSongBpmKey,omitempty"`
}
BPMConfig holds the optional keys of services that need one.
type BPMStore ¶
type BPMStore struct {
Path, ConfigPath string
HTTP *http.Client
ReccoURL string
SoundCloudURL string
GetSongURL string
DeezerURL string
// SoundCloudAuth is the token store shared with the SoundCloud source.
SoundCloudAuth *SoundCloudAuth
// Spotify returns the owner's login, if any, for finding a track's IDs.
Spotify func() *Spotify
// PreviewBPM estimates tempo and key from a preview clip, for tracks too new
// for any catalog. It is the last resort and never replaces a measured value.
PreviewBPM func(ctx context.Context, previewURL string) BPMInfo
// PreviewAllowed overrides the accepted clip hosts in tests.
PreviewAllowed func(*url.URL) bool
// contains filtered or unexported fields
}
func (*BPMStore) Enrich ¶
Enrich fills a list in place from the cache and one quick batch lookup. Lists must open at once, so everything else is looked up behind the scenes and shows the next time the list opens.
func (*BPMStore) Put ¶
Put records a tempo for a track. A measured value replaces a looked-up one, and never the other way round.
func (*BPMStore) SaveConfig ¶
SaveConfig writes the optional service keys under b.mu so concurrent readers and writers serialize cleanly.
func (*BPMStore) UpdateConfig ¶
UpdateConfig atomically reads, modifies, and writes BPMConfig under b.mu.
type Beatport ¶
type Beatport struct {
BaseURL string
HTTP *http.Client
Path string
// contains filtered or unexported fields
}
Beatport is one account. Path keeps its login (0600); empty keeps it in memory. The owner's instance is shared, because every refresh replaces the refresh token.
func (*Beatport) Download ¶
func (b *Beatport) Download(ctx context.Context, id string, lossless bool) (location, ext string, err error)
Download finds the signed address of a track's file at the best quality the subscription allows: FLAC, then 256k AAC (Professional), then 128k AAC (Advanced). ext is flac or mp4. Essential gets none of them and uses SaveStream instead.
func (*Beatport) Login ¶
Login signs in as Beatport's website does, then exchanges the session for an API token. The password is not kept; when the refresh token runs out, the owner logs in again.
func (*Beatport) Playlists ¶
Playlists lists the account's own playlists, then Beatport's newest charts, so a new account still has something to browse.
func (*Beatport) SaveStream ¶
SaveStream writes a track's stream to w as an MP4 file.
func (*Beatport) SetToken ¶
func (b *Beatport) SetToken(t BeatportToken) error
SetToken replaces the login and saves it.
func (*Beatport) Token ¶
func (b *Beatport) Token() BeatportToken
Token returns the current login, which the relay hands on to the deck.
type BeatportToken ¶
type BeatportToken struct {
Access string `json:"access_token"`
Refresh string `json:"refresh_token,omitempty"`
Expiry time.Time `json:"expiry,omitzero"`
}
BeatportToken is an account login. Expiry is zero when unknown (a pasted token).
func ParseBeatportToken ¶
func ParseBeatportToken(text string) (BeatportToken, error)
ParseBeatportToken reads a pasted token: the JSON Beatport's token endpoint returns, or the bare access token.
type Deezer ¶
type Deezer struct {
BaseURL string
UserID string
// ARL is the owner's Deezer login cookie, kept with the linked profile.
ARL string
// GatewayURL overrides https://www.deezer.com in tests.
GatewayURL string
HTTP *http.Client
}
func (*Deezer) ChartPlaylists ¶
func (*Deezer) IdentifyARL ¶
IdentifyARL asks Deezer whose login cookie this is, and never echoes it.
func (*Deezer) ResolveUser ¶
ResolveUser finds the user ID in an ID, a profile or playlist link, or a short link, whose redirects are followed only within Deezer's own hosts.
func (*Deezer) SearchPlaylists ¶
type NASConfig ¶
type NASConfig struct {
Protocol string `json:"protocol"` // "webdav", "subsonic", "plex", "smb"
URL string `json:"url"` // e.g. "https://nas.example.com/music" or "http://192.168.1.10:4533"
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Token string `json:"token,omitempty"` // Plex X-Plex-Token or Bearer token
Enabled bool `json:"enabled"`
}
type Netease ¶
type Netease struct {
BaseURL string
WebURL string // overrides https://music.163.com in tests
HTTP *http.Client
CookiePath string
Cookie string
UserID int64
// contains filtered or unexported fields
}
Netease speaks to music.163.com directly, or to a NeteaseCloudMusicApi-compatible service when BaseURL is set.
func (*Netease) AudioURL ¶
func (n *Netease) AudioURL(ctx context.Context, id string, lossless, allowLossy bool) (string, error)
AudioURL returns the address NetEase gives this account for a track at the best quality on offer, starting at 320k MP3 unless lossless is wanted. Previews never count: a DJ must not load 30 seconds of a song. When lossy audio is forbidden, a lossless request never tries the MP3 levels.
func (*Netease) FavoriteAlbums ¶
FavoriteAlbums lists the albums the account has saved.
func (*Netease) LoggedIn ¶
LoggedIn reports whether a user cookie is bound, safe against concurrent login.
func (*Netease) SearchPlaylists ¶
type Provider ¶
type Provider interface {
Playlists(context.Context) ([]Playlist, error)
Tracks(context.Context, string) ([]Track, error)
}
Listing methods may return an ordered successful prefix together with an error. A non-nil error means the list is incomplete, including auth failures.
type RateLimited ¶
RateLimited is a 429 with the wait its Retry-After header asked for (0: none given). It reads and matches as StatusError(429), so older checks still hold.
func (*RateLimited) As ¶
func (e *RateLimited) As(target any) bool
func (*RateLimited) Error ¶
func (e *RateLimited) Error() string
func (*RateLimited) Is ¶
func (e *RateLimited) Is(target error) bool
type SelfHostedProvider ¶
type SelfHostedProvider struct {
// contains filtered or unexported fields
}
func NewSelfHostedProvider ¶
func NewSelfHostedProvider(cfg NASConfig, c *http.Client) *SelfHostedProvider
func (*SelfHostedProvider) Config ¶
func (p *SelfHostedProvider) Config() NASConfig
func (*SelfHostedProvider) DownloadTrack ¶
func (*SelfHostedProvider) PlaylistTracks ¶
func (*SelfHostedProvider) Playlists ¶
func (p *SelfHostedProvider) Playlists(ctx context.Context) ([]Playlist, error)
type SoundCloud ¶
type SoundCloud struct {
BaseURL string
HTTP *http.Client
ClientID string
Secret string
Token string // a user's own token, which also reaches private content
Auth *SoundCloudAuth
UserID int64
Username string
WebURL string // overrides the web API in tests
SiteURL string // overrides soundcloud.com in tests
// contains filtered or unexported fields
}
func (*SoundCloud) HasGoPlus ¶
func (s *SoundCloud) HasGoPlus(ctx context.Context) bool
HasGoPlus reports whether the logged-in account has a Go/Go+ subscription, which is what makes preview-only (SNIP) tracks play in full. An app token or public profile never does. A failed /me lookup counts as no and is retried.
func (*SoundCloud) Identify ¶
func (s *SoundCloud) Identify(ctx context.Context) error
Identify fills in the account behind a user's token. An app token has no user.
func (*SoundCloud) Media ¶
func (s *SoundCloud) Media(ctx context.Context, id string, lossless bool) (SoundCloudMedia, error)
Media finds where to download a track's whole audio from. The preview address is never used, however it is offered. Lossless also looks for the original upload, which is far larger: a stream of an hour-long set is 60 MB, the WAV 600 MB.
func (*SoundCloud) Playlists ¶
func (s *SoundCloud) Playlists(ctx context.Context) ([]Playlist, error)
Playlists lists Likes, the account's own playlists, then the ones it liked.
func (*SoundCloud) ResolveUser ¶
func (s *SoundCloud) ResolveUser(ctx context.Context, raw string) error
ResolveUser finds a profile from a link, a share link or a username. An app token is enough, since profiles are public.
func (*SoundCloud) SearchPlaylists ¶
type SoundCloudAuth ¶
type SoundCloudAuth struct {
TokenURL string
Path string
HTTP *http.Client
// contains filtered or unexported fields
}
SoundCloudAuth exchanges an app's credentials for an access token. SoundCloud limits how often that may happen, so the token is shared and kept in a file.
func (*SoundCloudAuth) HasUser ¶
func (a *SoundCloudAuth) HasUser() bool
HasUser reports whether the owner logged in with an account.
func (*SoundCloudAuth) SetUser ¶
func (a *SoundCloudAuth) SetUser(access, refresh string, expiry time.Time) error
SetUser stores the owner's account login. Empty values clear it.
type SoundCloudMedia ¶
type SoundCloudMedia struct {
Ext string // mp3, or mp4 for AAC
URLs []string
// Original is the uploader's own file (often WAV or FLAC), offered only when
// lossless was asked for and the uploader allows downloads.
Original string
}
SoundCloudMedia is a track's audio: one address, or a list of segments to join.
type Spotify ¶
type Spotify struct {
BaseURL, AccountsURL, ClientID, TokenPath string
CredsPath, DeviceID string
StreamURL string
LinksPath, EmbedURL string // public playlist links (spotify_links.go)
AudioKey []byte
HTTP *http.Client
Token Token
// contains filtered or unexported fields
}
func (*Spotify) BeginDeviceAuth ¶
func (s *Spotify) BeginDeviceAuth(ctx context.Context) (*SpotifyDeviceAuth, error)
func (*Spotify) BeginPKCE ¶
BeginPKCE returns an authorization URL and a private verifier. The caller binds state, verifier, redirect URI and expiry to the initiating session.
func (*Spotify) CompletePKCE ¶
func (*Spotify) ConnectZeroconf ¶
ConnectZeroconf accepts the decrypted outer DH payload. ConnectBlob implements the inner SHA1(deviceID)/PBKDF2/AES-192-ECB/XOR authentication envelope.
func (*Spotify) DeviceAuthorizationEnabled ¶
func (*Spotify) DownloadAudio ¶
DownloadAudio fetches audio stream for trackID and writes it to dstDir as spotify-<trackID>.ogg.
func (*Spotify) ExchangeOAuthCredentials ¶
ExchangeOAuthCredentials turns streaming-scoped OAuth into reusable AP login. Custom HTTP endpoints retain the offline test/PKCE path.
func (*Spotify) HasStoredCredentials ¶
func (*Spotify) HasToken ¶
HasToken reports whether a login token is present, safe against concurrent refresh.
func (*Spotify) LoadToken ¶
LoadToken accepts the common OAuth2 expiry string and numeric expires_at.
func (*Spotify) PollDeviceAuthorization ¶
PollDeviceAuthorization makes at most one request, honoring interval/slow_down.
func (*Spotify) SearchPlaylists ¶
func (*Spotify) SetClientID ¶
SetClientID serializes app changes with OAuth token refresh.
func (*Spotify) SetLinks ¶
SetLinks replaces the saved public playlists with those named in text and returns how many were read. A link that cannot be read fails the whole call.
type SpotifyConnectInfo ¶
type SpotifyConnectInfo struct {
Status int `json:"status"`
StatusString string `json:"statusString"`
SpotifyError int `json:"spotifyError"`
Version string `json:"version"`
DeviceID string `json:"deviceID"`
RemoteName string `json:"remoteName"`
PublicKey string `json:"publicKey"`
DeviceType string `json:"deviceType"`
LibraryVersion string `json:"libraryVersion"`
AccountReq string `json:"accountReq"`
TokenType string `json:"tokenType"`
Scope string `json:"scope"`
}
SpotifyConnectInfo represents the Zeroconf getInfo response payload.
type SpotifyConnectKey ¶
type SpotifyConnectKey struct {
// contains filtered or unexported fields
}
SpotifyConnectKey is this process's Zeroconf key pair.
func SpotifyConnectKeyPair ¶
func SpotifyConnectKeyPair() *SpotifyConnectKey
SpotifyConnectKeyPair returns the key pair, generated once per process.
func (*SpotifyConnectKey) DecryptBlob ¶
func (k *SpotifyConnectKey) DecryptBlob(clientKey, blob string) ([]byte, error)
DecryptBlob opens addUser's blob with the phone's clientKey: iv(16) | AES-128-CTR data | HMAC-SHA1(20), keyed from SHA1 of the shared secret. A wrong MAC is an error.
func (*SpotifyConnectKey) PublicKey ¶
func (k *SpotifyConnectKey) PublicKey() string
PublicKey is what getInfo advertises.
type SpotifyConnectResponse ¶
type SpotifyConnectResponse struct {
Status int `json:"status"`
StatusString string `json:"statusString"`
SpotifyError int `json:"spotifyError"`
}
SpotifyConnectResponse represents standard response for Spotify Connect operations.
type SpotifyConnectUser ¶
type SpotifyConnectUser struct {
Action string `json:"action"`
UserName string `json:"userName"`
Blob string `json:"blob"`
AccessToken string `json:"accessToken"`
ClientKey string `json:"clientKey"`
}
SpotifyConnectUser represents the Zeroconf addUser request payload.
type SpotifyDeviceAuth ¶
type SpotifyDeviceAuth struct {
VerificationURL string
UserCode string
Expires time.Time
// contains filtered or unexported fields
}
SpotifyDeviceAuth keeps the private device code out of JSON/UI responses.
type StatusError ¶
type StatusError int
StatusError is a refused request's HTTP status, so callers can tell 401 or 404 apart.
func (StatusError) Error ¶
func (e StatusError) Error() string
type Token ¶
type Token struct {
Scope string `json:"scope,omitempty"`
Username string `json:"username,omitempty"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token,omitempty"`
TokenType string `json:"token_type,omitempty"`
ExpiresIn int64 `json:"expires_in,omitempty"`
Expiry time.Time `json:"expiry,omitempty"`
ExpiresAt int64 `json:"expires_at,omitempty"`
ClientID string `json:"client_id,omitempty"`
}
type Track ¶
type Track struct {
ID string `json:"id"`
CatalogID string `json:"catalogId,omitempty"`
Title string `json:"title"`
Artist string `json:"artist"`
Artists []string `json:"artists,omitempty"`
Album string `json:"album,omitempty"`
ISRC string `json:"isrc,omitempty"`
DurationMS int64 `json:"durationMs"`
Provider string `json:"provider"`
BPM float64 `json:"bpm,omitempty"`
Key string `json:"key,omitempty"` // Camelot, e.g. 8A
Rating int `json:"rating,omitempty"` // 1-5 stars
// PreviewOnly marks a SoundCloud Go+ track that plays only a preview without a Go+ login.
PreviewOnly bool `json:"previewOnly,omitempty"`
// CoverURL is the album artwork, embedded in the downloaded file for the deck.
CoverURL string `json:"coverUrl,omitempty"`
// ThumbURL is a smaller version for list rows, where the service offers one.
ThumbURL string `json:"-"`
// Preview is Deezer's public 30-second MP3, used only to estimate tempo.
Preview string `json:"-"`
}
Source Files
¶
- applemusic.go
- applemusic_helper.go
- beatport.go
- beatport_hls.go
- bpm.go
- deezer.go
- netease.go
- netease_web.go
- pages.go
- provider.go
- reccobeats_features.go
- selfhosted.go
- selfhosted_smb.go
- soundcloud.go
- spotify.go
- spotify_connect.go
- spotify_device_auth.go
- spotify_identity.go
- spotify_library.go
- spotify_librespot.go
- spotify_limit.go
- spotify_links.go
- spotify_metadata.go
- spotify_transport.go