Skip to content

Commit

Permalink
add plex_* ratings
Browse files Browse the repository at this point in the history
  • Loading branch information
chazlarson committed Jan 12, 2025
1 parent b1e9e86 commit 58fc64e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/config/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ You can create individual blocks of operations by using a list under `operations
<tr><td>`omdb`</td><td>Use IMDbRating through OMDb</td></tr>
<tr><td>`omdb_metascore`</td><td>Use Metacritic Metascore through OMDb</td></tr>
<tr><td>`omdb_tomatoes`</td><td>Use Rotten Tomatoes rating through OMDb</td></tr>
<tr><td>`plex_imdb`</td><td>Use IMDB Rating through Plex</td></tr>
<tr><td>`plex_tmdb`</td><td>Use TMDB Rating through Plex</td></tr>
<tr><td>`plex_tomatoes`</td><td>Use Rotten Tomatoes Rating through Plex</td></tr>
<tr><td>`plex_tomatoesaudience`</td><td>Use Rotten Tomatoes Audience Rating through Plex</td></tr>
<tr><td>`mdb`</td><td>Use MDBList Score</td></tr>
<tr><td>`mdb_average`</td><td>Use MDBList Average Score</td></tr>
<tr><td>`mdb_imdb`</td><td>Use IMDb Rating through MDBList</td></tr>
Expand Down
6 changes: 5 additions & 1 deletion modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@
"trakt_user": "Use Trakt User Rating",
"omdb": "Use IMDb Rating through OMDb",
"omdb_metascore": "Use Metacritic Metascore through OMDb",
"omdb_tomatoes": "Use Rotten Tomatoes rating through OMDb",
"omdb_tomatoes": "Use Rotten Tomatoes Rating through OMDb",
"plex_imdb": "Use IMDB Rating through Plex",
"plex_tmdb": "Use TMDB Rating through Plex",
"plex_tomatoes": "Use Rotten Tomatoes Rating through Plex",
"plex_tomatoesaudience": "Use Rotten Tomatoes Audience Rating through Plex",
"mdb": "Use MDBList Score",
"mdb_average": "Use MDBList Average Score",
"mdb_imdb": "Use IMDb Rating through MDBList",
Expand Down
6 changes: 6 additions & 0 deletions modules/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ def mal_obj():
found_rating = _ratings[_id]
else:
raise Failed
elif str(option).startswith("plex"):
ratings = self.library.get_ratings(item)
try:
found_rating = ratings[option] # noqa
except KeyError:
found_rating = None
elif str(option).startswith("omdb"):
omdb_item = omdb_obj()
if option == "omdb":
Expand Down
19 changes: 19 additions & 0 deletions modules/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,25 @@ def get_ids(self, item):
imdb_id = self.get_imdb_from_map(item)
return tmdb_id, tvdb_id, imdb_id

def get_ratings(self, item):
ratings = {
'plex_imdb': None,
'plex_tmdb': None,
'plex_tomatoes': None,
'plex_tomatoesaudience': None,
}
for rating in item.ratings:
if rating.image.startswith("imdb://"):
ratings['plex_imdb'] = rating.value
if rating.image.startswith("themoviedb://"):
ratings['plex_tmdb'] = rating.value
if rating.image.startswith("rottentomatoes://"):
if rating.image.endswith("ripe") or rating.image.endswith("rotten"):
ratings['plex_tomatoes'] = rating.value
else:
ratings['plex_tomatoesaudience'] = rating.value
return ratings

def get_locked_attributes(self, item, titles=None, year_titles=None, item_type=None):
if not item_type:
item_type = self.type
Expand Down

0 comments on commit 58fc64e

Please sign in to comment.