-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaylist.py
63 lines (47 loc) · 1.57 KB
/
playlist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from . import properties as _properties
from . import rpc as _rpc
def add():
"""Add item(s) to playlist"""
raise NotImplementedError
def clear():
"""Clear playlists"""
try:
_rpc.request('Playlist.Clear')
except:
pass
def get_playlists():
"""Returns all existing playlists"""
try:
playlists = _rpc.request('Playlist.GetPlaylists')
return playlists
except:
return {}
def get_items():
"""Get all items from playlist"""
try:
playlists = get_playlists()
# iterate over all playlists
for playlist in playlists:
items = _rpc.request('Playlist.GetItems', {'playlistid': playlist['playlistid'], 'properties': _properties.select()})
# check if playlist is empty
if 'items' in items:
# append playlist type
items['type'] = playlist['type']
# return statement breaks loops
return items['items']
# all playlist empty, return empty dict
return {}
except:
return {}
def get_properties():
"""Retrieves the values of the given properties"""
raise NotImplementedError
def insert():
"""Insert item(s) into playlist. Does not work for picture playlists (aka slideshows)"""
raise NotImplementedError
def remove():
"""Remove item from playlist. Does not work for picture playlists (aka slideshows)"""
raise NotImplementedError
def swap():
"""Swap items in the playlist. Does not work for picture playlists (aka slideshows)"""
raise NotImplementedError