diff --git a/plexapi/base.py b/plexapi/base.py index d9c4476f5..5b98875eb 100644 --- a/plexapi/base.py +++ b/plexapi/base.py @@ -145,7 +145,12 @@ def fetchItems(self, ekey, cls=None, **kwargs): on how this is used. """ data = self._server.query(ekey) - return self.findItems(data, cls, ekey, **kwargs) + items = self.findItems(data, cls, ekey, **kwargs) + librarySectionID = data.attrib.get('librarySectionID') + if librarySectionID: + for item in items: + item.librarySectionID = librarySectionID + return items def findItems(self, data, cls=None, initpath=None, **kwargs): """ Load the specified data to find and build all items with the specified tag diff --git a/plexapi/photo.py b/plexapi/photo.py index 9563b9bf0..26a4be688 100644 --- a/plexapi/photo.py +++ b/plexapi/photo.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from plexapi import media, utils from plexapi.base import PlexPartialObject +from plexapi.exceptions import NotFound, BadRequest from plexapi.exceptions import NotFound from plexapi.compat import quote_plus @@ -124,7 +125,12 @@ def photoalbum(self): def section(self): """ Returns the :class:`~plexapi.library.LibrarySection` this item belongs to. """ - return self._server.library.sectionByID(self.photoalbum().librarySectionID) + if hasattr(self, 'librarySectionID'): + return self._server.library.sectionByID(self.librarySectionID) + elif self.parentKey: + return self._server.library.sectionByID(self.photoalbum().librarySectionID) + else: + raise BadRequest('Unable to get section for photo, can`t find librarySectionID') def sync(self, resolution, client=None, clientId=None, limit=None, title=None): """ Add current photo as sync item for specified device.