From 7c04305b29c4fc9208cd3dfcb48e70aeb0856544 Mon Sep 17 00:00:00 2001 From: Hellowlol Date: Wed, 21 Dec 2016 14:17:28 +0100 Subject: [PATCH] Fix bug after ratingKey was made int. --- plexapi/playlist.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plexapi/playlist.py b/plexapi/playlist.py index d5ef5eff..f63fe3c4 100644 --- a/plexapi/playlist.py +++ b/plexapi/playlist.py @@ -37,7 +37,7 @@ class Playlist(PlexPartialObject, Playable): def items(self): path = '%s/items' % self.key return utils.listItems(self.server, path) - + def addItems(self, items): if not isinstance(items, (list, tuple)): items = [items] @@ -61,23 +61,25 @@ class Playlist(PlexPartialObject, Playable): path = '%s/items/%s/move' % (self.key, item.playlistItemID) if after: path += '?after=%s' % after.playlistItemID return self.server.query(path, method=self.server.session.put) - + def edit(self, title=None, summary=None): path = '/library/metadata/%s%s' % (self.ratingKey, utils.joinArgs({'title':title, 'summary':summary})) return self.server.query(path, method=self.server.session.put) - + def delete(self): return self.server.query(self.key, method=self.server.session.delete) - + @classmethod def create(cls, server, title, items): if not isinstance(items, (list, tuple)): items = [items] ratingKeys = [] + for item in items: if item.listType != items[0].listType: raise BadRequest('Can not mix media types when building a playlist') - ratingKeys.append(item.ratingKey) + ratingKeys.append(str(item.ratingKey)) + ratingKeys = ','.join(ratingKeys) uuid = items[0].section().uuid path = '/playlists%s' % utils.joinArgs({ @@ -86,5 +88,6 @@ class Playlist(PlexPartialObject, Playable): 'title': title, 'smart': 0 }) + data = server.query(path, method=server.session.post)[0] return cls(server, data, initpath=path)