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
LocalPlaylist
object- Parameters:
path (
str
|Path
) – Absolute path of the playlist. If the playlistpath
given does not exist, the playlist instance will use all the tracks given intracks
as 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 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
.
- Returns:
LocalPlaylist
– LoadedLocalPlaylist
object- Raises:
InvalidFileType – If the file type is not supported.