Playlist creation - check items are included, raise exception

This commit is contained in:
Nate Harris 2020-07-23 19:31:27 -04:00 committed by GitHub
parent 37c857568d
commit f5647e52c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -131,6 +131,9 @@ class Playlist(PlexPartialObject, Playable):
@classmethod
def _create(cls, server, title, items):
""" Create a playlist. """
if not items:
raise BadRequest('Must include items to add when creating new playlist')
if items and not isinstance(items, (list, tuple)):
items = [items]
ratingKeys = []
@ -163,6 +166,9 @@ class Playlist(PlexPartialObject, Playable):
**kwargs (dict): is passed to the filters. For a example see the search method.
Raises:
:class:`plexapi.exceptions.BadRequest`: when no items are included in create request.
Returns:
:class:`plexapi.playlist.Playlist`: an instance of created Playlist.
"""