Skip to content

Commit 6cfa762

Browse files
ajacobsonJonnyWong16
authored andcommitted
Accept booleans for include parameters in LibrarySection.hubs()
1 parent e63986b commit 6cfa762

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎plexapi/library.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,10 +716,12 @@ def hubs(self, **kwargs):
716716
Parameters:
717717
**kwargs (dict): Optional query parameters to add to the request
718718
(e.g. ``count=10`` to limit the number of items per hub or
719-
``includeMyMixes=1`` to include the personalized "Mixes For You" hub).
720-
``includeStations=1`` is included by default and may be overridden.
719+
``includeMyMixes=True`` to include the personalized "Mixes For You" hub).
720+
``includeStations`` is included by default and may be overridden
721+
with ``includeStations=False``.
721722
"""
722723
kwargs.setdefault('includeStations', 1)
724+
kwargs = {k: 1 if v is True else 0 if v is False else v for k, v in kwargs.items()}
723725
key = self._buildQueryKey(f'/hubs/sections/{self.key}', **kwargs)
724726
return self.fetchItems(key)
725727

‎tests/test_library.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ def test_library_MusicSection_hubs_kwargs(music):
396396
assert hubs
397397
for hub in hubs:
398398
assert len(hub._partialItems) <= 5
399+
hubs = music.hubs(includeStations=False)
400+
assert not any(h.context == "hub.music.stations" for h in hubs)
399401

400402

401403
def test_library_ShowSection_all(tvshows):

‎tests/test_playlist.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def test_Playlist_attrs(playlist):
3838
def test_Playlist_centroid(plex, music, requests_mock):
3939
# 'Mix For You' playlists cannot be generated on the bootstrap server,
4040
# so serve a representative hubs response and parse it through the normal path.
41-
requests_mock.get(plex.url(f"/hubs/sections/{music.key}"), text=MUSIC_MIXES_HUB)
42-
hubs = music.hubs(includeMyMixes=1)
41+
requests_mock.get(plex.url(f"/hubs/sections/{music.key}?includeMyMixes=1"), text=MUSIC_MIXES_HUB)
42+
hubs = music.hubs(includeMyMixes=True)
4343
mix = next(h for h in hubs if h.context == "hub.music.mixes").items()[0]
4444
assert mix.smart is True
4545
centroid = mix.centroid

0 commit comments

Comments
 (0)