Skip to content

retrieve guids is super slow #1128

Description

@BenjaminOddou

Describe the Bug

When trying to retrieve guids from the api, the response become very slow.

retrieving movies guids :

61680 function calls (148385 primitive calls) in 0.401 seconds

retrieving movies genres :

151 function calls in 0.000 seconds

Code Snippets

import cProfile
from plexapi.server import PlexServer

plex_instance = PlexServer(baseURL, plexToken)
test = plex_instance.search('harry potter', mediatype='movie')

def myfunction():
    for m in test:
        print(m.guids) # replace by m.genres

cProfile.run('myfunction()')

Expected Behavior

Same response time as other properties.

Additional Context

No response

Operating System and Version

macOS 13.2.1 (22D68)

Plex Media Server Version

1.31.1.6733

Python Version

3.11.2

PlexAPI Version

4.13.4

Activity

  1. JonnyWong16 commented on Mar 16, 2023

    @JonnyWong16
    Collaborator

    This is expected.

    A global Plex server search (hub search) doesn't provide guids in the response. This is equivalent to typing into the search box in Plex Web and displaying the results in the dropdown list. So to get the guids, PlexAPI has to make a second API call to .reload() the object (equivalent to clicking on one of the results in the dropdown list).

    You should search in a specific library instead. This is equivalent to using the "Advanced Filters" in a library. This API response includes the guids so no additional API calls are required.

    plex.library.section('Movies').search('harry potter')
    
  2. BenjaminOddou commented on Mar 16, 2023

    @BenjaminOddou
    ContributorAuthor

    Ok I see. In my case, I need a hub search so I was thinking querying guids only when needed by providing a unique identifier to the library section like so plex_instance.library.sectionByID(int(sectionID)).getGuid(guid) (guid can be retrived from hub search apparently). The drawback is that it will not work for agents like hama... Is there another unique identifier (except guid) that allows me to return a specific media in plex ?

    EDIT: Ok I think this will be my workaround -> [plex_instance.library.sectionByID(int(_sectionID)).fetchItem(_key).guids]. Passing the key seems to work better 😄

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