Skip to content

Commit b96f421

Browse files
author
Touchstone64
committed
Correct the implementation of relational key construction in Episode._season(), separating XML attributes from key construction.
1 parent fabbe18 commit b96f421

2 files changed

Lines changed: 18 additions & 19 deletions

File tree

plexapi/mixins/tv_parent_child.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
class TvParentChildMixin:
55
""" Mixin for Plex objects that have parent/child relationships (episode/season/show). """
66

7-
def _buildRelationKey(self, key, **kwargs):
7+
def _buildRelationalKey(self, key, **kwargs):
88
""" Returns a key suitable for fetching parent/child TV items
99
1010
Parameters:
11-
key (str): The relational key being fetched, such as '/children' (may be
12-
empty).
13-
**kwargs (dict): Custom XML attribute filters to apply to add to the
14-
query. See :func:`~plexapi.base.PlexObject.fetchItems` for more
15-
details on how this is used.
11+
key (str): The relational key to be fetched.
12+
**kwargs (dict): Optional relational selection parameters to apply to the
13+
key, for example 'excludeAllLeaves=1'. Additional options (such as XML
14+
filters) should be passed into search functions. See :func:`~plexapi.base.PlexObject.fetchItems`
15+
for details.
1616
1717
"""
1818
if not key:

plexapi/video.py

Lines changed: 12 additions & 13 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._buildRelationKey(f'{self.key}/children', excludeAllLeaves=1)
713+
key = self._buildRelationalKey(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._buildRelationKey(f'{self.key}/children', excludeAllLeaves=1)
726+
key = self._buildRelationalKey(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._buildRelationKey(f'{self.key}/allLeaves')
740+
key = self._buildRelationalKey(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._buildRelationKey(f'{self.key}/allLeaves')
749+
key = self._buildRelationalKey(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._buildRelationKey(f'{self.key}/children')
909+
key = self._buildRelationalKey(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._buildRelationKey(f'{self.key}/children')
922+
key = self._buildRelationalKey(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._buildRelationKey(self.parentKey))
931+
return self.fetchItem(self._buildRelationalKey(self.parentKey))
932932

933933
def watched(self):
934934
""" Returns list of watched :class:`~plexapi.video.Episode` objects. """
@@ -1136,12 +1136,11 @@ 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._buildRelationKey(
1139+
key = self._buildRelationalKey(
11401140
f'{self.grandparentKey}/children',
1141-
excludeAllLeaves=1,
1142-
index=self.parentIndex
1141+
excludeAllLeaves=1
11431142
)
1144-
return self.fetchItem(key)
1143+
return self.fetchItem(key, index=self.parentIndex)
11451144
return None
11461145

11471146
def __repr__(self):
@@ -1218,11 +1217,11 @@ def hasPreviewThumbnails(self):
12181217

12191218
def season(self):
12201219
"""" Return the episode's :class:`~plexapi.video.Season`. """
1221-
return self.fetchItem(self._buildRelationKey(self.parentKey))
1220+
return self.fetchItem(self._buildRelationalKey(self.parentKey))
12221221

12231222
def show(self):
12241223
"""" Return the episode's :class:`~plexapi.video.Show`. """
1225-
return self.fetchItem(self._buildRelationKey(self.grandparentKey))
1224+
return self.fetchItem(self._buildRelationalKey(self.grandparentKey))
12261225

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

0 commit comments

Comments
 (0)