Utils
Utilities for operations on LocalPlaylist types.
Generally, this will contain global variables representing all supported playlist file types
and a utility function for loading the appropriate LocalPlaylist type for a path based on its extension.
Functions:
|
Attempt to load a file from a given path, returning the appropriate |
- async musify.libraries.local.playlist.utils.load_playlist(path, tracks=(), path_mapper=PathMapper({}), remote_wrangler=None)
Attempt to load a file from a given path, returning the appropriate
LocalPlaylistobject- Parameters:
path (
str|Path) – Absolute path of the playlist. If the playlistpathgiven does not exist, the playlist instance will use all the tracks given intracksas the tracks in the playlist.tracks (
Collection[LocalTrack] (default:())) – Optional. Available Tracks to search through for matches. If no tracks are given, the playlist instance will load all the tracks from scratch according to its settings.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.
- Returns:
LocalPlaylist– LoadedLocalPlaylistobject- Raises:
InvalidFileType – If the file type is not supported.