Base๏
Base implementation for the functionality of a local playlist.
Classes:
|
Generic class for loading and manipulating local playlists. |
- class musify.libraries.local.playlist.base.LocalPlaylist(path, matcher=None, limiter=None, sorter=None, path_mapper=PathMapper({}), remote_wrangler=None)๏
Bases:
File,LocalCollection[LocalTrack],Playlist[LocalTrack],GenericGeneric class for loading and manipulating local playlists.
- Parameters:
path (
str|Path) โ Absolute path of the playlist.matcher (
Optional[TypeVar(T, bound=Filter[LocalTrack])] (default:None)) โFilterobject to use for matching tracks.limiter (
ItemLimiter|None(default:None)) โItemLimiterobject to use for limiting the number of tracks matched.sorter (
ItemSorter|None(default:None)) โItemSorterobject to use for sorting the final track list.path_mapper (
PathMapper(default:PathMapper({}))) โ Optionally, provide aPathMapperfor paths stored in the playlist file. Useful if the playlist file contains relative paths and/or paths for other systems that need to be mapped to absolute, system-specific paths to be loaded and back again when saved.remote_wrangler (
RemoteDataWrangler(default:None)) โ Optionally, provide aRemoteDataWranglerobject for processing URIs on tracks. If given, the wrangler can be used when calling __get_item__ to get an item from the collection from its URI. The wrangler is also used when loading tracks to allow them to process URI tags. For more info on this, seeLocalTrack.
Attributes:
The name of this playlist, always the same as the filename.
The tracks in this collection
The path to the file.
Filterobject to use for matching tracks.ItemLimiterobject to use for limiting the number of tracks matched.ItemSorterobject to use for sorting the final track list.Maps paths stored in the playlist file.
Methods:
load([tracks])Read the playlist file and update the tracks in this playlist instance.
save([dry_run])Write the tracks in this Playlist and its settings (if applicable) to file.
- property name: str๏
The name of this playlist, always the same as the filename.
- property tracks: list[LocalTrack]๏
The tracks in this collection
- property path๏
The path to the file.
- matcher๏
Filterobject to use for matching tracks.
- limiter๏
ItemLimiterobject to use for limiting the number of tracks matched.
- sorter๏
ItemSorterobject to use for sorting the final track list.
- path_mapper๏
Maps paths stored in the playlist file.
- valid_extensions: frozenset[str]๏
Extensions of files that can be loaded by this class.
- abstractmethod async load(tracks=())๏
Read the playlist file and update the tracks in this playlist instance.
- Parameters:
tracks (
Collection[LocalTrack] (default:())) โ Available Tracks to search through for matches.- Returns:
Selfโ Self
- abstractmethod async save(dry_run=True, *args, **kwargs)๏
Write the tracks in this Playlist and its settings (if applicable) to file.
- Parameters:
dry_run (
bool(default:True)) โ Run function, but do not modify the file on the disk.- Returns:
ResultโResultobject with stats on the changes to the playlist.