calliope.playlist

Module Contents

Classes

PlaylistFormat

Playlist serialization formats.

Item

Represents a single item in a Calliope playlist.

Functions

read(stream)

Parses a playlist from the given stream.

write(items, stream)

Write a playlist to the given stream.

split(items)

Convert a list of items into a list of playlists.

load_schema()

Returns the JSON Schema for Calliope playlist items.

Attributes

Playlist

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.

Check the Import and Export modules to see which formats they support.

CUE = 1
JSPF = 2
M3U = 3
PLS = 1
XSPF = 4
class calliope.playlist.Item(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.Playlist
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