Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard against None parentIndex #1304

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions plexapi/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,11 +961,9 @@ def parentThumb(self):
@cached_property
def _season(self):
""" Returns the :class:`~plexapi.video.Season` object by querying for the show's children. """
if not self.grandparentKey:
return None
return self.fetchItem(
f'{self.grandparentKey}/children?excludeAllLeaves=1&index={self.parentIndex}'
)
if self.grandparentKey and self.parentIndex is not None:
return self.fetchItem(f'{self.grandparentKey}/children?excludeAllLeaves=1&index={self.parentIndex}')
return None

def __repr__(self):
return '<{}>'.format(
Expand Down Expand Up @@ -1003,7 +1001,11 @@ def episodeNumber(self):
@cached_property
def seasonNumber(self):
""" Returns the episode's season number. """
return self.parentIndex if isinstance(self.parentIndex, int) else self._season.seasonNumber
if isinstance(self.parentIndex, int):
return self.parentIndex
elif self._season:
return self._season.index
return None

@property
def seasonEpisode(self):
Expand Down