@@ -456,10 +456,45 @@ def get(self, title):
456456
457457 Parameters:
458458 title (str): Title of the item to return.
459+
460+ Raises:
461+ :exc:`~plexapi.exceptions.NotFound`: The title is not found in the library.
459462 """
460- key = '/library/sections/%s/all?title=%s' % (self .key , quote (title , safe = '' ))
463+ key = '/library/sections/%s/all?includeGuids=1& title=%s' % (self .key , quote (title , safe = '' ))
461464 return self .fetchItem (key , title__iexact = title )
462465
466+ def getGuid (self , guid ):
467+ """ Returns the media item with the specified external IMDB, TMDB, or TVDB ID.
468+ Note: This search uses a PlexAPI operator so performance may be slow. All items from the
469+ entire Plex library need to be retrieved for each guid search. It is recommended to create
470+ your own lookup dictionary if you are searching for a lot of external guids.
471+
472+ Parameters:
473+ guid (str): The external guid of the item to return.
474+ Examples: IMDB ``imdb://tt0944947``, TMDB ``tmdb://1399``, TVDB ``tvdb://121361``.
475+
476+ Raises:
477+ :exc:`~plexapi.exceptions.NotFound`: The guid is not found in the library.
478+
479+ Example:
480+
481+ .. code-block:: python
482+
483+ # This will retrieve all items in the entire library 3 times
484+ result1 = library.getGuid('imdb://tt0944947')
485+ result2 = library.getGuid('tmdb://1399')
486+ result3 = library.getGuid('tvdb://121361')
487+
488+ # This will only retrieve all items in the library once to create a lookup dictionary
489+ guidLookup = {guid.id: item for item in library.all() for guid in item.guids}
490+ result1 = guidLookup['imdb://tt0944947']
491+ result2 = guidLookup['tmdb://1399']
492+ result3 = guidLookup['tvdb://121361']
493+
494+ """
495+ key = '/library/sections/%s/all?includeGuids=1' % self .key
496+ return self .fetchItem (key , Guid__id__iexact = guid )
497+
463498 def all (self , libtype = None , ** kwargs ):
464499 """ Returns a list of all items from this library section.
465500 See description of :func:`~plexapi.library.LibrarySection.search()` for details about filtering / sorting.
@@ -979,6 +1014,8 @@ def _buildSearchKey(self, title=None, sort=None, libtype=None, limit=None, filte
9791014 """
9801015 args = {}
9811016 filter_args = []
1017+
1018+ args ['includeGuids' ] = int (bool (kwargs .pop ('includeGuids' , True )))
9821019 for field , values in list (kwargs .items ()):
9831020 if field .split ('__' )[- 1 ] not in OPERATORS :
9841021 filter_args .append (self ._validateFilterField (field , values , libtype ))
0 commit comments