Base๏ƒ

Inheritance diagram of musify.libraries.local.playlist.base

Base implementation for the functionality of a local playlist.

Classes:

LocalPlaylist(path[,ย matcher,ย limiter,ย ...])

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: LocalCollection[LocalTrack], Playlist[LocalTrack], File, ABC, Generic

Generic class for loading and manipulating local playlists.

Parameters:
  • path (str) โ€“ 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 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.

Attributes:

name

The name of this playlist, always the same as the filename.

tracks

The tracks in this collection

path

The path to the file.

date_modified

datetime.datetime object representing when the playlist was last modified

date_created

datetime.datetime object representing when the playlist was created

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.

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.

property date_modified๏ƒ

datetime.datetime object representing when the playlist was last modified

property date_created๏ƒ

datetime.datetime object representing when the playlist was created

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.

abstract 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:

list[LocalTrack] โ€“ Ordered list of tracks in this playlist

valid_extensions: frozenset[str]๏ƒ

Extensions of files that can be loaded by this class.

abstract 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.