@@ -534,7 +534,8 @@ def listChoices(self, category, libtype=None, **kwargs):
534534 key = '/library/sections/%s/%s%s' % (self .key , category , utils .joinArgs (args ))
535535 return self .fetchItems (key , cls = FilterChoice )
536536
537- def search (self , title = None , sort = None , maxresults = 999999 , libtype = None , container_size = None , ** kwargs ):
537+ def search (self , title = None , sort = None , maxresults = 999999 ,
538+ libtype = None , container_size = X_PLEX_CONTAINER_SIZE , ** kwargs ):
538539 """ Search the library. If there are many results, they will be fetched from the server
539540 in batches of X_PLEX_CONTAINER_SIZE amounts. If you're only looking for the first <num>
540541 results, it would be wise to set the maxresults option to that amount so this functions
@@ -547,6 +548,7 @@ def search(self, title=None, sort=None, maxresults=999999, libtype=None, contain
547548 maxresults (int): Only return the specified number of results (optional).
548549 libtype (str): Filter results to a spcifiec libtype (movie, show, episode, artist,
549550 album, track; optional).
551+ container_size (int): default X_PLEX_CONTAINER_SIZE in your config file.
550552 **kwargs (dict): Any of the available filters for the current library section. Partial string
551553 matches allowed. Multiple matches OR together. Negative filtering also possible, just add an
552554 exclamation mark to the end of filter name, e.g. `resolution!=1x1`.
@@ -582,18 +584,20 @@ def search(self, title=None, sort=None, maxresults=999999, libtype=None, contain
582584 results = []
583585 subresults = []
584586 args ['X-Plex-Container-Start' ] = 0
585- args ['X-Plex-Container-Size' ] = container_size or X_PLEX_CONTAINER_SIZE
587+ args ['X-Plex-Container-Size' ] = container_size
586588 while True :
587589 key = '/library/sections/%s/all%s' % (self .key , utils .joinArgs (args ))
588590 subresults = self .fetchItems (key )
589591 results .extend (subresults )
590592
591- # this si not set as condition in the while as
593+ # self.totalSize is not used as a condition in the while loop as
592594 # this require a additional http request.
595+ # self.totalSize is updated from .fetchItems
593596 if self .totalSize <= len (results ):
594597 break
595598
596599 args ['X-Plex-Container-Start' ] += args ['X-Plex-Container-Size' ]
600+
597601 return results [:maxresults ]
598602
599603 def _cleanSearchFilter (self , category , value , libtype = None ):
0 commit comments