api

package
v0.0.0-...-e53a3c9 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {
	task.Task

	DeviceId  string
	SessionId string
	// contains filtered or unexported fields
}

func NewApi

func NewApi(host string) (*Api, error)

func (*Api) ConnectionOk

func (a *Api) ConnectionOk() bool

func (*Api) DefaultMusicView

func (a *Api) DefaultMusicView() string

func (*Api) GetAlbum

func (a *Api) GetAlbum(id models.Id) (models.Album, error)

func (*Api) GetAlbumSongs

func (a *Api) GetAlbumSongs(album models.Id) ([]*models.Song, error)

GetAlbumSongs gets songs for given album.

func (*Api) GetArtist

func (a *Api) GetArtist(id models.Id) (models.Artist, error)

func (*Api) GetArtistAlbums

func (a *Api) GetArtistAlbums(id models.Id) ([]*models.Album, error)

GetArtistAlbums retrieves albums for given artist.

func (*Api) GetChildItems

func (a *Api) GetChildItems(id models.Id) ([]models.Item, error)

func (*Api) GetFavoriteArtists

func (a *Api) GetFavoriteArtists() ([]*models.Artist, error)

func (*Api) GetItem

func (a *Api) GetItem(id models.Id) (models.Item, error)

func (*Api) GetItems

func (a *Api) GetItems(ids []models.Id) ([]models.Item, error)

func (*Api) GetLatestAlbums

func (a *Api) GetLatestAlbums() ([]*models.Album, error)

func (*Api) GetParentItem

func (a *Api) GetParentItem(id models.Id) (models.Item, error)

func (*Api) GetServerVersion

func (a *Api) GetServerVersion() (string, string, string, error)

GetServerVersion returns name, version, id and possible error

func (*Api) GetSongDirect

func (a *Api) GetSongDirect(id string, codec string) (io.ReadCloser, error)

func (*Api) GetUserViews

func (a *Api) GetUserViews()

func (*Api) GetViews

func (a *Api) GetViews() ([]*models.View, error)

func (*Api) Host

func (a *Api) Host() string

func (*Api) IsLoggedIn

func (a *Api) IsLoggedIn() bool

func (*Api) Login

func (a *Api) Login(username, password string) error

Login performs username based login

func (*Api) ReportProgress

func (a *Api) ReportProgress(state *PlaybackState) error

func (*Api) Search

func (a *Api) Search(q string, limit int) (*SearchResult, error)

Search searches audio items

func (*Api) ServerId

func (a *Api) ServerId() string

func (*Api) SetDefaultMusicview

func (a *Api) SetDefaultMusicview(id string)

func (*Api) SetServerId

func (a *Api) SetServerId(id string)

func (*Api) SetToken

func (a *Api) SetToken(token string) error

SetToken sets existing token

func (*Api) SetUserId

func (a *Api) SetUserId(id string)

func (*Api) Token

func (a *Api) Token() string

func (*Api) UserId

func (a *Api) UserId() string

func (*Api) VerifyServerId

func (a *Api) VerifyServerId() error

type Cache

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

func NewCache

func NewCache() (*Cache, error)

NewCache creates new cache that's ready to use.

func (*Cache) Count

func (c *Cache) Count() int

Count returns total count of stored items

func (*Cache) Delete

func (c *Cache) Delete(id models.Id)

Delete deletes item with given id. If item is not found, do nothing.

func (*Cache) Get

func (c *Cache) Get(id models.Id) (models.Item, bool)

Get gets single item fro cache. Returns item and flag whether item is found

func (*Cache) GetBatch

func (c *Cache) GetBatch(ids []models.Id) ([]models.Item, bool)

GetBatch returns batch of items with given ids. Return array is always same length of ids. However, if not all items are found, return flag is set to false.

func (*Cache) GetList

func (c *Cache) GetList(id string) ([]models.Id, bool)

GetList gets list of Ids with given id

func (*Cache) Put

func (c *Cache) Put(id models.Id, item models.Item, expire bool)

Put puts single item. If expire is true, item expires after default expiration

func (*Cache) PutBatch

func (c *Cache) PutBatch(items []models.Item, expire bool) error

PutBatch put's multiple items with expiration. Each item must have a valid id or operation fails returning error.

func (*Cache) PutList

func (c *Cache) PutList(id string, data []models.Id)

PutList puts a list of ids under key

type MediaLibrary

type MediaLibrary struct {
	Name     string `json:"Name"`
	ServerId string `json:"ServerId"`
	Id       string `json:"Id"`
}

type MediaServer

type MediaServer interface {
	//GetSongDirect downloads song and returns readcloser if any.
	GetSongDirect(id string, codec string) (io.ReadCloser, error)
	//Search returns Songs that match query
	//TODO: set single / multiple of artist, album, playlist, song
	Search(query string, limit int) (*SearchResult, error)
	//ReportProgress reports current playing progress to server
	ReportProgress(state *PlaybackState) error

	//GetItem retrieves single item by its id
	GetItem(id models.Id) (models.Item, error)
	//GetItems retrieves multiple items by their id's
	GetItems(ids []models.Id) ([]models.Item, error)

	//GetArtist gets artist by id.
	GetArtist(id models.Id) (models.Artist, error)

	//Getalbum retrieves album by id.
	GetAlbum(id models.Id) (models.Album, error)
}

MediaServer uses Jellyfin servers resources and exposes them

type MediaViewResponse

type MediaViewResponse struct {
	Libraries []MediaLibrary `json:"Items"`
}

type PlaybackEvent

type PlaybackEvent string
const (
	// Internal events
	EventStart PlaybackEvent = "start"
	EventStop  PlaybackEvent = "stop"

	// Outgoing events
	EventTimeUpdate          PlaybackEvent = "TimeUpdate"
	EventPause               PlaybackEvent = "Pause"
	EventUnpause             PlaybackEvent = "Unnpause"
	EventVolumeChange        PlaybackEvent = "VolumeChange"
	EventRepeatModeChange    PlaybackEvent = "RepeatModeChange"
	EventAudioTrackChange    PlaybackEvent = "AudioTrackChange"
	EventSubtitleTrackChange PlaybackEvent = "SubtitleTrackChange"
	EventPlaylistItemMove    PlaybackEvent = "PlaylistItemMove"
	EventPlaylistItemRemove  PlaybackEvent = "PlaylistItemRemove"
	EventPlaylistItemAdd     PlaybackEvent = "PlaylistItemAdd"
	EventQualityChange       PlaybackEvent = "QualityChange"
)

type PlaybackState

type PlaybackState struct {
	Event    PlaybackEvent
	ItemId   string
	IsPaused bool
	IsMuted  bool
	// Total length of current playlist in seconds
	PlaylistLength int
	// Position in seconds
	Position int
	// Volume in 0-100
	Volume int
}

Playbackstate reports playback back to server

type SearchHint

type SearchHint struct {
	Id          string `json:"Id"`
	Name        string `json:"Name"`
	Year        int    `json:"ProductionYear"`
	Type        string `json:"Type"`
	Duration    int    `json:"RunTimeTicks"`
	Album       string `json:"Album"`
	AlbumId     string `json:"AlbumId"`
	AlbumArtist string `json:"AlbumArtist"`
}

type SearchResult

type SearchResult struct {
	Items []SearchHint `json:"SearchHints"`
}

Jump to

Keyboard shortcuts

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