musefuse

package module
v0.0.0-...-38e4d57 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2022 License: MIT Imports: 23 Imported by: 0

README

MuseFUSE: Browse your music by tag using the filesystem

This was a fun little Sunday hack to make a read-only FUSE filesystem for exploring tagged music files.

Basically I made it because I have a rather large mess on my hands here and wanted to explore the data before I started to autotag everything, plus I wanted to see how hard it was to use FUSE in Go (answer: not very, though the docs are a bit pants).

Unfortunately, now I have two messes - this prototype has been really useful, so now I have to clean up the code too!

Prerequisites:

  • Go 1.11
  • MacFUSE if running on macOS

To install on Ubuntu:

go install go.shabbyrobe.org/musefuse/cmd/musefuse@latest

I've been using a mount point in /media/$USER because it shows up in Nautilus, YMMV:

sudo mkdir -p "/media/$USER/muse"
sudo chown "$USER:$USER" "/media/$USER/muse"

Now mount the thing:

musefuse fs -mount "/media/$USER/muse" -path ~/music/

On macOS, I created the mountpoint in /Volumes and that worked with Finder no problem.

Now you can explore!

$ ls /media/bl/muse
artist  artistalbum  failed  genre  unsorted  year

$ ls /media/bl/muse/year
1984  1987  1990  1993  1996  1999  2002  2005  2008  2011  2014  2017

It's a bit easier than I'd like at the moment for the program to shut down before closing the mount. If you have a stray mount on your hands, just umount it and you're good to go:

sudo umount "/media/$USER/muse"

Here's what I plan to add:

  • Finish the playlist handling
  • Config files
  • Multiple databases with configurable file extensions
  • Make the webserver a bit better for exploring the metadata
  • Re-scan databases periodically
  • Trigger re-scan
  • "Complete albums" - when tags have Tracks set, and all tracks are found.

Here's what I won't add:

  • Something like fsnotify or watcher; I tried it and it was way too janky and I lost a lot of time that could've been better spent on the other list.

Notes

Generic libs:

ID3:

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AudioExtensions = []string{".oga", ".mp3", ".ogg", ".opus", ".flac", ".mp4", ".m4a", ".alac", ".aac"}
View Source
var PlaylistExtensions = []string{".xspf"}

Functions

This section is empty.

Types

type FS

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

func NewFS

func NewFS() *FS

func (*FS) AddAudio

func (fs *FS) AddAudio(entry *FileEntry) error

func (*FS) Root

func (fs *FS) Root() (fs.Node, error)

type FileEntry

type FileEntry struct {
	File     FileInfo
	Err      string
	Metadata *Metadata
}

type FileInfo

type FileInfo struct {
	Prefix  string
	Path    string
	Size    int64
	ModTime time.Time
	Kind    FileKind
}

type FileKind

type FileKind string
const (
	FileAudio    FileKind = "audio"
	FilePlaylist FileKind = "playlist"
)

type Lister

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

Lister, if you touch that guitar, I'll remove the E-string and garotte you with it.

func NewLister

func NewLister(paths []string, audioExts, playlistExts []string) *Lister

func (*Lister) List

func (lister *Lister) List(into []FileInfo) (files []FileInfo, err error)

type Metadata

type Metadata struct {
	Format      tag.Format
	FileType    tag.FileType
	Title       string
	Album       string
	Artist      string
	AlbumArtist string
	Composer    string
	Year        int
	Genre       string
	Lyrics      string
	Comment     string

	Track  int
	Tracks int

	Disc  int
	Discs int

	// Picture returns a picture, or nil if not available.
	Picture *tag.Picture

	// Raw returns the raw mapping of retrieved tag names and associated values.
	// NB: tag/atom names are not standardised between formats.
	Raw map[string]interface{}
}

Metadata is a structured representation of the tag.Metadata interface for serialisation.

func MetadataFromTag

func MetadataFromTag(tagData tag.Metadata) *Metadata

func (*Metadata) ToTag

func (meta *Metadata) ToTag() tag.Metadata

type WebServer

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

func NewWebServer

func NewWebServer(host string, fs *FS) *WebServer

func (*WebServer) Run

func (s *WebServer) Run(ctx service.Context) error

Directories

Path Synopsis
cmd
internal
fastwalk
Package fastwalk provides a faster version of filepath.Walk for file system scanning tools.
Package fastwalk provides a faster version of filepath.Walk for file system scanning tools.

Jump to

Keyboard shortcuts

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