From f5647e52c27561a411f6a166081e75ebd3bb6d24 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Thu, 23 Jul 2020 19:31:27 -0400 Subject: [PATCH] Playlist creation - check items are included, raise exception --- plexapi/playlist.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plexapi/playlist.py b/plexapi/playlist.py index c640ae34..fa3c882d 100644 --- a/plexapi/playlist.py +++ b/plexapi/playlist.py @@ -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 = [] @@ -162,6 +165,9 @@ class Playlist(PlexPartialObject, Playable): smart (bool): default False. **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.