Skip to content

Commit 9b3b65b

Browse files
authored
Support global hubs (#873)
* Get global hubs * Add hub filtering arguments * Simplify
1 parent b89bd23 commit 9b3b65b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

plexapi/library.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,28 @@ def sectionByID(self, sectionID):
8282
except KeyError:
8383
raise NotFound('Invalid library sectionID: %s' % sectionID) from None
8484

85+
def hubs(self, sectionID=None, identifier=None, **kwargs):
86+
""" Returns a list of :class:`~plexapi.library.Hub` across all library sections.
87+
88+
Parameters:
89+
sectionID (int or str or list, optional):
90+
IDs of the sections to limit results or "playlists".
91+
identifier (str or list, optional):
92+
Names of identifiers to limit results.
93+
Available on `Hub` instances as the `hubIdentifier` attribute.
94+
Examples: 'home.continue' or 'home.ondeck'
95+
"""
96+
if sectionID:
97+
if not isinstance(sectionID, list):
98+
sectionID = [sectionID]
99+
kwargs['contentDirectoryID'] = ",".join(map(str, sectionID))
100+
if identifier:
101+
if not isinstance(identifier, list):
102+
identifier = [identifier]
103+
kwargs['identifier'] = ",".join(identifier)
104+
key = '/hubs%s' % utils.joinArgs(kwargs)
105+
return self.fetchItems(key)
106+
85107
def all(self, **kwargs):
86108
""" Returns a list of all media from all library sections.
87109
This may be a very large dataset to retrieve.

0 commit comments

Comments
 (0)