local

package
v1.60.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package local implements a playlist.Provider backed by TOML files in ~/.config/cliamp/playlists/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

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

Provider reads and writes TOML-based playlists stored on disk.

func New

func New() *Provider

New creates a Provider using ~/.config/cliamp/playlists/ as the base directory.

func (*Provider) AddTrack

func (p *Provider) AddTrack(playlistName string, track playlist.Track) error

AddTrack appends a track to the named playlist, creating the directory and file if needed.

func (*Provider) AddTrackToPlaylist

func (p *Provider) AddTrackToPlaylist(_ context.Context, playlistID string, track playlist.Track) error

AddTrackToPlaylist appends a track to the named playlist. Implements provider.PlaylistWriter.

func (*Provider) AddTracks

func (p *Provider) AddTracks(playlistName string, tracks []playlist.Track) (added, skipped int, err error)

AddTracks appends multiple tracks, skipping exact path duplicates already in the playlist or repeated in the input. It creates the playlist file if needed.

func (*Provider) AddTracksToPlaylist

func (p *Provider) AddTracksToPlaylist(_ context.Context, playlistID string, tracks []playlist.Track) (int, int, error)

AddTracksToPlaylist appends multiple tracks to the named playlist. Implements provider.PlaylistBatchWriter.

func (*Provider) ClearHistory

func (p *Provider) ClearHistory() error

ClearHistory wipes the recorded play history. Returns nil if no history exists yet.

func (*Provider) CreatePlaylist

func (p *Provider) CreatePlaylist(_ context.Context, name string) (string, error)

CreatePlaylist creates an empty playlist file.

func (*Provider) DeletePlaylist

func (p *Provider) DeletePlaylist(name string) error

DeletePlaylist removes the TOML file for the named playlist. "Recently Played" cannot be deleted via this method — use ClearHistory.

func (*Provider) Exists

func (p *Provider) Exists(name string) bool

Exists reports whether a playlist with the given name exists on disk, or whether it refers to the virtual "Recently Played" history with at least one entry recorded.

func (*Provider) Name

func (p *Provider) Name() string

func (*Provider) Playlists

func (p *Provider) Playlists() ([]playlist.PlaylistInfo, error)

Playlists scans the directory for .toml files and returns their metadata, prepending the virtual "Recently Played" entry when the user has any recorded plays. Returns an empty list (not error) when neither exists.

func (*Provider) RemoveTrack

func (p *Provider) RemoveTrack(name string, index int) error

RemoveTrack removes a track by index from the named playlist. Empty playlists are kept on disk; deleting a playlist remains explicit.

func (*Provider) RenamePlaylist

func (p *Provider) RenamePlaylist(oldName, newName string) error

RenamePlaylist renames a playlist by renaming its TOML file. The reserved "Recently Played" history playlist cannot be renamed.

func (*Provider) SavePlaylist

func (p *Provider) SavePlaylist(name string, tracks []playlist.Track) error

SavePlaylist overwrites a playlist with the given tracks.

func (*Provider) SearchTracks

func (p *Provider) SearchTracks(_ context.Context, query string, limit int) ([]playlist.Track, error)

SearchTracks does a case-insensitive fuzzy search across every saved playlist for tracks whose title, artist, or album match query, ranked by relevance (best match first). Returns up to limit results (limit <= 0 means no cap). Implements provider.Searcher.

func (*Provider) SetBookmark

func (p *Provider) SetBookmark(playlistName string, idx int) error

SetBookmark toggles the bookmark flag on a track and rewrites the playlist.

func (*Provider) SetBookmarkByPath

func (p *Provider) SetBookmarkByPath(playlistName string, path string) error

SetBookmarkByPath toggles the bookmark flag on the first track with path and rewrites the playlist. This avoids corrupting saved playlists when the live queue has been filtered, reordered, or otherwise diverged from file order.

func (*Provider) Tracks

func (p *Provider) Tracks(playlistID string) ([]playlist.Track, error)

Tracks parses the TOML file for the given playlist name and returns its tracks. The reserved "Recently Played" name is served from the history store.

Jump to

Keyboard shortcuts

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