Documentation
¶
Overview ¶
Package meta turns a media path into the descriptive metadata a UI shows: tags, cover art and the stream shape. Resolvers are pluggable, so a new source (a sidecar file, a music database, an FFprobe wrapper) is added without touching the chain or the player.
A resolver that fails is not fatal: the chain moves down the priority order and lets a cheaper answer stand in. That is why resolving a path almost always succeeds even for a file with no tags at all.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoMatch = errors.New("meta: no resolver could describe the path")
ErrNoMatch means every matching resolver failed. It is not returned for an untagged file, because the filename resolver always has an answer.
var ErrNoTags = errors.New("meta: no embedded tags")
ErrNoTags means the file parsed but carries no usable metadata. It is a deliberate step-aside, not a hard failure: a tagless file should fall down to the filename resolver instead of surfacing an empty title.
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain runs resolvers from highest priority to lowest and returns the first success. Failure is a signal to fall through, never an abort.
func Default ¶
func Default() *Chain
Default is the chain a player uses unless the caller supplies another.
func NewChain ¶
NewChain sorts a copy of resolvers by descending priority so Resolve never has to. Ties keep the caller's order, which makes a chain with two equal priorities predictable.
func (*Chain) Priority ¶
Priority is zero: a chain is a container for resolvers, not a peer of them.
type EmbeddedTags ¶
type EmbeddedTags struct{}
EmbeddedTags reads the container's own metadata through dhowden/tag, which covers ID3 (MP3), Vorbis comments (Ogg/Opus/FLAC), MP4 atoms and DSF. One library covers every format we decode today.
func NewEmbeddedTags ¶
func NewEmbeddedTags() *EmbeddedTags
NewEmbeddedTags returns the content-aware resolver.
func (*EmbeddedTags) Match ¶
func (e *EmbeddedTags) Match(path string) bool
func (*EmbeddedTags) Name ¶
func (e *EmbeddedTags) Name() string
func (*EmbeddedTags) Priority ¶
func (e *EmbeddedTags) Priority() int
Priority puts container metadata above a filename guess, because it is cheaper and more direct than probing the stream.
type Filename ¶
type Filename struct{}
Filename is the last-resort resolver: it always matches and turns the base name into a title. It exists so a UI never has to show an empty line, and it guarantees the chain can answer for a file no other resolver understands.
func (*Filename) Match ¶
Match always reports true. Requiring the file to exist here would make a queued but not-yet-created path fail to describe itself, which is not this resolver's job to police: the decoder reports a missing file.
type Meta ¶
type Meta struct {
Path string
Container string
Codec string
Stream core.StreamInfo
Tags Tags
// Source names the resolver that answered, for debugging and for a UI that
// wants to show where the title came from.
Source string
}
Meta is everything known about one media file. Stream is filled by whoever opened the file, not by a resolver, because only the decoder can report the true stream shape.
type Resolver ¶
type Resolver interface {
Name() string
Priority() int
Match(path string) bool
Resolve(ctx context.Context, path string) (*Meta, error)
}
Resolver is one source of metadata. Match is a cheap path-only check, so a resolver is never opened for a file it cannot handle.
type Tags ¶
type Tags struct {
Title string
Artist string
Album string
AlbumArtist string
Track int
Disc int
Year int
// Cover is the raw image bytes and CoverMIME the type the source declared.
// A UI hands both to an image decoder; the engine never touches them.
Cover []byte
CoverMIME string
}
Tags is the human-facing part of the metadata. Zero values mean "the source did not provide this", which lets a UI decide what to show instead of guessing.