Skip to content

Commit e0ed2d1

Browse files
committed
Fix calls to hub.items
1 parent 176a3ff commit e0ed2d1

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

plexapi/library.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,7 @@ def albums(self):
19671967

19681968
def stations(self):
19691969
""" Returns a list of :class:`~plexapi.playlist.Playlist` stations in this section. """
1970-
return next((hub.items for hub in self.hubs() if hub.context == 'hub.music.stations'), None)
1970+
return next((hub._partialItems for hub in self.hubs() if hub.context == 'hub.music.stations'), None)
19711971

19721972
def searchArtists(self, **kwargs):
19731973
""" Search for an artist. See :func:`~plexapi.library.LibrarySection.search` for usage. """
@@ -2231,6 +2231,11 @@ def _loadData(self, data):
22312231
def __len__(self):
22322232
return self.size
22332233

2234+
@cached_data_property
2235+
def _partialItems(self):
2236+
""" Cache for partial items. """
2237+
return self.findItems(self._data)
2238+
22342239
@cached_data_property
22352240
def _items(self):
22362241
""" Cache for items. """
@@ -2240,7 +2245,7 @@ def _items(self):
22402245
self.size = len(items)
22412246
return items
22422247
# Otherwise, all the data is in the initial _data XML response
2243-
return self.findItems(self._data)
2248+
return self._partialItems
22442249

22452250
def items(self):
22462251
""" Returns a list of all items in the hub. """

plexapi/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,9 +806,9 @@ def search(self, query, mediatype=None, limit=None, sectionId=None):
806806
for hub in self.fetchItems(key, Hub):
807807
if mediatype:
808808
if hub.type == mediatype:
809-
return hub.items
809+
return hub._partialItems
810810
else:
811-
results += hub.items
811+
results += hub._partialItems
812812
return results
813813

814814
def continueWatching(self):

tests/test_video.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ def test_video_Movie_hubs(movies):
570570
assert hub.context == "hub.movie.similar"
571571
assert utils.is_metadata(hub.hubKey)
572572
assert hub.hubIdentifier == "movie.similar"
573-
assert len(hub.items) == hub.size
573+
assert len(hub._partialItems) == hub.size
574574
assert utils.is_metadata(hub.key)
575575
assert hub.more is False
576576
assert hub.random is False
@@ -582,7 +582,7 @@ def test_video_Movie_hubs(movies):
582582
# Force hub reload
583583
hub.more = True
584584
hub.reload()
585-
assert len(hub.items) == hub.size
585+
assert len(hub.items()) == hub.size
586586
assert hub.more is False
587587
assert hub.size == 1
588588

0 commit comments

Comments
 (0)