Skip to content

Commit

Permalink
Merge pull request #2119 from glensc/rating-titles
Browse files Browse the repository at this point in the history
Feature: Show rating titles from trakt
  • Loading branch information
glensc authored Dec 29, 2024
2 parents 6c7d406 + 981c1ef commit a1c133a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion plextraktsync/util/Rating.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ class Rating(NamedTuple):
rating: int
rated_at: datetime | None

RATING_TITLES = {
1: "Weak Sauce :(",
2: "Terrible",
3: "Bad",
4: "Poor",
5: "Meh",
6: "Fair",
7: "Good",
8: "Great",
9: "Superb",
10: "Totally Ninja!",
}

def __eq__(self, other):
"""Ratings are equal if their rating value is the same"""
if isinstance(other, (int, float)):
Expand All @@ -20,9 +33,13 @@ def __eq__(self, other):

return self.rating == other.rating

@property
def title(self):
return self.RATING_TITLES[self.rating]

def __str__(self):
rated_at = f"'{timestamp(self.rated_at)}'" if self.rated_at else None
return f"Rating(rating={self.rating}, rated_at={rated_at})"
return f"Rating(rating={self.rating}, rated_at={rated_at}, title={self.title})"

@classmethod
def create(cls, rating: int | float | None, rated_at: datetime | str | None):
Expand Down

0 comments on commit a1c133a

Please sign in to comment.