Skip to content

Commit 1c591f6

Browse files
authored
Guard against None parentIndex (#1304)
#1251 (comment)
1 parent f7522af commit 1c591f6

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

plexapi/video.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -925,11 +925,9 @@ def parentThumb(self):
925925
@cached_property
926926
def _season(self):
927927
""" Returns the :class:`~plexapi.video.Season` object by querying for the show's children. """
928-
if not self.grandparentKey:
929-
return None
930-
return self.fetchItem(
931-
f'{self.grandparentKey}/children?excludeAllLeaves=1&index={self.parentIndex}'
932-
)
928+
if self.grandparentKey and self.parentIndex is not None:
929+
return self.fetchItem(f'{self.grandparentKey}/children?excludeAllLeaves=1&index={self.parentIndex}')
930+
return None
933931

934932
def __repr__(self):
935933
return '<{}>'.format(
@@ -967,7 +965,11 @@ def episodeNumber(self):
967965
@cached_property
968966
def seasonNumber(self):
969967
""" Returns the episode's season number. """
970-
return self.parentIndex if isinstance(self.parentIndex, int) else self._season.seasonNumber
968+
if isinstance(self.parentIndex, int):
969+
return self.parentIndex
970+
elif self._season:
971+
return self._season.index
972+
return None
971973

972974
@property
973975
def seasonEpisode(self):

0 commit comments

Comments
 (0)