Skip to content

Commit 57f27ea

Browse files
authored
Fix handling of live TV sessions (#1260)
* Handle parsing live TV without season information * Add guards for parent keys
1 parent 94734ae commit 57f27ea

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

plexapi/video.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,11 @@ def _loadData(self, data):
930930
@cached_property
931931
def parentKey(self):
932932
""" Returns the parentKey. Refer to the Episode attributes. """
933-
return self._parentKey or f'/library/metadata/{self.parentRatingKey}'
933+
if self._parentKey:
934+
return self._parentKey
935+
if self.parentRatingKey:
936+
return f'/library/metadata/{self.parentRatingKey}'
937+
return None
934938

935939
@cached_property
936940
def parentRatingKey(self):
@@ -940,17 +944,25 @@ def parentRatingKey(self):
940944
# Parse the parentRatingKey from the parentThumb
941945
if self._parentThumb and self._parentThumb.startswith('/library/metadata/'):
942946
return utils.cast(int, self._parentThumb.split('/')[3])
943-
# Get the parentRatingKey from the season's ratingKey
944-
return self._season.ratingKey
947+
# Get the parentRatingKey from the season's ratingKey if available
948+
if self._season:
949+
return self._season.ratingKey
950+
return None
945951

946952
@cached_property
947953
def parentThumb(self):
948954
""" Returns the parentThumb. Refer to the Episode attributes. """
949-
return self._parentThumb or self._season.thumb
955+
if self._parentThumb:
956+
return self._parentThumb
957+
if self._season:
958+
return self._season.thumb
959+
return None
950960

951961
@cached_property
952962
def _season(self):
953963
""" Returns the :class:`~plexapi.video.Season` object by querying for the show's children. """
964+
if not self.grandparentKey:
965+
return None
954966
return self.fetchItem(
955967
f'{self.grandparentKey}/children?excludeAllLeaves=1&index={self.parentIndex}'
956968
)

0 commit comments

Comments
 (0)