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
],Generic
Generic 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
)) โFilter
object to use for matching tracks.limiter (
ItemLimiter
|None
(default:None
)) โItemLimiter
object to use for limiting the number of tracks matched.sorter (
ItemSorter
|None
(default:None
)) โItemSorter
object to use for sorting the final track list.path_mapper (
PathMapper
(default:PathMapper({})
)) โ Optionally, provide aPathMapper
for 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 aRemoteDataWrangler
object 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.
Filter
object to use for matching tracks.ItemLimiter
object to use for limiting the number of tracks matched.ItemSorter
object 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๏
Filter
object to use for matching tracks.
- limiter๏
ItemLimiter
object to use for limiting the number of tracks matched.
- sorter๏
ItemSorter
object 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.
- abstract 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
- abstract 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
โResult
object with stats on the changes to the playlist.