Plex: Add seen_date property
+import datetime
from plexapi.library import MovieSection, ShowSection, LibrarySection
from plexapi.video import Movie, Show
from plex_trakt_sync.decorators import memoize, nocache
@@ -51,6 +52,17 @@ def id(self):
def rating(self):
return int(self.item.userRating) if self.item.userRating is not None else None
+ @property
+ @memoize
+ def seen_date(self):
+ movie = self.item
+ date = (movie.lastViewedAt if movie.lastViewedAt else datetime.now())
+
+ try:
+ return date.astimezone(datetime.timezone.utc)
+ except ValueError: # for py<3.6
+ return date
+
@property
@memoize
def guid_is_imdb_legacy(self):
