diff --git a/lib/plexapi/media.py b/lib/plexapi/media.py index da19d48a..710a4cda 100644 --- a/lib/plexapi/media.py +++ b/lib/plexapi/media.py @@ -586,6 +586,29 @@ class MediaTag(PlexObject): return self.fetchItems(self.key) +class GuidTag(PlexObject): + """ Base class for guid tags used only for Guids, as they contain only a string identifier + Attributes: + server (:class:`~plexapi.server.PlexServer`): Server this client is connected to. + id (id): Tag ID (Used as a unique id, except for Guid's, used for external systems + to plex identifiers, like imdb and tmdb). + """ + + def _loadData(self, data): + """ Load attribute values from Plex XML response. """ + self._data = data + self.id = data.attrib.get('id') + self.tag = data.attrib.get('tag') + + def items(self, *args, **kwargs): + """ Return the list of items within this tag. This function is only applicable + in search results from PlexServer :func:`~plexapi.server.PlexServer.search()`. + """ + if not self.key: + raise BadRequest('Key is not defined for this tag: %s' % self.tag) + return self.fetchItems(self.key) + + @utils.registerPlexObject class Collection(MediaTag): """ Represents a single Collection media tag. @@ -665,6 +688,12 @@ class Genre(MediaTag): FILTER = 'genre' +@utils.registerPlexObject +class Guid(GuidTag): + """ Represents a single Guid media tag. """ + TAG = "Guid" + + @utils.registerPlexObject class Mood(MediaTag): """ Represents a single Mood media tag. diff --git a/lib/plexapi/video.py b/lib/plexapi/video.py index c78dc793..a324d039 100644 --- a/lib/plexapi/video.py +++ b/lib/plexapi/video.py @@ -266,6 +266,7 @@ class Movie(Playable, Video): directors (List<:class:`~plexapi.media.Director`>): List of director objects. fields (List<:class:`~plexapi.media.Field`>): List of field objects. genres (List<:class:`~plexapi.media.Genre`>): List of genre objects. + guids (List<:class:`~plexapi.media.Guid`>): List of guid objects. media (List<:class:`~plexapi.media.Media`>): List of media objects. producers (List<:class:`~plexapi.media.Producer`>): List of producers objects. roles (List<:class:`~plexapi.media.Role`>): List of role objects. @@ -310,6 +311,7 @@ class Movie(Playable, Video): self.directors = self.findItems(data, media.Director) self.fields = self.findItems(data, media.Field) self.genres = self.findItems(data, media.Genre) + self.guids = self.findItems(data, media.Guid) self.media = self.findItems(data, media.Media) self.producers = self.findItems(data, media.Producer) self.roles = self.findItems(data, media.Role)