Skip to content

Commit 587618f

Browse files
author
Touchstone64
committed
Rename the relational key builder to be a query key builder
1 parent b3dc7a6 commit 587618f

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

plexapi/base.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,11 @@ def _buildDetailsKey(self, **kwargs):
176176
details_key += '?' + urlencode(sorted(params.items()))
177177
return details_key
178178

179-
def _buildRelationalKey(self, key, **kwargs):
180-
""" Returns a key suitable for fetching partial objects extended to
181-
include relational information.
179+
def _buildQueryKey(self, key, **kwargs):
180+
""" Returns a query key suitable for fetching partial objects.
182181
183182
Parameters:
184-
key (str): The relational key to be fetched.
183+
key (str): The key to which options should be added to form a query.
185184
**kwargs (dict): Optional query parameters to add to the key, such as
186185
'excludeAllLeaves=1' or 'index=0'. Additional XML filters should instead
187186
be passed into search functions. See :func:`~plexapi.base.PlexObject.fetchItems`

plexapi/video.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ def season(self, title=None, season=None):
710710
Raises:
711711
:exc:`~plexapi.exceptions.BadRequest`: If title or season parameter is missing.
712712
"""
713-
key = self._buildRelationalKey(f'{self.key}/children', excludeAllLeaves=1)
713+
key = self._buildQueryKey(f'{self.key}/children', excludeAllLeaves=1)
714714
if title is not None and not isinstance(title, int):
715715
return self.fetchItem(key, Season, title__iexact=title)
716716
elif season is not None or isinstance(title, int):
@@ -723,7 +723,7 @@ def season(self, title=None, season=None):
723723

724724
def seasons(self, **kwargs):
725725
""" Returns a list of :class:`~plexapi.video.Season` objects in the show. """
726-
key = self._buildRelationalKey(f'{self.key}/children', excludeAllLeaves=1)
726+
key = self._buildQueryKey(f'{self.key}/children', excludeAllLeaves=1)
727727
return self.fetchItems(key, Season, container_size=self.childCount, **kwargs)
728728

729729
def episode(self, title=None, season=None, episode=None):
@@ -737,7 +737,7 @@ def episode(self, title=None, season=None, episode=None):
737737
Raises:
738738
:exc:`~plexapi.exceptions.BadRequest`: If title or season and episode parameters are missing.
739739
"""
740-
key = self._buildRelationalKey(f'{self.key}/allLeaves')
740+
key = self._buildQueryKey(f'{self.key}/allLeaves')
741741
if title is not None:
742742
return self.fetchItem(key, Episode, title__iexact=title)
743743
elif season is not None and episode is not None:
@@ -746,7 +746,7 @@ def episode(self, title=None, season=None, episode=None):
746746

747747
def episodes(self, **kwargs):
748748
""" Returns a list of :class:`~plexapi.video.Episode` objects in the show. """
749-
key = self._buildRelationalKey(f'{self.key}/allLeaves')
749+
key = self._buildQueryKey(f'{self.key}/allLeaves')
750750
return self.fetchItems(key, Episode, **kwargs)
751751

752752
def get(self, title=None, season=None, episode=None):
@@ -906,7 +906,7 @@ def episode(self, title=None, episode=None):
906906
Raises:
907907
:exc:`~plexapi.exceptions.BadRequest`: If title or episode parameter is missing.
908908
"""
909-
key = self._buildRelationalKey(f'{self.key}/children')
909+
key = self._buildQueryKey(f'{self.key}/children')
910910
if title is not None and not isinstance(title, int):
911911
return self.fetchItem(key, Episode, title__iexact=title)
912912
elif episode is not None or isinstance(title, int):
@@ -919,7 +919,7 @@ def episode(self, title=None, episode=None):
919919

920920
def episodes(self, **kwargs):
921921
""" Returns a list of :class:`~plexapi.video.Episode` objects in the season. """
922-
key = self._buildRelationalKey(f'{self.key}/children')
922+
key = self._buildQueryKey(f'{self.key}/children')
923923
return self.fetchItems(key, Episode, **kwargs)
924924

925925
def get(self, title=None, episode=None):
@@ -928,7 +928,7 @@ def get(self, title=None, episode=None):
928928

929929
def show(self):
930930
""" Return the season's :class:`~plexapi.video.Show`. """
931-
return self.fetchItem(self._buildRelationalKey(self.parentKey))
931+
return self.fetchItem(self._buildQueryKey(self.parentKey))
932932

933933
def watched(self):
934934
""" Returns list of watched :class:`~plexapi.video.Episode` objects. """
@@ -1136,7 +1136,7 @@ def parentThumb(self):
11361136
def _season(self):
11371137
""" Returns the :class:`~plexapi.video.Season` object by querying for the show's children. """
11381138
if self.grandparentKey and self.parentIndex is not None:
1139-
key = self._buildRelationalKey(
1139+
key = self._buildQueryKey(
11401140
f'{self.grandparentKey}/children',
11411141
excludeAllLeaves=1,
11421142
index=self.parentIndex
@@ -1218,11 +1218,11 @@ def hasPreviewThumbnails(self):
12181218

12191219
def season(self):
12201220
"""" Return the episode's :class:`~plexapi.video.Season`. """
1221-
return self.fetchItem(self._buildRelationalKey(self.parentKey))
1221+
return self.fetchItem(self._buildQueryKey(self.parentKey))
12221222

12231223
def show(self):
12241224
"""" Return the episode's :class:`~plexapi.video.Show`. """
1225-
return self.fetchItem(self._buildRelationalKey(self.grandparentKey))
1225+
return self.fetchItem(self._buildQueryKey(self.grandparentKey))
12261226

12271227
def _defaultSyncTitle(self):
12281228
""" Returns str, default title for a new syncItem. """

0 commit comments

Comments
 (0)