jooki

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: MIT Imports: 19 Imported by: 2

README

jooki

Documentation

Index

Constants

View Source
const (
	PlayModeShuffle = 1
	PlayModeRepeat  = 2
	RepeatModeOff   = RepeatMode(0)
	RepeatModeOn    = RepeatMode(1)
	RepeatModeOnce  = RepeatMode(2)
)
View Source
const (
	PlaybackStateStarting = "STARTING"
	PlaybackStateEnded    = "ENDED"
	PlaybackStatePlaying  = "PLAYING"
	PlaybackStatePaused   = "PAUSED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Audio

type Audio struct {
	Config     *AudioConfig `json:"config"`
	NowPlaying *NowPlaying  `json:"nowPlaying"`
	Playback   *Playback    `json:"playback"`
}

func (*Audio) Clone

func (a *Audio) Clone() *Audio

func (*Audio) UnmarshalJSON added in v0.1.1

func (a *Audio) UnmarshalJSON(data []byte) error

type AudioConfig

type AudioConfig struct {
	RepeatMode  RepeatMode `json:"repeat_mode"`
	ShuffleMode bool       `json:"shuffle_mode"`
	Volume      uint8      `json:"volume"`
}

func (*AudioConfig) Clone

func (a *AudioConfig) Clone() *AudioConfig

type Awaiter

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

func NewAwaiter

func NewAwaiter(client *Client, id int, ch chan *StateUpdate) *Awaiter

func (*Awaiter) Close

func (a *Awaiter) Close() *StateUpdate

func (*Awaiter) Closed

func (a *Awaiter) Closed() bool

func (*Awaiter) GetChannel

func (a *Awaiter) GetChannel() chan *StateUpdate

func (*Awaiter) GetDeltaCount

func (a *Awaiter) GetDeltaCount() int

func (*Awaiter) GetDeltas

func (a *Awaiter) GetDeltas() []*JookiState

func (*Awaiter) GetInitialState

func (a *Awaiter) GetInitialState() *JookiState

func (*Awaiter) GetState

func (a *Awaiter) GetState() *JookiState

func (*Awaiter) Read

func (a *Awaiter) Read(timer *time.Timer) (*StateUpdate, bool)

func (*Awaiter) WaitFor

func (a *Awaiter) WaitFor(f func(state *JookiState) bool, timeout time.Duration) (*JookiState, error)

func (*Awaiter) Write

func (a *Awaiter) Write(update *StateUpdate) error

type Client

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

func Discover

func Discover() (*Client, error)

func NewClient

func NewClient(device *DiscoveryInfo, dpi *DiscoveryPingInfo) (*Client, error)

func (*Client) AddAwaiter

func (c *Client) AddAwaiter() (*Awaiter, error)

func (*Client) AddTrackToPlaylist

func (c *Client) AddTrackToPlaylist(playlistId, trackId string) (*Playlist, error)

func (*Client) Await

func (c *Client) Await(timeout time.Duration) (*StateUpdate, error)

func (*Client) Closed

func (c *Client) Closed() bool

func (*Client) CreatePlaylist

func (c *Client) CreatePlaylist(title string) (*Playlist, error)

func (*Client) DeletePlaylist

func (c *Client) DeletePlaylist(id string) error

func (*Client) Disconnect

func (c *Client) Disconnect()

func (*Client) Error

func (c *Client) Error() error

func (*Client) GetState

func (c *Client) GetState() *JookiState

func (*Client) IP

func (c *Client) IP() string

func (*Client) Pause

func (c *Client) Pause() (*Audio, error)

func (*Client) Play

func (c *Client) Play() (*Audio, error)

func (*Client) PlayPlaylist

func (c *Client) PlayPlaylist(id string, idx int) (*Audio, error)

func (*Client) Reconnect

func (c *Client) Reconnect() (*Client, error)

func (*Client) RemoveAwaiter

func (c *Client) RemoveAwaiter(id int)

func (*Client) RenamePlaylist

func (c *Client) RenamePlaylist(id, title string) (*Playlist, error)

func (*Client) Seek

func (c *Client) Seek(ms int) (*Audio, error)

func (*Client) SetPlayMode

func (c *Client) SetPlayMode(mode int) (*Audio, error)

func (*Client) SetRepeatMode

func (c *Client) SetRepeatMode(mode RepeatMode) (*Audio, error)

func (*Client) SetShuffleMode

func (c *Client) SetShuffleMode(on bool) (*Audio, error)

func (*Client) SetVolume

func (c *Client) SetVolume(vol int) (*Audio, error)

func (*Client) SkipNext

func (c *Client) SkipNext() (*Audio, error)

func (*Client) SkipPrev

func (c *Client) SkipPrev() (*Audio, error)

func (*Client) UpdatePlaylist

func (c *Client) UpdatePlaylist(update *PlaylistUpdate) (*Playlist, error)

func (*Client) UpdatePlaylistToken

func (c *Client) UpdatePlaylistToken(id, token string) (*Playlist, error)

func (*Client) UpdatePlaylistTracks

func (c *Client) UpdatePlaylistTracks(id string, trackIds []string) (*Playlist, error)

func (*Client) UploadToPlaylist

func (c *Client) UploadToPlaylist(id string, track TrackUpload, ch chan ProgressUpdate) (*Track, error)

type ConnectPayload

type ConnectPayload struct {
	Jooki *JookiInfo `json:"jooki"`
}

type Device

type Device struct {
	DiskUsage *DiskUsage    `json:"diskUsage"`
	Firmware  string        `json:"firmware"`
	Flags     []interface{} `json:"flags"`
	Hostname  string        `json:"hostname"`
	ID        string        `json:"id"`
	IP        string        `json:"ip"`
	Machine   string        `json:"machine"`
	ToySafe   bool          `json:"toy_safe"`
	Usage     string        `json:"usage"`
	WebApp    string        `json:"webapp"`
	WiFiMac   string        `json:"wifi_mac"`
}

func (*Device) Clone

func (d *Device) Clone() *Device

type DiscoveryInfo

type DiscoveryInfo struct {
	Hostname string `json:"Hostname"`
	ID       string `json:"Id"`
	IP       string `json:"Ip"`
	State    string `json:"State"`
}

type DiscoveryPingInfo

type DiscoveryPingInfo struct {
	Version string `json:"version"`
}

type DiskUsage

type DiskUsage struct {
	Available   int64 `json:"available"`
	Total       int64 `json:"total"`
	Used        int64 `json:"used"`
	UsedPercent int8  `json:"usedPercent"`
}

func (*DiskUsage) Clone

func (d *DiskUsage) Clone() *DiskUsage

type FloatStr

type FloatStr float64

func (FloatStr) MarshalJSON

func (fs FloatStr) MarshalJSON() ([]byte, error)

func (*FloatStr) UnmarshalJSON

func (fs *FloatStr) UnmarshalJSON(data []byte) error

type ImageWrapper

type ImageWrapper string

func (*ImageWrapper) MarshalJSON

func (iw *ImageWrapper) MarshalJSON() ([]byte, error)

func (*ImageWrapper) UnmarshalJSON

func (iw *ImageWrapper) UnmarshalJSON(data []byte) error

type IntStr

type IntStr int64

func (IntStr) MarshalJSON

func (is IntStr) MarshalJSON() ([]byte, error)

func (*IntStr) UnmarshalJSON

func (is *IntStr) UnmarshalJSON(data []byte) error

type JookiIP

type JookiIP struct {
	Address string `json:"address"`
	Ping    string `json:"ping"`
}

type JookiInfo

type JookiInfo struct {
	Label   string   `json:"label"`
	IP      *JookiIP `json:"ip"`
	Live    string   `json:"live"`
	Version string   `json:"version"`
}

type JookiSettings

type JookiSettings struct {
	QuietTime *QuietTime `json:"quietTime"`
}

func (*JookiSettings) Clone

func (s *JookiSettings) Clone() *JookiSettings

type JookiState

type JookiState struct {
	Settings     *JookiSettings `json:"DISABLEDsettings"`
	Audio        *Audio         `json:"audio"`
	Bluetooth    string         `json:"bt"`
	Library      *Library       `json:"db"`
	Deezer       []interface{}  `json:"deezer"`
	Device       *Device        `json:"device"`
	Mender       *Mender        `json:"mender"`
	NFC          interface{}    `json:"nfc"`
	Owner        *Owner         `json:"owner"`
	Power        *Power         `json:"power"`
	Spotify      *Spotify       `json:"spotify"`
	UserMessages []interface{}  `json:"userMessages"`
	WiFi         *WiFi          `json:"wifi"`
}

func (*JookiState) Clone

func (s *JookiState) Clone() *JookiState

type Library

type Library struct {
	Playlists map[string]*Playlist `json:"playlists"`
	Tokens    map[string]*Token    `json:"tokens"`
	Tracks    map[string]*Track    `json:"tracks"`
}

func (*Library) Clone

func (l *Library) Clone() *Library

func (*Library) FindTrack

func (l *Library) FindTrack(tr TrackSearch) *Track

func (*Library) UnmarshalJSON added in v0.1.1

func (l *Library) UnmarshalJSON(data []byte) error

type Mender

type Mender struct {
	Event string `json:"event"`
	State string `json:"state"`
}

func (*Mender) Clone

func (m *Mender) Clone() *Mender

type NowPlaying

type NowPlaying struct {
	Album      *string       `json:"album"`
	Artist     *string       `json:"artist"`
	Audiobook  bool          `json:"audiobook"`
	Duration   *float64      `json:"duration_ms"`
	HasNext    bool          `json:"hasNext"`
	HasPrev    bool          `json:"hasPrev"`
	Image      *ImageWrapper `json:"image"`
	PlaylistID *string       `json:"playlistId"`
	Service    *string       `json:"service"`
	Source     *string       `json:"source"`
	Title      *string       `json:"track"`
	TrackID    *string       `json:"trackId"`
	TrackIndex *int          `json:"trackIndex"`
	URI        *string       `json:"uri"`
}

func (*NowPlaying) Clone

func (n *NowPlaying) Clone() *NowPlaying

type Owner

type Owner struct {
	Email     string `json:"email"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	Marketing bool   `json:"marketing"`
}

func (*Owner) Clone

func (o *Owner) Clone() *Owner

type Playback

type Playback struct {
	Position int    `json:"position_ms"`
	State    string `json:"state"`
}

func (*Playback) Clone

func (p *Playback) Clone() *Playback

type Playlist

type Playlist struct {
	ID        *string  `json:"-"`
	Audiobook *bool    `json:audiobook"`
	Token     *string  `json:"star"`
	Name      string   `json:"title"`
	Tracks    []string `json:"tracks"`
	URL       *string  `json:"url,omitempty"`
}

func (*Playlist) Clone

func (p *Playlist) Clone() *Playlist

func (*Playlist) String

func (p *Playlist) String() string

type PlaylistAddTrack

type PlaylistAddTrack struct {
	ID      string `json:"playlistId"`
	TrackID string `json:"trackId"`
}

type PlaylistAddUpload

type PlaylistAddUpload struct {
	ID       string `json:"playlistId"`
	UploadID int    `json:"uploadId"`
	Filename string `json:"filename"`
}

type PlaylistCreate

type PlaylistCreate struct {
	Title     *string `json:"title"`
	Audiobook bool    `json:"audiobook"`
}

type PlaylistDelete

type PlaylistDelete struct {
	ID string `json:"playlistId"`
}

type PlaylistPlay

type PlaylistPlay struct {
	ID         string `json:"playlistId"`
	TrackIndex int    `json:"trackIndex"`
}

type PlaylistUpdate

type PlaylistUpdate struct {
	ID     string   `json:"id"`
	Tracks []string `json:"tracks,omitempty"`
	Title  *string  `json:"title,omitempty"`
	Token  *string  `json:"star,omitempty"`
}

type PlaylistUpdateWrapper

type PlaylistUpdateWrapper struct {
	Playlist *PlaylistUpdate `json:"playlist"`
}

type Power

type Power struct {
	Charging  bool        `json:"charging"`
	Connected bool        `json:"connected"`
	Level     *PowerLevel `json:"level"`
}

func (*Power) Clone

func (p *Power) Clone() *Power

type PowerLevel

type PowerLevel struct {
	MV int `json:"mv"`
	P  int `json:"p"`
	T  int `json:"t"`
}

func (*PowerLevel) Clone

func (p *PowerLevel) Clone() *PowerLevel

type ProgressBody

type ProgressBody struct {
	Progress chan float64
	// contains filtered or unexported fields
}

func NewProgressBody

func NewProgressBody() *ProgressBody

func (*ProgressBody) Len

func (pb *ProgressBody) Len() int

func (*ProgressBody) Read

func (pb *ProgressBody) Read(dst []byte) (int, error)

func (*ProgressBody) UploadProgress

func (pb *ProgressBody) UploadProgress() float64

func (*ProgressBody) Write

func (pb *ProgressBody) Write(data []byte) (int, error)

type ProgressUpdate

type ProgressUpdate struct {
	FileName       string
	UploadID       int
	UploadProgress float64
	Track          *Track
	Err            error
}

type QuietTime

type QuietTime struct {
	Active   bool       `json:"active"`
	Shutdown *TimeOfDay `json:"shutdown"`
}

func (*QuietTime) Clone

func (q *QuietTime) Clone() *QuietTime

type RepeatMode

type RepeatMode uint8

func (RepeatMode) MarshalJSON

func (rm RepeatMode) MarshalJSON() ([]byte, error)

func (*RepeatMode) UnmarshalJSON

func (rm *RepeatMode) UnmarshalJSON(data []byte) error

type SetRepeat

type SetRepeat struct {
	RepeatMode int `json:"repeat_mode"`
}

type SetSeek

type SetSeek struct {
	Position int `json:"position_ms"`
}

type SetShuffle

type SetShuffle struct {
	ShuffleMode bool `json:"shuffle_mode"`
}

type SetVol

type SetVol struct {
	Volume int `json:"vol"`
}

type Spotify

type Spotify struct {
	Active bool `json:"active"`
}

func (*Spotify) Clone

func (s *Spotify) Clone() *Spotify

type StateUpdate

type StateUpdate struct {
	Before *JookiState
	After  *JookiState
	Deltas []*JookiState
}

type TimeOfDay

type TimeOfDay struct {
	Hour   uint8 `json:"hour"`
	Minute uint8 `json:"minute"`
}

func (*TimeOfDay) Clone

func (t *TimeOfDay) Clone() *TimeOfDay

func (*TimeOfDay) Is

func (t *TimeOfDay) Is(tm time.Time) bool

func (*TimeOfDay) Next

func (t *TimeOfDay) Next(tm time.Time) time.Time

type Token

type Token struct {
	ID     *string `json:"-"`
	Seen   int64   `json:"seen"`
	StarID string  `json:"starId"`
}

func (*Token) Clone

func (t *Token) Clone() *Token

type Track

type Track struct {
	ID       *string   `json:"-"`
	Album    *string   `json:"album"`
	Artist   *string   `json:"artist"`
	Codec    *string   `json:"codec"`
	Duration *FloatStr `json:"duration"`
	Location *string   `json:"filename"`
	Format   *string   `json:"format"`
	HasImage bool      `json:"hasImage"`
	Size     *IntStr   `json:"size"`
	Name     *string   `json:"title"`
}

func (*Track) Clone

func (t *Track) Clone() *Track

func (*Track) String

func (t *Track) String() string

type TrackSearch

type TrackSearch struct {
	JookiID   *string
	Name      *string
	Album     *string
	Artist    *string
	Size      *uint64
	TotalTime *uint
}

type TrackUpload

type TrackUpload interface {
	ContentType() string
	FileName() string
	MD5() string
	Reader() (io.ReadCloser, error)
}

type WiFi

type WiFi struct {
	Signal int    `json:"signal"`
	SSID   string `json:"ssid"`
}

func (*WiFi) Clone

func (w *WiFi) Clone() *WiFi

Jump to

Keyboard shortcuts

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