Skip to content

Commit b494e8e

Browse files
glenscJonnyWong16
andauthored
Fix: Raise an exception when trying to create a smart collection/playlist with items (#1377)
* Disallow using smart playlist with items * Change exception message Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> * Also check for state when creating collections --------- Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
1 parent 97faf3c commit b494e8e

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

plexapi/collection.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ def create(cls, server, title, section, items=None, smart=False, limit=None,
503503
:class:`~plexapi.collection.Collection`: A new instance of the created Collection.
504504
"""
505505
if smart:
506+
if items:
507+
raise BadRequest('Cannot create a smart collection with items.')
506508
return cls._createSmart(server, title, section, limit, libtype, sort, filters, **kwargs)
507509
else:
508510
return cls._create(server, title, section, items)

plexapi/playlist.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ def create(cls, server, title, section=None, items=None, smart=False, limit=None
434434
if m3ufilepath:
435435
return cls._createFromM3U(server, title, section, m3ufilepath)
436436
elif smart:
437+
if items:
438+
raise BadRequest('Cannot create a smart playlist with items.')
437439
return cls._createSmart(server, title, section, limit, libtype, sort, filters, **kwargs)
438440
else:
439441
return cls._create(server, title, items)

0 commit comments

Comments
 (0)