Skip to content

Library search breaks early when using a PlexAPI operator #694

Description

@JonnyWong16

Describe the issue
The current library search loop breaks when no results are found.

https://github.com/pkkid/python-plexapi/blob/4.4.1/plexapi/library.py#L691

If a PlexAPI operator is used (e.g. viewCount__gt=0), the first batch of results may return 0 results (i.e. There are no items with a view count greater than 1 in the first 100 items (container_size)). This causes the loop to break without continuing the search through the rest of the items.

Code snipppets

>>> library = plex.library.section("TV Shows")
>>> results = library.search(libtype='episode', container_size=1, viewCount__gte=0)
>>> print(len(results))
0

image

Expected behavior
Search should continue looping through the rest of the items.

Proposed solution is to add a check if the container exceeds the total number of items to exit the loop.

https://github.com/pkkid/python-plexapi/blob/4.4.1/plexapi/library.py#L707

if container_start > self.totalSize:
    break

Enviroment (please complete the following information):

  • PlexAPI version: 4.4.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions