Add episodes_collection property to TraktApi
MODIFY
plextraktsync/trakt/TraktApi.py
plextraktsync/trakt/TraktApi.py
from plextraktsync.trakt.types import TraktMedia
if TYPE_CHECKING:
- from typing import Optional, Union
+ from typing import Any, Generator, Optional, Union
from trakt.movies import Movie
- from trakt.tv import TVShow
+ from trakt.tv import TVEpisode, TVShow
from plextraktsync.plex.PlexGuid import PlexGuid
from plextraktsync.plex.PlexLibraryItem import PlexLibraryItem
@@ -85,6 +85,14 @@ def movie_collection(self):
def show_collection(self):
return self.me.show_collection
+ @cached_property
+ @flatten_list
+ def episodes_collection(self) -> List[TVEpisode]:
+ for show in self.show_collection:
+ for season in show.seasons:
+ for episode in season.episodes:
+ yield episode
+
def remove_from_collection(self, m: TraktMedia):
if m.media_type not in ["movies", "shows", "episodes"]:
raise ValueError(f"Unsupported media type: {m.media_type}")

Add episodes_collection property to TraktApi