Documentation
¶
Overview ¶
Package local implements a playlist.Provider backed by TOML files in ~/.config/cliamp/playlists/.
Index ¶
- type Provider
- func (p *Provider) AddTrack(playlistName string, track playlist.Track) error
- func (p *Provider) AddTrackToPlaylist(_ context.Context, playlistID string, track playlist.Track) error
- func (p *Provider) AddTracks(playlistName string, tracks []playlist.Track) (added, skipped int, err error)
- func (p *Provider) AddTracksToPlaylist(_ context.Context, playlistID string, tracks []playlist.Track) (int, int, error)
- func (p *Provider) ClearHistory() error
- func (p *Provider) CreatePlaylist(_ context.Context, name string) (string, error)
- func (p *Provider) DeletePlaylist(name string) error
- func (p *Provider) Exists(name string) bool
- func (p *Provider) Name() string
- func (p *Provider) Playlists() ([]playlist.PlaylistInfo, error)
- func (p *Provider) RemoveTrack(name string, index int) error
- func (p *Provider) RenamePlaylist(oldName, newName string) error
- func (p *Provider) SavePlaylist(name string, tracks []playlist.Track) error
- func (p *Provider) SearchTracks(_ context.Context, query string, limit int) ([]playlist.Track, error)
- func (p *Provider) SetBookmark(playlistName string, idx int) error
- func (p *Provider) SetBookmarkByPath(playlistName string, path string) error
- func (p *Provider) Tracks(playlistID string) ([]playlist.Track, error)
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 ¶
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 ¶
ClearHistory wipes the recorded play history. Returns nil if no history exists yet.
func (*Provider) CreatePlaylist ¶
CreatePlaylist creates an empty playlist file.
func (*Provider) DeletePlaylist ¶
DeletePlaylist removes the TOML file for the named playlist. "Recently Played" cannot be deleted via this method — use ClearHistory.
func (*Provider) Exists ¶
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) 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 ¶
RemoveTrack removes a track by index from the named playlist. Empty playlists are kept on disk; deleting a playlist remains explicit.
func (*Provider) RenamePlaylist ¶
RenamePlaylist renames a playlist by renaming its TOML file. The reserved "Recently Played" history playlist cannot be renamed.
func (*Provider) SavePlaylist ¶
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 ¶
SetBookmark toggles the bookmark flag on a track and rewrites the playlist.
func (*Provider) SetBookmarkByPath ¶
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.