Skip to content

Commit 3f1d04d

Browse files
committed
missing parameters for playlist_edit
1 parent a99f27c commit 3f1d04d

2 files changed

Lines changed: 30 additions & 11 deletions

File tree

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
requests~=2.28.1
1+
requests>=2.28.1
22
setuptools>=65.6.3

src/ampache.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __init__(self):
6464
def set_format(self, myformat: str):
6565
""" set_format
6666
67-
Allow forcing a default format
67+
Allow forcing a default API output format
6868
6969
INPUTS
7070
* myformat = (string) 'xml'|'json'
@@ -1518,27 +1518,39 @@ def playlist_create(self, playlist_name, playlist_type):
15181518
return self.return_data(ampache_response)
15191519

15201520
def playlist_edit(self, filter_id: int, name=False,
1521-
object_type=False):
1521+
playlist_type=False, owner=False, items=False, tracks=False):
15221522
""" playlist_edit
15231523
MINIMUM_API_VERSION=400001
15241524
15251525
This modifies name and type of a playlist
15261526
15271527
INPUTS
1528-
* filter_id = (integer)
1529-
* name = (string) playlist name //optional
1530-
* object_type = (string) 'public'|'private'
1528+
* filter_id = (integer)
1529+
* name = (string) playlist name //optional
1530+
* playlist_type = (string) 'public'|'private' //optional
1531+
* owner = (string) Change playlist owner to the user id (-1 = System playlist) //optional
1532+
* items = (string) comma-separated song_id's (replaces existing items with a new id) //optional
1533+
* tracks = (string) comma-separated playlisttrack numbers matched to 'items' in order //optional
15311534
"""
15321535
ampache_url = self.AMPACHE_URL + '/server/' + self.AMPACHE_API + '.server.php'
15331536
data = {'action': 'playlist_edit',
15341537
'auth': self.AMPACHE_SESSION,
15351538
'filter': filter_id,
15361539
'name': name,
1537-
'type': object_type}
1540+
'type': playlist_type,
1541+
'owner': owner,
1542+
'items': items,
1543+
'tracks': tracks}
15381544
if not name:
15391545
data.pop('name')
1540-
if not object_type:
1546+
if not playlist_type:
15411547
data.pop('type')
1548+
if not owner:
1549+
data.pop('owner')
1550+
if not items:
1551+
data.pop('items')
1552+
if not tracks:
1553+
data.pop('tracks')
15421554
data = urllib.parse.urlencode(data)
15431555
full_url = ampache_url + '?' + data
15441556
ampache_response = self.fetch_url(full_url, self.AMPACHE_API, 'playlist_edit')
@@ -4491,11 +4503,18 @@ def execute(self, method: str, params=None):
44914503
case 'playlist_delete':
44924504
return self.playlist_delete(params["filter_id"])
44934505
case 'playlist_edit':
4494-
if not "playlist_name" in params:
4495-
params["playlist_name"] = False
4506+
if not "name" in params:
4507+
params["name"] = False
44964508
if not "playlist_type" in params:
44974509
params["playlist_type"] = False
4498-
return self.playlist_edit(params["filter_id"], params["playlist_name"], params["playlist_type"])
4510+
if not "owner" in params:
4511+
params["owner"] = False
4512+
if not "items" in params:
4513+
params["items"] = False
4514+
if not "tracks" in params:
4515+
params["tracks"] = False
4516+
return self.playlist_edit(params["filter_id"], params["name"], params["playlist_type"],
4517+
params["owner"], params["items"], params["tracks"])
44994518
case 'playlist_generate':
45004519
if not "mode" in params:
45014520
params["mode"] = 'random'

0 commit comments

Comments
 (0)