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:

load_playlist(path[, tracks, path_mapper, ...])

Attempt to load a file from a given path, returning the appropriate LocalPlaylist object

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) – Absolute path of the playlist. If the playlist path given does not exist, the playlist instance will use all the tracks given in tracks 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 a PathMapper 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 a RemoteDataWrangler 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, see LocalTrack.

Returns:

LocalPlaylist – Loaded LocalPlaylist object

Raises:

InvalidFileType – If the file type is not supported.