Skip to content

Commit

Permalink
Add show property to PlexLibraryItem
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Oct 24, 2022
1 parent 4c43e49 commit e4408c5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion plextraktsync/plex_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,17 @@ def audio_codecs(self):


class PlexLibraryItem:
def __init__(self, item: Union[Movie, Show, Episode], plex: PlexApi = None):
def __init__(self,
item: Union[Movie, Show, Episode],
show: Optional[Show] = None,
plex: PlexApi = None,
):
self.item = item
self.plex = plex
if show and self.is_episode:
self._show = show
else:
self._show = None

@cached_property
def is_episode(self):
Expand All @@ -164,6 +172,16 @@ def is_episode(self):
def is_legacy_agent(self):
return not self.item.guid.startswith("plex://")

@property
def show(self):
return self._show

@show.setter
def show(self, show: Show):
if not self.is_episode:
raise RuntimeError("show property can only be set to episodes")
self._show = show

@nocache
@retry()
def get_guids(self):
Expand Down

0 comments on commit e4408c5

Please sign in to comment.