gosubsonic

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

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

Go to latest
Published: Oct 3, 2020 License: MIT Imports: 10 Imported by: 0

README

gosubsonic Build Status

Subsonic client library, written in Go. MIT Licensed.

Full documentation for gosubsonic may be found on GoDoc.

Documentation

Overview

Package gosubsonic provides a Subsonic client library, written in Go.

Index

Constants

View Source
const (
	CLIENT     = "gosubsonic-git-master"
	APIVERSION = "1.15.0"
)

Constants to pass with each API request

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code    int
	Message string
}

APIError represents any errors reported by Subsonic

type APIStatus

type APIStatus struct {
	// Common fields
	Status  string
	Version string
	Xmlns   string

	// API error - returned only when an error occurs
	Error APIError

	// license - returned only in GetLicense
	License License

	// musicFolders - returned only in GetMusicFolders
	MusicFolders apiMusicFolderContainer

	// indexes - returned only in GetIndexes
	Indexes apiIndexesContainer

	// directory - returned only in GetMusicDirectory
	Directory apiMusicDirectoryContainer

	// nowPlaying - returned only in GetNowPlaying
	NowPlaying interface{}
}

APIStatus represents the current status of Subsonic

type Audio

type Audio struct {
	// Raw values
	ID                    string
	Album                 string
	AlbumID               int64
	Artist                string
	ArtistID              int64
	BitRate               int64
	ContentType           string
	CoverArt              int64
	CreatedRaw            string `json:"created"`
	DiscNumber            int64
	DurationRaw           int64 `json:"duration"`
	Genre                 string
	Parent                string
	Path                  string
	Size                  int64
	Suffix                string
	Title                 string
	Track                 int64
	TranscodedContentType string
	TranscodedSuffix      string
	Type                  string
	Year                  int64

	// Parsed values
	Created  time.Time
	Duration time.Duration
}

Audio represents an audio item from Subsonic

type Client

type Client struct {
	Host     string
	Username string
	Password string
	// contains filtered or unexported fields
}

Client represents the required parameters to connect to a Subsonic server

func New

func New(host string, username string, password string) (*Client, error)

New creates a new Client using the specified parameters

func NewMock

func NewMock() (*Client, error)

NewMock creates a new Client which receives mock data instead of connecting to a Subsonic server

func (Client) Download

func (s Client) Download(id int64) (io.ReadCloser, error)

Download returns a io.ReadCloser which contains a raw, non-transcoded media file stream

func (Client) GetCoverArt

func (s Client) GetCoverArt(id int64, size int64) (io.ReadCloser, error)

GetCoverArt returns a io.ReadCloser which contains a cover art stream, scaled to the specified size

func (Client) GetIndexes

func (s Client) GetIndexes(folderID string, modified string) ([]Index, error)

GetIndexes returns an indexed structure of all artists from Subsonic

func (Client) GetLicense

func (s Client) GetLicense() (*License, error)

GetLicense retrieves details about the Subsonic server license

func (Client) GetMusicDirectory

func (s Client) GetMusicDirectory(folderID string) (*Content, error)

GetMusicDirectory returns a list of all content in a music directory

func (Client) GetMusicFolders

func (s Client) GetMusicFolders() ([]MusicFolder, error)

GetMusicFolders returns the configured top-level music folders

func (Client) GetNowPlaying

func (s Client) GetNowPlaying() ([]NowPlaying, error)

GetNowPlaying returns a list of tracks which are currently being played

func (Client) Ping

func (s Client) Ping() (*APIStatus, error)

Ping checks the connectivity of a Subsonic server

func (Client) Scrobble

func (s Client) Scrobble(id int64, time int64, submission bool) error

Scrobble triggers a "Now Playing" or "Submission" request to Last.fm, if configured

func (Client) Stream

func (s Client) Stream(id string, options *StreamOptions) (io.ReadCloser, error)

Stream returns a io.ReadCloser which contains a processed media file stream, with an optional StreamOptions struct

type Content

type Content struct {
	Audio       []Audio
	Directories []Directory
	Video       []Video
}

Content is a container used to contain the Directory, Audio, and Video structs residing in this Directory

type Directory

type Directory struct {
	// Raw values
	ID         string
	Album      string
	Artist     string
	CoverArt   int64
	CreatedRaw string `json:"created"`
	Parent     string
	Title      string

	// Parsed values
	Created time.Time
}

Directory represents a media directory from Subsonic

type Index

type Index struct {
	// Raw values
	Name      string
	ArtistRaw interface{} `json:"artist"`

	// Artist - generated from raw interfaces
	Artist []IndexArtist
}

Index represents a group in the Subsonic index

type IndexArtist

type IndexArtist struct {
	ID   string
	Name string
}

IndexArtist represents an artist in the Subsonic index

type License

type License struct {
	// Raw values
	DateRaw string `json:"date"`
	Email   string
	Key     string
	Valid   bool

	// Parsed values
	Date time.Time
}

License represents the license status of Subsonic

type MusicFolder

type MusicFolder struct {
	ID   string
	Name string
}

MusicFolder represents a top-level music folders of Subsonic

type NowPlaying

type NowPlaying struct {
	// Raw values
	ID          string
	Album       string
	AlbumID     string
	Artist      string
	ArtistID    string
	BitRate     int64
	ContentType string
	CoverArt    int64
	CreatedRaw  string `json:"created"`
	DiscNumber  int64
	DurationRaw int64
	Genre       string
	IsDir       bool
	IsVideo     bool
	MinutesAgo  int64
	Parent      string
	Path        string
	PlayerID    int64
	Size        int64
	Suffix      string
	Title       string
	Track       int64
	Username    string
	Year        int64

	// Parsed values
	Created  time.Time
	Duration time.Duration
}

NowPlaying represents a now playing entry from Subsonic

type StreamOptions

type StreamOptions struct {
	MaxBitRate            int64
	Format                string
	TimeOffset            int64
	Size                  string
	EstimateContentLength bool
}

StreamOptions represents additional options for the Stream() method

type Video

type Video struct {
	// Raw values
	ID                    string
	BitRate               int64
	ContentType           string
	CoverArt              int64
	CreatedRaw            string `json:"created"`
	DurationRaw           int64  `json:"duration"`
	Parent                string
	Path                  string
	Size                  int64
	Suffix                string
	Title                 string
	TranscodedContentType string
	TranscodedSuffix      string

	// Parsed values
	Created  time.Time
	Duration time.Duration
}

Video represents a video item from Subsonic

Jump to

Keyboard shortcuts

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