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>
This commit is contained in:
Elan Ruusamäe 2024-03-17 00:17:40 +02:00 committed by GitHub
parent 97faf3ccce
commit b494e8e2f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -503,6 +503,8 @@ class Collection(
:class:`~plexapi.collection.Collection`: A new instance of the created Collection.
"""
if smart:
if items:
raise BadRequest('Cannot create a smart collection with items.')
return cls._createSmart(server, title, section, limit, libtype, sort, filters, **kwargs)
else:
return cls._create(server, title, section, items)

View file

@ -434,6 +434,8 @@ class Playlist(
if m3ufilepath:
return cls._createFromM3U(server, title, section, m3ufilepath)
elif smart:
if items:
raise BadRequest('Cannot create a smart playlist with items.')
return cls._createSmart(server, title, section, limit, libtype, sort, filters, **kwargs)
else:
return cls._create(server, title, items)