go_librespot

package module
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

README

go-librespot

Yet another open-source Spotify client, written in Go.

Trying it out

Create a config.yml file containing:

device_name: go-librespot
credentials:
  type: interactive

Then run (or grab a prebuilt binary from the releases page):

go run ./cmd/daemon

Follow the instructions on the console for completing authentication and the new device should appear in your Spotify Connect devices.

Alternatively, you can use the Zeroconf mode:

device_name: go-librespot
credentials:
  type: zeroconf

API

The daemon offers an API to control and/or monitor playback. To enable this features add the following to your config.yml file:

server:
  enabled: true
  port: 3678

For API documentation see here.

Building

The daemon can be easily built with:

go build -o go-librespot-daemon ./cmd/daemon

To crosscompile for different architectures the GOOS and GOARCH environment variables can be used.

Development

To recompile protobuf definitions use:

protoc --go_out=proto --go_opt module=git.fish/kotahu/librespot-go/proto -I proto proto/*.proto

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMediaRestricted    = errors.New("media is restricted")
	ErrNoSupportedFormats = errors.New("no supported formats")
)
View Source
var ClientId = []byte{0x65, 0xb7, 0x8, 0x7, 0x3f, 0xc0, 0x48, 0xe, 0xa9, 0x2a, 0x7, 0x72, 0x33, 0xca, 0x87, 0xbd}
View Source
var ClientIdHex = hex.EncodeToString(ClientId)
View Source
var UriRegexp = regexp.MustCompile("^spotify:([a-z]+):([0-9a-zA-Z]{21,22})$")

Functions

func ContextTrackToProvidedTrack

func ContextTrackToProvidedTrack(typ SpotifyIdType, track *connectpb.ContextTrack, provider string) *connectpb.ProvidedTrack

func GetCpuFamily

func GetCpuFamily() spotifypb.CpuFamily

func GetOS

func GetOS() spotifypb.Os

func GetPlatform

func GetPlatform() spotifypb.Platform

func GetPlatformSpecificData

func GetPlatformSpecificData() *clienttokenpb.PlatformSpecificData

func GidToBase62

func GidToBase62(id []byte) string

func SpotifyLikeClientVersion

func SpotifyLikeClientVersion() string

func SystemInfoString

func SystemInfoString() string

func UserAgent

func UserAgent() string

func VersionNumberString

func VersionNumberString() string

func VersionString

func VersionString() string

Types

type AudioSource

type AudioSource interface {
	// SetPositionMs sets the new position in samples
	SetPositionMs(int64) error

	// PositionMs gets the position in samples
	PositionMs() int64

	// Read reads 32bit little endian floats from the stream
	Read([]float32) (int, error)
}

type Float32Reader

type Float32Reader interface {
	// Read reads 32bit little endian floats from the stream
	// until EOF or ErrDrainReader is returned.
	Read([]float32) (n int, err error)
}

type GetAddressFunc

type GetAddressFunc func() string

GetAddressFunc is a function that everytime it is called returns a different address for that type of endpoint.

type GetLogin5TokenFunc

type GetLogin5TokenFunc func(force bool) (string, error)

GetLogin5TokenFunc is a function that everytime it is called returns a valid login5 access token.

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) Duration

func (te Media) Duration() int32

func (Media) Episode

func (te Media) Episode() *metadatapb.Episode

func (Media) IsEpisode

func (te Media) IsEpisode() bool

func (Media) IsTrack

func (te Media) IsTrack() bool

func (Media) Name

func (te Media) Name() string

func (Media) Restriction

func (te Media) Restriction() []*metadatapb.Restriction

func (Media) Track

func (te Media) Track() *metadatapb.Track

type PageResolver

type PageResolver[T any] interface {
	Page(idx int) ([]T, error)
}

type SizedReadAtSeeker

type SizedReadAtSeeker interface {
	io.ReadSeeker
	io.ReaderAt

	Size() int64
}

type SpotifyId

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

func SpotifyIdFromGid

func SpotifyIdFromGid(typ SpotifyIdType, id []byte) SpotifyId

func SpotifyIdFromUri

func SpotifyIdFromUri(uri string) SpotifyId

func SpotifyIdFromUriSafe

func SpotifyIdFromUriSafe(uri string) (_ *SpotifyId, err error)

func (SpotifyId) Base62

func (id SpotifyId) Base62() string

func (SpotifyId) Hex

func (id SpotifyId) Hex() string

func (SpotifyId) Id

func (id SpotifyId) Id() []byte

func (SpotifyId) String

func (id SpotifyId) String() string

func (SpotifyId) Type

func (id SpotifyId) Type() SpotifyIdType

func (SpotifyId) Uri

func (id SpotifyId) Uri() string

type SpotifyIdType

type SpotifyIdType string
const (
	SpotifyIdTypeTrack   SpotifyIdType = "track"
	SpotifyIdTypeEpisode SpotifyIdType = "episode"
)

func InferSpotifyIdTypeFromContextUri

func InferSpotifyIdTypeFromContextUri(uri string) SpotifyIdType

Jump to

Keyboard shortcuts

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