gospot

package module
v0.0.0-...-b6ccf7d Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: BSD-3-Clause Imports: 20 Imported by: 0

README

gospot

librespot-go wrapper that makes it not painful to use

docs:

https://pkg.go.dev/github.com/ambeloe/gospot

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEBUG = false
View Source
var ErrMissingImg = errors.New("missing image")

ErrMissingImg todo: engooden

Functions

func SanityCheck

func SanityCheck(tracks []TrackStub) bool

SanityCheck makes sure that all the tracks have an id associated with them because 90% of anything spotify related will silently fail. returns true if all is good

Types

type Album

type Album struct {
	Id      string
	Name    string
	Artists []Artist
	Date    string //iso8061 date
	Songs   []TrackStub
	Stub    *Spotify.Album `json:",omitempty"`
}

type Artist

type Artist struct {
	Id     string
	Name   string
	Genres []string
	Stub   *Spotify.Artist `json:",omitempty"`
}

type Audio

type Audio struct {
	Format Spotify.AudioFile_Format
	File   *[]byte
}

type FormatType

type FormatType byte
const (
	FormatMp3        FormatType = 1
	FormatOgg        FormatType = 2
	FormatBestEffort FormatType = 3
)

type Image

type Image struct {
	Id   []byte
	File []byte
}

type LocalStore

type LocalStore struct {
	Username   string
	AuthBlob   []byte
	DeviceName string

	OauthToken OToken
}

type OToken

type OToken struct {
	IssueTime time.Time
	Token     *metadata.Token
}

func (OToken) ToOauthToken

func (o OToken) ToOauthToken() *oauth2.Token

type Playlist

type Playlist struct {
	Id      string
	Name    string
	Thumb   Image
	Len     int
	Songs   []TrackStub
	Stub    *Spotify.Playlist     `json:",omitempty"`
	APIStub *spotify.FullPlaylist `json:",omitempty"`
}

type Session

type Session struct {
	Ls   *LocalStore
	Sess *core.Session
}

func Login

func Login(confFile string, debug bool) (Session, error)

func (*Session) GetAlbum

func (s *Session) GetAlbum(id string) (Album, error)

func (*Session) GetArtist

func (s *Session) GetArtist(id string) (Artist, error)

func (*Session) GetAudio

func (s *Session) GetAudio(t TrackStub, format FormatType) (Audio, error)

GetAudio returns the audio file in the desired format, starting at high bitrate then going lower if not available. Throws error if audio of type cannot be found.

func (*Session) GetLikedSongs

func (s *Session) GetLikedSongs() ([]TrackStub, error)

GetLikedSongs may take forever if you have a ton of songs since it only gets them in chunks of 50

func (*Session) GetOauthToken

func (s *Session) GetOauthToken(scope string) (*metadata.Token, error)

GetOauthToken gets an access token with all scopes if scope is empty or with the specified scopes

func (*Session) GetPlaylist

func (s *Session) GetPlaylist(id string, stubOnly bool) (Playlist, error)

func (*Session) GetPlaylistMercury

func (s *Session) GetPlaylistMercury(id string, stubOnly bool) (Playlist, error)

GetPlaylistMercury "same" as GetPlaylist but uses mercury api instead of the public api. Might be faster, but also can't get playlist images and likes to fail silently.

func (*Session) GetRootPlaylist

func (s *Session) GetRootPlaylist() ([]Playlist, error)

func (*Session) GetTrack

func (s *Session) GetTrack(trackId string) (TrackStub, error)

func (*Session) GetTrackFull

func (s *Session) GetTrackFull(stub TrackStub) (Track, error)

func (*Session) GetTrackStub

func (s *Session) GetTrackStub(trackId string) (TrackStub, error)

func (*Session) PromoteStub

func (s *Session) PromoteStub(t *TrackStub) error

func (*Session) ValidToken

func (s *Session) ValidToken() (string, error)

ValidToken for internal use or if you don't want to maintain the token yourself; returns a valid token; uses the cached one if it is still valid, else gets a new one and updates the cache

type Track

type Track struct {
	Id string

	Title   string
	Artists []Artist
	Album   Album
	Number  int

	Art   Image `json:"-"`
	Sound Audio `json:"-"`

	Stub *Spotify.Track `json:",omitempty"`
}

type TrackStub

type TrackStub struct {
	Id     string
	STrack *Spotify.Track `json:",omitempty"`
}

func (TrackStub) GetArtists

func (t TrackStub) GetArtists() ([]Artist, error)

func (TrackStub) GetImage

func (t TrackStub) GetImage() (Image, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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