musiclib

package module
v0.0.0-...-3b03873 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 14 Imported by: 0

README

musiclib

A mctofu/musiclib-grpc service that allows browsing and searching a local music library.

Clients

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BrowseItem

type BrowseItem struct {
	Name     string
	URI      string
	ImageURI string
	Folder   bool
}

type BrowseOptions

type BrowseOptions struct {
	TextFilter string
	BrowseType BrowseType
}

type BrowseType

type BrowseType string
const (
	BrowseTypeFile        BrowseType = "file"
	BrowseTypeAlbumArtist BrowseType = "albumartist"
	BrowseTypeGenre       BrowseType = "genre"
	BrowseTypeYear        BrowseType = "year"
	BrowseTypeModified    BrowseType = "modified"
)

type FileIndex

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

func (*FileIndex) Index

func (f *FileIndex) Index(ctx context.Context, files *Files) error

func (*FileIndex) Node

func (f *FileIndex) Node(ctx context.Context, uri string) (*Node, error)

func (*FileIndex) Roots

func (f *FileIndex) Roots(ctx context.Context) ([]*Node, error)

type Files

type Files struct {
	Roots []PathMeta
}

func ScanRoots

func ScanRoots(ctx context.Context, roots []string) (*Files, error)

func (*Files) WalkFiles

func (f *Files) WalkFiles(walkFn WalkFunc) error

type Index

type Index interface {
	Roots(ctx context.Context) ([]*Node, error)
	Node(ctx context.Context, uri string) (*Node, error)
}

type IndexedLibrary

type IndexedLibrary struct {
	RootPaths    []string
	AlbumArtists *MetadataIndex
	Files        *FileIndex
	Genres       *MetadataIndex
	Years        *MetadataIndex
	ModifyDates  *MetadataIndex
}

func NewIndexedLibrary

func NewIndexedLibrary(ctx context.Context, rootPaths []string) (*IndexedLibrary, error)

func (*IndexedLibrary) Browse

func (l *IndexedLibrary) Browse(ctx context.Context, browseURI string, opts BrowseOptions) ([]*BrowseItem, error)

func (*IndexedLibrary) Media

func (l *IndexedLibrary) Media(ctx context.Context, uri string, opts BrowseOptions) ([]string, error)

type MediaMetadata

type MediaMetadata interface {
	Artist() string
	AlbumArtist() string
	Album() string
	Song() string
	AlbumArtURI() string
	Track() int
	Genre() string
	Modified() time.Time
	Year() int
}

type MetadataIndex

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

func NewArtistAlbumIndex

func NewArtistAlbumIndex() *MetadataIndex

func NewGenreIndex

func NewGenreIndex() *MetadataIndex

func NewMetadataIndex

func NewMetadataIndex(builders []NodeBuilder) *MetadataIndex

func NewModifiedAtIndex

func NewModifiedAtIndex() *MetadataIndex

func NewYearIndex

func NewYearIndex() *MetadataIndex

func (*MetadataIndex) Index

func (a *MetadataIndex) Index(ctx context.Context, files *Files) error

func (*MetadataIndex) Node

func (a *MetadataIndex) Node(ctx context.Context, uri string) (*Node, error)

func (*MetadataIndex) Roots

func (a *MetadataIndex) Roots(ctx context.Context) ([]*Node, error)

type Node

type Node struct {
	Name      string
	LowerName string
	URI       string
	ImageURI  string
	Parent    *Node
	Children  []*Node
}

func (*Node) AddChildren

func (n *Node) AddChildren(nodes ...*Node)

func (*Node) IsFolder

func (n *Node) IsFolder() bool

type NodeBuilder

type NodeBuilder func(lookup map[string]*Node, dir *PathMeta, file *PathMeta, uriPaths []string) (*Node, []string, bool)

type PathMeta

type PathMeta struct {
	Name      string
	Path      string
	ImagePath string
	Metadata  MediaMetadata
	Parent    *PathMeta
	Children  []PathMeta
}

func (*PathMeta) IsDir

func (f *PathMeta) IsDir() bool

type ReloadableLibrary

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

func NewReloadableLibrary

func NewReloadableLibrary(rootPaths []string) *ReloadableLibrary

func (*ReloadableLibrary) Browse

func (r *ReloadableLibrary) Browse(ctx context.Context, browseURI string, opts BrowseOptions) ([]*BrowseItem, error)

func (*ReloadableLibrary) Load

func (r *ReloadableLibrary) Load(ctx context.Context) error

func (*ReloadableLibrary) Media

func (r *ReloadableLibrary) Media(ctx context.Context, uri string, opts BrowseOptions) ([]string, error)

type WalkFunc

type WalkFunc func(dir *PathMeta, file *PathMeta) error

type WalkNodeFunc

type WalkNodeFunc func(n *Node) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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