plistsync.core.playlist¶
Playlist collections.
This module defines the PlaylistCollection class, which represents a collection of tracks as a playlist. To support playlist management on different platforms, we define a number of protocols which each service-specific implementation may adhere to.
The main idea here is to have an abstraction to allow updates/edit playlist in a generic way.
Usage Example:¶
Create a custom playlist collection by subclassing PlaylistCollection and implementing the required methods.
class MyPlaylistCollection(PlaylistCollection):
Overview¶
Unified information a playlist can have, independent of its service. |
|
Represents a snapshot of a playlist’s state. |
|
Abstract base class for playlist collections across music services. |
Module Contents¶
- class plistsync.core.playlist.PlaylistInfo¶
Bases:
TypedDictUnified information a playlist can have, independent of its service.
- class plistsync.core.playlist.Snapshot¶
Bases:
Generic[T]Represents a snapshot of a playlist’s state.
- class plistsync.core.playlist.PlaylistCollection¶
Bases:
Generic[T],plistsync.core.collection.Collection[T],plistsync.core.collection.TrackStream[T],abc.ABCAbstract base class for playlist collections across music services.
Manages local track state and syncs changes to remote services via concrete subclasses. Supports transactional edits through the edit() context manager.
- property info: PlaylistInfo¶
- Abstractmethod:
Get this playlist’s information.
Subclasses need return a reference, so that the setters for name etc. that are defined here, write back.
- remote_edit()¶
Transactional playlist editor with automatic rollback.
Only callable if the playlist is already linked. (.remote_associated == True)
Captures snapshot before entering block. Applies diff to remote service on successful exit. Resets local state on error.
- remote_create()¶
Create the playlist online.
if self.id: raise “is already associated online”
Depending on config (TODO config option DEBUG | INFO | WARN | Raise ) Warn or Raise here if another playlist exists with the same name.
- remote_delete()¶
Delete the playlist online.
- abstractmethod remote_upsert()¶
Alternate usage pattern, besides playlist.remote_edit().
if does not exist, create_online()
if exists, then invoke remote_edit() wrapper.