Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trakt Ratings #2425

Merged
merged 4 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Logic added to Kometa to create `config.yml` if it does not exist from the `conf
When using `mass_poster_update`, added `ignore_locked` and `ignore_overlays` attributes which will prevent Kometa from resetting the image if the poster field is locked (i.e. a previous mass poster update) or if the item has an Overlay. This can effectively act as a differential update system.
When using `mass_background_update`, added `ignore_locked` attribute which will prevent Kometa from resetting the image if the poster field is locked (i.e. a previous mass poster update). This can effectively act as a differential update system.
Add `date` option for schedules
Add `trakt`, `omdb_metascore`, `omdb_tomatoes` ratings sources for mass operations.
Add `trakt` ratings source for mass episode operations.

# Docs
Added "getting started" page
Expand Down
2 changes: 1 addition & 1 deletion PART
Original file line number Diff line number Diff line change
@@ -1 +1 @@

1
2 changes: 2 additions & 0 deletions docs/config/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ You can create individual blocks of operations by using a list under `operations
<table class="clearTable">
<tr><td>`tmdb`</td><td>Use TMDb Rating</td></tr>
<tr><td>`imdb`</td><td>Use IMDb Rating</td></tr>
<tr><td>`trakt`</td><td>Use Trakt Rating</td></tr>
<tr><td>`trakt_user`</td><td>Use Trakt User's Personal Rating</td></tr>
<tr><td>`omdb`</td><td>Use IMDbRating through OMDb</td></tr>
<tr><td>`omdb_metascore`</td><td>Use Metacritic Metascore through OMDb</td></tr>
Expand Down Expand Up @@ -456,6 +457,7 @@ You can create individual blocks of operations by using a list under `operations
<table class="clearTable">
<tr><td>`tmdb`</td><td>Use TMDb Rating</td></tr>
<tr><td>`imdb`</td><td>Use IMDb Rating</td></tr>
<tr><td>`trakt`</td><td>Use Trakt Rating</td></tr>
<tr><td>`lock`</td><td>Lock Rating Field</td></tr>
<tr><td>`unlock`</td><td>Unlock Rating Field</td></tr>
<tr><td>`remove`</td><td>Remove Rating and Lock Field</td></tr>
Expand Down
3 changes: 2 additions & 1 deletion modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
}
mass_episode_rating_options = {
"lock": "Lock Rating", "unlock": "Unlock Rating", "remove": "Remove and Lock Rating", "reset": "Remove and Unlock Rating",
"tmdb": "Use TMDb Rating", "imdb": "Use IMDb Rating"
"tmdb": "Use TMDb Rating", "imdb": "Use IMDb Rating", "trakt": "Use Trakt Rating"
}
mass_rating_options = {
"lock": "Lock Rating",
Expand All @@ -106,6 +106,7 @@
"reset": "Remove and Unlock Rating",
"tmdb": "Use TMDb Rating",
"imdb": "Use IMDb Rating",
"trakt": "Use Trakt Rating",
"trakt_user": "Use Trakt User Rating",
"omdb": "Use IMDb Rating through OMDb",
"omdb_metascore": "Use Metacritic Metascore through OMDb",
Expand Down
4 changes: 4 additions & 0 deletions modules/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ def mal_obj():
found_rating = tmdb_obj().vote_average # noqa
elif option == "imdb":
found_rating = self.config.IMDb.get_rating(imdb_id)
elif option == "trakt":
found_rating = self.config.Trakt.get_rating(imdb_id, self.library.is_movie)
elif option == "trakt_user":
_ratings = trakt_ratings()
_id = tmdb_id if self.library.is_movie else tvdb_id
Expand Down Expand Up @@ -916,6 +918,8 @@ def mal_obj():
logger.error(er)
elif imdb_id and option == "imdb":
found_rating = self.config.IMDb.get_episode_rating(imdb_id, ep.seasonNumber, ep.episodeNumber)
elif imdb_id and option == "trakt":
found_rating = self.config.Trakt.get_episode_rating(imdb_id, ep.seasonNumber, ep.episodeNumber)
else:
try:
found_rating = float(option)
Expand Down
9 changes: 9 additions & 0 deletions modules/trakt.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ def user_ratings(self, is_movie):
id_type = "tmdb" if is_movie else "tvdb"
return {int(i[media]["ids"][id_type]): i["rating"] for i in self._request(f"/users/me/ratings/{media}s")}

def get_episode_rating(self, show_id, season, episode):
response = self._request(f"/shows/{show_id}/seasons/{season}/episodes/{episode}/ratings")
return response["rating"]

def get_rating(self, show_id, is_movie):
item_type = 'movies' if is_movie else 'shows'
response = self._request(f"/{item_type}/{show_id}/ratings")
return response["rating"]

def convert(self, external_id, from_source, to_source, media_type):
path = f"/search/{from_source}/{external_id}"
params = {"type": media_type} if from_source in ["tmdb", "tvdb"] else None
Expand Down
Loading