api

package
v0.0.0-...-6217932 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2016 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIMETYPE_FLAC = "audio/x-flac"
	MIMETYPE_MP3  = "audio/mpeg"
)
View Source
const MarkovGlobalKey = "@GLOBAL"

Variables

This section is empty.

Functions

func GetExtensionForMimeType

func GetExtensionForMimeType(mimeType string) string

func GetFfmpegFormatForMimeType

func GetFfmpegFormatForMimeType(mimeType string) string

func GetMimeTypeFromExtension

func GetMimeTypeFromExtension(ext string) string

Types

type AcousticCorrelation

type AcousticCorrelation struct {
	SongId string
	Value  float32
}

type AcousticData

type AcousticData struct {
	Features []byte `json:"f"`
}

AcousticData stores acoustic analysis output (as a binary blob, which is definitely not optimal).

type AddPlayLogRequest

type AddPlayLogRequest struct {
	Songs []SongID `json:"songs"`
}

Add an entry to the playlog. Songs are in increasing time order (most recently played last).

type AudioFile

type AudioFile struct {
	MD5           string  `json:"md5"`
	MimeType      string  `json:"mime_type"`
	Size          int64   `json:"size"`
	SampleRate    int     `json:"sample_rate"`
	BitRate       int     `json:"bitrate"`
	Channels      int     `json:"channels"`
	BitsPerSample int     `json:"bits_per_sample"`
	Duration      float64 `json:"duration"`
	SongId        SongID
}

AudioFile describes a single audio file that has been uploaded.

func GetBestAudioFile

func GetBestAudioFile(files []*AudioFile) *AudioFile

type AuthKey

type AuthKey struct {
	KeyId  string `json:"key_id"`
	Secret string `json:"secret"`
	User   string `json:"user"`
}

AuthKey stores credentials for a single API key.

type Document

type Document MultiValuedMap

Document is an entry in the index.

func (Document) Add

func (d Document) Add(key, value string)

type Fingerprint

type Fingerprint struct {
	Code    string `json:"code"`
	Version string `json:"version"`
	Ok      bool   `json:"ok"`
	Stamp   int64  `json:"stamp"`
}

Fingerprint holds the binary audio fingerprint data

type FingerprintRequest

type FingerprintRequest struct {
	Fingerprints []string `json:"fingerprints"`
}

type FingerprintResponse

type FingerprintResponse struct {
	Missing []string `json:"missing"`
	Dupes   []string `json:"dupes"`
}

type FreqDist

type FreqDist struct {
	D   map[SongID]int
	Sum int64
}

FreqDist contains a probability distribution for a specific N-gram in the Markov model. We store counters instead of probabilities so that we can update the map incrementally.

func NewFreqDist

func NewFreqDist() *FreqDist

func (*FreqDist) GetSong

func (fd *FreqDist) GetSong() SongID

func (*FreqDist) Incr

func (fd *FreqDist) Incr(song SongID)

func (*FreqDist) MarshalJSON

func (fd *FreqDist) MarshalJSON() ([]byte, error)

func (*FreqDist) UnmarshalJSON

func (fd *FreqDist) UnmarshalJSON(data []byte) error

type GetManySongsRequest

type GetManySongsRequest struct {
	SongIds []SongID `json:"song_ids"`
}

type GetManySongsResponse

type GetManySongsResponse struct {
	Results []*Song `json:"results"`
}

type JsonFsAttr

type JsonFsAttr struct {
	Name  string     `json:"name"`
	IsDir bool       `json:"is_dir"`
	Audio *AudioFile `json:"audio"`
	Meta  *Meta      `json:"meta"`
}

JsonFs data structures.

type JsonFsLsResponse

type JsonFsLsResponse struct {
	Results []*JsonFsAttr
}

type MarkovMap

type MarkovMap struct {
	M map[SongID]*FreqDist
	// contains filtered or unexported fields
}

MarkovMap contains probability distributions for playlists. The input tuple size is 1, and it's hard-coded in the interface.

func NewMarkovMap

func NewMarkovMap() *MarkovMap

func (*MarkovMap) GetRandomSong

func (m *MarkovMap) GetRandomSong() SongID

GetRandomSong returns a random song chosen amongst those that appear as seeds in the map (i.e. that have been listened to at least once, and have at least one transition).

func (*MarkovMap) GetSong

func (m *MarkovMap) GetSong(cur SongID) (SongID, bool)

GetSong returns a song following 'cur' according to the model.

func (*MarkovMap) Len

func (m *MarkovMap) Len() int

Len returns the total number of transitions encoded in the map (useful for debugging purposes).

func (*MarkovMap) MarshalJSON

func (m *MarkovMap) MarshalJSON() ([]byte, error)

MarshalJSON serializes the map to JSON (using a quite inefficient mechanism at the moment).

func (*MarkovMap) UnmarshalJSON

func (m *MarkovMap) UnmarshalJSON(data []byte) error

UnmarshalJSON restores a MarkovMap from a JSON serialization.

func (*MarkovMap) Update

func (m *MarkovMap) Update(in chan Transition)

type Meta

type Meta struct {
	Artist   string `json:"artist"`
	Title    string `json:"title"`
	Album    string `json:"album"`
	Genre    string `json:"genre"`
	Year     int    `json:"year"`
	TrackNum int    `json:"track_num"`
}

Meta stores metadata about the song.

type MultiValuedMap

type MultiValuedMap map[string][]string

MultiValuedMap is a map of attributes to multiple values.

func (MultiValuedMap) Add

func (m MultiValuedMap) Add(key, value string)

Add an attribute/value pair to the document.

type PlayLogEntry

type PlayLogEntry struct {
	// Username.
	User string

	// History of played songs, from oldest to most recent.
	Songs []SongID

	// Timestamp of this log entry.
	Timestamp int64
}

PlayLogEntry records a single 'play' action by a user.

type SearchIdsResponse

type SearchIdsResponse struct {
	Results []SongID `json:"results"`
}

type SearchResponse

type SearchResponse struct {
	Results []*Song `json:"results"`
}

type Song

type Song struct {
	Id    SongID       `json:"id"`
	Files []*AudioFile `json:"files"`
	Meta  Meta         `json:"meta"`
	Info  SongInfo     `json:"info"`
}

Song has the comprehensive song state. Multiple AudioFiles can actually correspond to the same song (different rip, multiple versions, etc). This object is not stored directly in the db.

func NewSong

func NewSong(af *AudioFile, am *Meta) *Song

NewSong assembles a Song object from a single audio file. The song ID will be equal to the file's MD5 checksum. The song will be created in the 'incoming' state.

func (*Song) GetBestAudioFile

func (s *Song) GetBestAudioFile() *AudioFile

GetBestAudioFile returns the 'best' audio file for this song.

func (*Song) GetBestAudioFileByType

func (s *Song) GetBestAudioFileByType(mimetype string) *AudioFile

GetBestAudioFileByType returns the 'best' file with the given MIME type.

func (*Song) ToDoc

func (song *Song) ToDoc() Document

ToDoc extracts the indexable tokens from a Song object.

type SongID

type SongID [16]byte

SongID is the primary key type (in-memory). It consists of a MD5 hash, related to the audio contents of the song. We use a binary in-memory representation to save space, but the type is serialized to a hex-encoded string in JSON encodings and in the public API in general.

var NilSongID SongID

func ParseSongID

func ParseSongID(s string) (SongID, error)

func ParseSongIDSlice

func ParseSongIDSlice(sl []string) []SongID

func (SongID) MarshalJSON

func (s SongID) MarshalJSON() ([]byte, error)

func (SongID) String

func (s SongID) String() string

func (*SongID) UnmarshalJSON

func (s *SongID) UnmarshalJSON(src []byte) error

type SongInfo

type SongInfo struct {
	State       string `json:"state"`
	CreatedAt   int64  `json:"created_at"`
	DuplicateOf SongID `json:"duplicate_of"`
}

SongInfo contains the internal song state.

type SongIntl

type SongIntl struct {
	Id    SongID   `json:"id"`
	Files []string `json:"files"`
	Meta  Meta     `json:"meta"`
	Info  SongInfo `json:"info"`
}

SongIntl is the on-database representation of the above structure, with the various fields wrapped.

type SongSet

type SongSet map[SongID]struct{}

Set is a simple unordered collection of songs.

func (SongSet) Add

func (s SongSet) Add(id SongID)

Add a value to the set.

func (SongSet) Discard

func (s SongSet) Discard(id SongID)

Discard a value from the set.

func (SongSet) Intersect

func (s SongSet) Intersect(other SongSet) SongSet

Intersect returns a new Set that is the intersection of s and the specified argument.

func (SongSet) Update

func (s SongSet) Update(other SongSet)

Update merges a Set into this one.

type SuggestRequest

type SuggestRequest struct {
	CurrentSongs []SongID `json:"current_songs"`
	NumResults   int      `json:"num_results"`
}

type SuggestResponse

type SuggestResponse struct {
	Results    []*Song  `json:"results"`
	SongOrigin []string `json:"song_origin"`
}

type Transition

type Transition struct {
	Src SongID
	Dst SongID
}

A transition from a song to another.

type UploadResponse

type UploadResponse struct {
	Ok bool `json:"ok"`
}

type User

type User struct {
	Email       string   `json:"email"`
	Password    string   `json:"password"`
	CreatedAt   int64    `json:"created_at"`
	InvitedBy   string   `json:"invited_by"`
	InvitesLeft int      `json:"invites_left"`
	State       string   `json:"state"`
	AuthKeyIds  []string `json:"auth_keys"`
}

User holds user information.

func (*User) CheckPassword

func (u *User) CheckPassword(password string) bool

func (*User) NewAuthKey

func (u *User) NewAuthKey() *AuthKey

func (*User) SetPassword

func (u *User) SetPassword(password string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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