[44] Add support for the other two ratings provided by OMDB (#2422)

small-fixes
Chaz Larson 2 weeks ago committed by GitHub Action
parent 0130ae6d8f
commit 8c4b483663

@ -1 +1 @@
2.1.0-build43
2.1.0-build44

@ -387,6 +387,8 @@ You can create individual blocks of operations by using a list under `operations
<tr><td>`imdb`</td><td>Use IMDb 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>
<tr><td>`omdb_tomatoes`</td><td>Use Rotten Tomatoes rating through OMDb</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>

@ -108,6 +108,8 @@ mass_rating_options = {
"imdb": "Use IMDb Rating",
"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",
"mdb": "Use MDBList Score",
"mdb_average": "Use MDBList Average Score",
"mdb_imdb": "Use IMDb Rating through MDBList",

@ -39,13 +39,22 @@ class OMDbObj:
self.imdb_rating = _parse("imdbRating", is_float=True)
self.imdb_votes = _parse("imdbVotes", is_int=True, replace=",")
self.metacritic_rating = _parse("Metascore", is_int=True)
self.rotten_tomatoes = None
try:
for rating in data["Ratings"]:
if rating["Source"] == "Rotten Tomatoes":
data["tempRT"] = rating["Value"] # This is a hack to allow _parse to work without changes
self.rotten_tomatoes = _parse("tempRT", is_int=True, replace="%")
break
except KeyError:
pass
self.imdb_id = _parse("imdbID")
self.type = _parse("Type")
self.series_id = _parse("seriesID")
self.season_num = _parse("Season", is_int=True)
self.episode_num = _parse("Episode", is_int=True)
class OMDb:
def __init__(self, requests, cache, params):
self.requests = requests

@ -376,8 +376,6 @@ class Operations:
found_rating = tmdb_obj().vote_average # noqa
elif option == "imdb":
found_rating = self.config.IMDb.get_rating(imdb_id)
elif option == "omdb":
found_rating = omdb_obj().imdb_rating # noqa
elif option == "trakt_user":
_ratings = trakt_ratings()
_id = tmdb_id if self.library.is_movie else tvdb_id
@ -385,6 +383,14 @@ class Operations:
found_rating = _ratings[_id]
else:
raise Failed
elif str(option).startswith("omdb"):
omdb_item = omdb_obj()
if option == "omdb":
found_rating = omdb_item.imdb_rating # noqa
elif option == "omdb_metascore":
found_rating = omdb_item.metacritic_rating / 10 if omdb_item.metacritic_rating else None # noqa
elif option == "omdb_tomatoes":
found_rating = omdb_item.rotten_tomatoes / 10 if omdb_item.rotten_tomatoes else None # noqa
elif str(option).startswith("mdb"):
mdb_item = mdb_obj()
if option == "mdb_average":

Loading…
Cancel
Save