get trakt collection through sync/collection request
MODIFY
plextraktsync/media.py
plextraktsync/media.py
@@ -73,8 +73,9 @@ def is_collected(self):
f"is_collected: Unsupported media type: {self.media_type}"
)
- collected = self.show.collected
- return collected.get_completed(self.season_number, self.episode_number)
+ collected = self.trakt_api.collected_shows
+ return collected.is_collected(
+ self.show_trakt_id, self.season_number, self.episode_number)
@cached_property
def collected(self):

MODIFY
plextraktsync/pytrakt_extensions.py
plextraktsync/pytrakt_extensions.py
@@ -49,9 +49,16 @@ def instance(self):
@get
def allwatched():
- # returns a ShowProgress object containing all watched episodes
+ # returns a AllShowProgress object containing all watched shows
data = yield "sync/watched/shows"
- yield AllWatchedShows(data)
+ yield AllShowsProgress(data)
+
+
+@get
+def allcollected():
+ # returns a AllShowProgress object containing all collected shows
+ data = yield "sync/collection/shows"
+ yield AllShowsProgress(data)
@get
@@ -63,7 +70,7 @@ def watched(show_id):
@get
def collected(show_id):
- # returns a ShowProgress object containing the watched states of the passed show
+ # returns a ShowProgress object containing the collected states of the passed show
data = yield "shows/{}/progress/collection?specials=true".format(show_id)
yield ShowProgress(**data)
@@ -152,7 +159,7 @@ def get_completed(self, season, episode):
return self.seasons[season].get_completed(episode)
-class AllWatchedShows:
+class AllShowsProgress:
def __init__(self, shows=None):
self.shows = {}
for show in shows:
@@ -166,6 +173,13 @@ def get_completed(self, trakt_id, season, episode):
return False
return self.shows[trakt_id].seasons[season].get_completed(episode)
+ def is_collected(self, trakt_id, season, episode):
+ if trakt_id not in self.shows.keys():
+ return False
+ elif season not in self.shows[trakt_id].seasons.keys():
+ return False
+ return episode in self.shows[trakt_id].seasons[season].episodes.keys()
+
def add(self, trakt_id, season, episode):
episode_prog = {"number": episode, "completed": True}
season_prog = {"number": season, "episodes": [episode_prog]}

MODIFY
plextraktsync/trakt_api.py
plextraktsync/trakt_api.py
@@ -160,6 +160,12 @@ def movie_collection_set(self):
def watched_shows(self):
return pytrakt_extensions.allwatched()
+ @cached_property
+ @nocache
+ @rate_limit()
+ def collected_shows(self):
+ return pytrakt_extensions.allcollected()
+
@cached_property
@nocache
@rate_limit()

get trakt collection through sync/collection request