Skip to content

Commit

Permalink
[65] New special text (#2448)
Browse files Browse the repository at this point in the history
  • Loading branch information
chazlarson authored and actions-user committed Jan 24, 2025
1 parent 2cd0401 commit 11afc2d
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 52 deletions.
1 change: 1 addition & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ mediux
meisnate
metacritic
metacriticuser
metascore
microsoft
mikenobbs
minikube
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Added `trakt`, `omdb_metascore`, `omdb_tomatoes` ratings sources for mass operat
Added `trakt` ratings source for mass episode operations.
Added GitHub token validation during config validation.
Added `plex` ratings source for mass operations.
Add recently-added ratings sources to special-text overlays.
Added IMDb Interests (sub-genres) to `imdb_search` builder
Allow `server_preroll` to accept a list
Changed default `overlay_artwork_filetype` to `webp_lossy` and `overlay_artwork_quality` to 90
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0-build64
2.1.0-build65
62 changes: 38 additions & 24 deletions docs/files/overlays.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,16 @@ tags:
- mdb_trakt_rating
- name
- omdb_rating
- omdb_imdb_rating
- omdb_metascore_rating
- omdb_tomatoes_rating
- original_title
- originally_available
- overlays
- plex_imdb_rating
- plex_tmdb_rating
- plex_tomatoes_rating
- plex_tomatoesaudience_rating
- queue
- queues
- repo
Expand Down Expand Up @@ -391,30 +398,37 @@ Each Special Text Variables has multiple modifiers that can be used to format th

##### Special Rating Text

| Variable | Description | Item Types |
|:------------------------------|:----------------------------------------|:--------------------------------------------------------------------------|
| `audience_rating` | Plex Audience Rating | `Movies`, `Shows`, or `Episodes` |
| `critic_rating` | Plex Critic Rating | `Movies`, `Shows`, or `Episodes` |
| `user_rating` | Plex User Rating | `Movies`, `Shows`, `Seasons`, or `Episodes` |
| `tmdb_rating` | TMDb Rating | `Movies`, `Shows`, `Seasons`, or `Episodes` |
| `imdb_rating` | IMDb Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup>, or `Episodes` |
| `trakt_user_rating` | Trakt User Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `omdb_rating` | OMDb Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_rating` | MDBList Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_average_rating` | MDBList Average Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_imdb_rating` | MDBList IMDb Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_metacritic_rating` | MDBList Metacritic Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_metacriticuser_rating` | MDBList Metacritic User Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_trakt_rating` | MDBList Trakt Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_tomatoes_rating` | MDBList Rotten Tomatoes Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_tomatoesaudience_rating` | MDBList Rotten Tomatoes Audience Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_tmdb_rating` | MDBList TMDb Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_letterboxd_rating` | MDBList Letterboxd Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_myanimelist_rating` | MDBList MyAnimeList Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `anidb_rating` | AniDB Rating | `Movies` or `Shows` |
| `anidb_average_rating` | AniDB Average Rating | `Movies` or `Shows` |
| `anidb_score_rating` | AniDB Score Rating | `Movies` or `Shows` |
| `mal_rating` | MyAnimeList Rating | `Movies` or `Shows` |
| Variable | Description | Item Types |
|:-------------------------------|:----------------------------------------|:--------------------------------------------------------------------------|
| `audience_rating` | Plex Audience Rating | `Movies`, `Shows`, or `Episodes` |
| `critic_rating` | Plex Critic Rating | `Movies`, `Shows`, or `Episodes` |
| `user_rating` | Plex User Rating | `Movies`, `Shows`, `Seasons`, or `Episodes` |
| `tmdb_rating` | TMDb Rating | `Movies`, `Shows`, `Seasons`, or `Episodes` |
| `imdb_rating` | IMDb Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup>, or `Episodes` |
| `trakt_rating` | Trakt Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `trakt_user_rating` | Trakt User Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `omdb_imdb_rating` | OMDb IMDb Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `omdb_metascore_rating` | OMDb Metascore Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `omdb_tomatoes_rating` | OMDb Rotten Tomatoes Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `plex_imdb_rating` | Plex IMDb Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `plex_tmdb_rating` | Plex TMDb Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `plex_tomatoes_rating` | Plex Rotten Tomatoes Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> |
| `plex_tomatoesaudience_rating` | Plex Rotten Tomatoes Audience Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> |
| `mdb_rating` | MDBList Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_average_rating` | MDBList Average Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_imdb_rating` | MDBList IMDb Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_metacritic_rating` | MDBList Metacritic Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_metacriticuser_rating` | MDBList Metacritic User Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_trakt_rating` | MDBList Trakt Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_tomatoes_rating` | MDBList Rotten Tomatoes Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_tomatoesaudience_rating` | MDBList Rotten Tomatoes Audience Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_tmdb_rating` | MDBList TMDb Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_letterboxd_rating` | MDBList Letterboxd Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `mdb_myanimelist_rating` | MDBList MyAnimeList Rating | `Movies`, `Shows`, `Seasons`<sup>1</sup> or `Episodes`<sup>1</sup> |
| `anidb_rating` | AniDB Rating | `Movies` or `Shows` |
| `anidb_average_rating` | AniDB Average Rating | `Movies` or `Shows` |
| `anidb_score_rating` | AniDB Score Rating | `Movies` or `Shows` |
| `mal_rating` | MyAnimeList Rating | `Movies` or `Shows` |

<sup>1</sup> These services do not store season or episode-level ratings, using these options will allow show ratings to be applied at the season or episode level.

Expand Down
35 changes: 30 additions & 5 deletions modules/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,33 @@
square_dim = (1000, 1000)
old_special_text = [f"{a}{s}" for a in ["audience_rating", "critic_rating", "user_rating"] for s in ["", "0", "%", "#"]]
rating_sources = [
"tmdb_rating", "imdb_rating", "trakt_user_rating", "omdb_rating", "mdb_rating", "mdb_average_rating",
"mdb_imdb_rating", "mdb_metacritic_rating", "mdb_metacriticuser_rating", "mdb_trakt_rating", "mdb_tomatoes_rating",
"mdb_tomatoesaudience_rating", "mdb_tmdb_rating", "mdb_letterboxd_rating", "mdb_myanimelist_rating",
"anidb_rating", "anidb_average_rating", "anidb_score_rating", "mal_rating"
"anidb_average_rating",
"anidb_rating",
"anidb_score_rating",
"imdb_rating",
"mal_rating",
"mdb_average_rating",
"mdb_imdb_rating",
"mdb_letterboxd_rating",
"mdb_metacritic_rating",
"mdb_metacriticuser_rating",
"mdb_myanimelist_rating",
"mdb_rating",
"mdb_tmdb_rating",
"mdb_tomatoes_rating",
"mdb_tomatoesaudience_rating",
"mdb_trakt_rating",
"omdb_rating",
"omdb_imdb_rating",
"omdb_metascore_rating",
"omdb_tomatoes_rating",
"plex_imdb_rating",
"plex_tmdb_rating",
"plex_tomatoes_rating",
"plex_tomatoesaudience_rating",
"tmdb_rating",
"trakt_rating",
"trakt_user_rating"
]
float_vars = ["audience_rating", "critic_rating", "user_rating"] + rating_sources
int_vars = ["runtime", "total_runtime", "season_number", "episode_number", "episode_count", "versions"]
Expand All @@ -28,7 +51,9 @@
"imdb_rating", "mdb_average_rating", "mdb_imdb_rating", "mdb_letterboxd_rating",
"mdb_metacritic_rating", "mdb_metacriticuser_rating", "mdb_rating",
"mdb_tmdb_rating", "mdb_tomatoes_rating", "mdb_tomatoesaudience_rating",
"mdb_trakt_rating", "mdb_myanimelist_rating", "omdb_rating", "tmdb_rating"
"mdb_trakt_rating", "mdb_myanimelist_rating", "omdb_rating", "omdb_imdb_rating", "tmdb_rating",
"omdb_metascore_rating", "omdb_tomatoes_rating", "plex_imdb_rating", "plex_tmdb_rating",
"plex_tomatoes_rating", "plex_tomatoesaudience_rating", "trakt_rating",
],
"movie_show_season": ["original_title", "trakt_user_rating"],
"show_season_artist_album": ["total_runtime"],
Expand Down
44 changes: 31 additions & 13 deletions modules/overlays.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,24 +280,18 @@ def get_text(text_overlay):
found_rating = self.config.IMDb.get_episode_rating(imdb_id, item.seasonNumber, item.episodeNumber)
else:
found_rating = self.config.IMDb.get_rating(imdb_id)
elif format_var == "omdb_rating":
if self.config.OMDb.limit is not False:
raise Failed("Daily OMDb Limit Reached")
elif not imdb_id:
raise Failed(f"No IMDb ID for Guid: {item.guid}")
else:
try:
found_rating = self.config.OMDb.get_omdb(imdb_id).imdb_rating
except Exception:
logger.error(f"IMDb ID: {imdb_id}")
raise
elif format_var == "trakt_user_rating":
_ratings = trakt_ratings()
_id = tmdb_id if self.library.is_movie else tvdb_id
if _id in _ratings:
found_rating = _ratings[_id]
else:
raise Failed("No Trakt User Rating Found")
elif format_var == "trakt_rating":
if self.config.Trakt:
found_rating = self.config.Trakt.get_rating(imdb_id, self.library.is_movie)
else:
raise Failed("No Trakt Rating Found")
elif str(format_var).startswith("mdb"):
mdb_item = None
if self.config.MDBList.limit is False:
Expand Down Expand Up @@ -355,7 +349,23 @@ def get_text(text_overlay):
found_rating = mdb_item.myanimelist_rating if mdb_item.myanimelist_rating else None
else:
found_rating = mdb_item.score / 10 if mdb_item.score else None

elif str(format_var).startswith("omdb"):
if self.config.OMDb.limit is not False:
raise Failed("Daily OMDb Limit Reached")
elif not imdb_id:
raise Failed(f"No IMDb ID for Guid: {item.guid}")
else:
try:
omdb_obj = self.config.OMDb.get_omdb(imdb_id, True)
if format_var == "omdb_metascore_rating":
found_rating = omdb_obj.metacritic_rating / 10 if omdb_obj.metacritic_rating else None
elif format_var == "omdb_tomatoes_rating":
found_rating = omdb_obj.rotten_tomatoes / 10 if omdb_obj.rotten_tomatoes else None
else:
found_rating = omdb_obj.imdb_rating if omdb_obj.imdb_rating else None
except Exception:
logger.error(f"Cannot retrieve {format_var} for: {imdb_id}")
raise
elif str(format_var).startswith(("anidb", "mal")):
anidb_id = self.config.Convert.ids_to_anidb(self.library, item.ratingKey, tvdb_id, imdb_id, tmdb_id)

Expand All @@ -382,12 +392,20 @@ def get_text(text_overlay):
raise Failed(f"{errr} of Guid: {item.guid}")
if mal_id:
found_rating = self.config.MyAnimeList.get_anime(mal_id).score
elif str(format_var).startswith("plex"):
ratings = self.library.get_ratings(item)
rating_key = format_var.replace("_rating", "")
try:
found_rating = ratings[rating_key] # noqa
except KeyError:
found_rating = None
except Failed as err:
logger.error(err)
if found_rating:
actual_value = found_rating
logger.trace(f"{format_var}: {actual_value}")
else:
raise Failed(f"No Rating Found for {item_title}")
raise Failed(f"No {format_var} found for {item_title}")
elif format_var == "runtime" and text_overlay.level in ["show", "season", "artist", "album"]:
if hasattr(item, "duration") and item.duration:
actual_value = item.duration
Expand Down
18 changes: 9 additions & 9 deletions modules/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,21 +1547,21 @@ def get_ids(self, item):

def get_ratings(self, item):
ratings = {
'plex_imdb': None,
'plex_tmdb': None,
'plex_tomatoes': None,
'plex_tomatoesaudience': None,
}
"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
ratings["plex_imdb"] = rating.value
if rating.image.startswith("themoviedb://"):
ratings['plex_tmdb'] = rating.value
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
ratings["plex_tomatoes"] = rating.value
else:
ratings['plex_tomatoesaudience'] = rating.value
ratings["plex_tomatoesaudience"] = rating.value
return ratings

def get_locked_attributes(self, item, titles=None, year_titles=None, item_type=None):
Expand Down

0 comments on commit 11afc2d

Please sign in to comment.