Add is_episode, show_id properties
MODIFY
plex_trakt_sync/plex_api.py
plex_trakt_sync/plex_api.py
@@ -59,6 +59,30 @@ def id(self):
x = x.split("?")[0]
return x
+ @property
+ @memoize
+ def is_episode(self):
+ """
+ Return true of the id is in form of <show>/<season>/<episode>
+ """
+ parts = self.id.split("/")
+ if len(parts) == 3 and all(x.isnumeric() for x in parts):
+ return True
+
+ return False
+
+ @property
+ @memoize
+ def show_id(self):
+ if not self.is_episode:
+ raise ValueError("show_id is not valid for non-episodes")
+
+ show = self.id.split("/", 1)[0]
+ if not show.isnumeric():
+ raise ValueError(f"show_id is not numeric: {show}")
+
+ return int(show)
+
@property
@memoize
def rating(self):

Add is_episode, show_id properties