@@ -32,9 +32,10 @@ class Collection(
3232 art (str): URL to artwork image (/library/metadata/<ratingKey>/art/<artid>).
3333 artBlurHash (str): BlurHash string for artwork image.
3434 childCount (int): Number of items in the collection.
35- collectionMode (str): How the items in the collection are displayed.
35+ collectionFilterBasedOnUser (int): Which user's activity is used for the collection filtering.
36+ collectionMode (int): How the items in the collection are displayed.
3637 collectionPublished (bool): True if the collection is published to the Plex homepage.
37- collectionSort (str ): How to sort the items in the collection.
38+ collectionSort (int ): How to sort the items in the collection.
3839 content (str): The filter URI string for smart collections.
3940 contentRating (str) Content rating (PG-13; NR; TV-G).
4041 fields (List<:class:`~plexapi.media.Field`>): List of field objects.
@@ -71,6 +72,7 @@ def _loadData(self, data):
7172 self .art = data .attrib .get ('art' )
7273 self .artBlurHash = data .attrib .get ('artBlurHash' )
7374 self .childCount = utils .cast (int , data .attrib .get ('childCount' ))
75+ self .collectionFilterBasedOnUser = utils .cast (int , data .attrib .get ('collectionFilterBasedOnUser' , '0' ))
7476 self .collectionMode = utils .cast (int , data .attrib .get ('collectionMode' , '-1' ))
7577 self .collectionPublished = utils .cast (bool , data .attrib .get ('collectionPublished' , '0' ))
7678 self .collectionSort = utils .cast (int , data .attrib .get ('collectionSort' , '0' ))
@@ -196,6 +198,32 @@ def get(self, title):
196198 """ Alias to :func:`~plexapi.library.Collection.item`. """
197199 return self .item (title )
198200
201+ def filterUserUpdate (self , user = None ):
202+ """ Update the collection filtering user advanced setting.
203+
204+ Parameters:
205+ user (str): One of the following values:
206+ "admin" (Always the server admin user),
207+ "user" (User currently viewing the content)
208+
209+ Example:
210+
211+ .. code-block:: python
212+
213+ collection.updateMode(user="user")
214+ """
215+ if not self .smart :
216+ raise BadRequest ('Cannot change collection filtering user for a non-smart collection.' )
217+
218+ user_dict = {
219+ 'admin' : 0 ,
220+ 'user' : 1
221+ }
222+ key = user_dict .get (user )
223+ if key is None :
224+ raise BadRequest ('Unknown collection filtering user: %s. Options %s' % (user , list (user_dict )))
225+ self .editAdvanced (collectionFilterBasedOnUser = key )
226+
199227 def modeUpdate (self , mode = None ):
200228 """ Update the collection mode advanced setting.
201229
@@ -220,7 +248,7 @@ def modeUpdate(self, mode=None):
220248 }
221249 key = mode_dict .get (mode )
222250 if key is None :
223- raise BadRequest ('Unknown collection mode : %s. Options %s' % (mode , list (mode_dict )))
251+ raise BadRequest ('Unknown collection mode: %s. Options %s' % (mode , list (mode_dict )))
224252 self .editAdvanced (collectionMode = key )
225253
226254 def sortUpdate (self , sort = None ):
@@ -238,6 +266,9 @@ def sortUpdate(self, sort=None):
238266
239267 collection.updateSort(mode="alpha")
240268 """
269+ if self .smart :
270+ raise BadRequest ('Cannot change collection order for a smart collection.' )
271+
241272 sort_dict = {
242273 'release' : 0 ,
243274 'alpha' : 1 ,
0 commit comments