add episodes to trakt ratings fetch
MODIFY
plex_trakt_sync/media.py
plex_trakt_sync/media.py
@@ -85,7 +85,13 @@ def mark_watched_plex(self):
@property
def trakt_rating(self):
- return self.trakt_api.rating(self.trakt)
+ if self.trakt.media_type == 'movies':
+ rating = self.trakt_api.movie_ratings.get(self.trakt.trakt, None)
+ if self.trakt.media_type == 'episodes':
+ rating = self.trakt_api.episode_ratings.get(self.trakt.trakt, None)
+ if rating:
+ return int(rating)
+ return None
@property
def plex_rating(self):

MODIFY
plex_trakt_sync/trakt_api.py
plex_trakt_sync/trakt_api.py
@@ -141,23 +141,21 @@ def watchlist_movies(self):
@nocache
@rate_limit()
def movie_ratings(self):
- return self.me.get_ratings(media_type='movies')
+ ratings = {}
+ for r in self.me.get_ratings(media_type='movies'):
+ ratings[r['movie']['ids']['trakt']] = r['rating']
+ return ratings
@property
@memoize
- def ratings(self):
+ @nocache
+ @rate_limit()
+ def episode_ratings(self):
ratings = {}
- for r in self.movie_ratings:
- ratings[r['movie']['ids']['slug']] = r['rating']
-
+ for r in self.me.get_ratings(media_type='episodes'):
+ ratings[r['episode']['ids']['trakt']] = r['rating']
return ratings
- def rating(self, m):
- if m.slug in self.ratings:
- return int(self.ratings[m.slug])
-
- return None
-
@nocache
@rate_limit()
@time_limit()

add episodes to trakt ratings fetch