calliope.playlist
¶
Module Contents¶
Classes¶
Playlist serialization formats. |
|
Represents a single item in a Calliope playlist. |
|
Built-in mutable sequence. |
Functions¶
|
Parses a playlist from the given stream. |
|
Write a playlist to the given stream. |
|
Convert a list of items into a list of playlists. |
Returns the JSON Schema for Calliope playlist items. |
Attributes¶
- exception calliope.playlist.PlaylistError¶
Bases:
RuntimeError
Unspecified run-time error.
Initialize self. See help(type(self)) for accurate signature.
- exception calliope.playlist.UnhashableItem¶
Bases:
PlaylistError
Unspecified run-time error.
Initialize self. See help(type(self)) for accurate signature.
- class calliope.playlist.PlaylistFormat¶
Bases:
enum.Enum
Playlist serialization formats.
JSPF
: JSON variant of XSPF. Note that YAML is accepted as well.CUE
: The Cue sheet formatM3U
: M3U and Extended M3U. See https://en.wikipedia.org/wiki/M3UPLS
: The INI-based PLS format
Check the
Import
andExport
modules to see which formats they support.- CUE = 1¶
- JSPF = 2¶
- M3U = 3¶
- PLS = 1¶
- XSPF = 4¶
- class calliope.playlist.PlaylistItem(data=None)¶
Bases:
dict
Represents a single item in a Calliope playlist.
Initialize self. See help(type(self)) for accurate signature.
- id()¶
- __hash__()¶
Return hash(self).
- __str__()¶
Return str(self).
- add_warning(namespace, message)¶
- calliope.playlist.Item¶
- class calliope.playlist.Playlist¶
Bases:
list
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
Initialize self. See help(type(self)) for accurate signature.
- calliope.playlist.read(stream)¶
Parses a playlist from the given stream.
Returns an generator that produces calliope.playlist.Item objects.
The generator will read from the file on demand, so you must be careful not to do this:
- with open(‘playlist.cpe’, ‘r’) as f:
playlist = calliope.playlist.read(f)
- for item in playlist:
# You will see ‘ValueError: I/O operation on closed file.’. …
If you want to read the playlist in one operation, convert it to a list:
- with open(‘playlist.cpe’, ‘r’) as f:
playlist = list(calliope.playlist.read(f))
- calliope.playlist.write(items, stream)¶
Write a playlist to the given stream.
- calliope.playlist.split(items)¶
Convert a list of items into a list of playlists.
Splitting is done based on the playlist.title attribute. Each time an item is found with this attribute set, it’s treated as a new playlist.
- calliope.playlist.load_schema()¶
Returns the JSON Schema for Calliope playlist items.
- Return type:
dict