@@ -578,9 +578,7 @@ def get(self, title):
578578
579579 def getGuid (self , guid ):
580580 """ Returns the media item with the specified external IMDB, TMDB, or TVDB ID.
581- Note: This search uses a PlexAPI operator so performance may be slow. All items from the
582- entire Plex library need to be retrieved for each guid search. It is recommended to create
583- your own lookup dictionary if you are searching for a lot of external guids.
581+ Note: Only available for the Plex Movie and Plex TV Series agents.
584582
585583 Parameters:
586584 guid (str): The external guid of the item to return.
@@ -593,20 +591,23 @@ def getGuid(self, guid):
593591
594592 .. code-block:: python
595593
596- # This will retrieve all items in the entire library 3 times
597594 result1 = library.getGuid('imdb://tt0944947')
598595 result2 = library.getGuid('tmdb://1399')
599596 result3 = library.getGuid('tvdb://121361')
600597
601- # This will only retrieve all items in the library once to create a lookup dictionary
598+ # Alternatively, create your own guid lookup dictionary for faster performance
602599 guidLookup = {guid.id: item for item in library.all() for guid in item.guids}
603600 result1 = guidLookup['imdb://tt0944947']
604601 result2 = guidLookup['tmdb://1399']
605602 result3 = guidLookup['tvdb://121361']
606603
607604 """
608- key = '/library/sections/%s/all?includeGuids=1' % self .key
609- return self .fetchItem (key , Guid__id__iexact = guid )
605+ try :
606+ dummy = self .search (maxresults = 1 )[0 ]
607+ match = dummy .matches (agent = self .agent , title = guid .replace ('://' , '-' ))
608+ return self .search (guid = match [0 ].guid )[0 ]
609+ except IndexError :
610+ raise NotFound ("Guid '%s' is not found in the library" % guid ) from None
610611
611612 def all (self , libtype = None , ** kwargs ):
612613 """ Returns a list of all items from this library section.
0 commit comments