Skip to content

Commit

Permalink
update trakt watched_movies list during scan
Browse files Browse the repository at this point in the history
  • Loading branch information
simonc56 committed Sep 7, 2021
1 parent 83ded35 commit a3859fa
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions plex_trakt_sync/trakt_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class TraktApi:

def __init__(self, batch_size=None):
self.batch = TraktBatch(self, batch_size=batch_size)
self._watched_movies = {}
trakt.core.CONFIG_PATH = pytrakt_file
trakt.core.session = factory.session()
load_config()
Expand Down Expand Up @@ -88,13 +89,14 @@ def liked_lists(self):
return pytrakt_extensions.get_liked_lists()

@property
@memoize
@nocache
@rate_limit()
def watched_movies(self):
return set(
map(lambda m: m.trakt, self.me.watched_movies)
)
if not self._watched_movies:
self._watched_movies = set(
map(lambda m: m.trakt, self.me.watched_movies)
)
return self._watched_movies

@property
@memoize
Expand Down Expand Up @@ -181,6 +183,7 @@ def scrobbler(media: Union[Movie, TVEpisode]) -> ScrobblerProxy:
@time_limit()
def mark_watched(self, m, time):
m.mark_as_seen(time)
self._watched_movies.add(trakt_id)

def add_to_collection(self, m, pm: PlexLibraryItem):
if m.media_type == "movies":
Expand Down

0 comments on commit a3859fa

Please sign in to comment.