Throw ValueError if lastViewedAt is accessed but not set
This is fix for datetime.now() method being missing,
But the property should not be accessed when media item is not viewed
@@ -55,8 +55,11 @@ def rating(self):
@property
@memoize
def seen_date(self):
- movie = self.item
- date = (movie.lastViewedAt if movie.lastViewedAt else datetime.now())
+ media = self.item
+ if not media.lastViewedAt:
+ raise ValueError('lastViewedAt is not set')
+
+ date = media.lastViewedAt
try:
return date.astimezone(datetime.timezone.utc)
