From edfb618269cc6418ecc57c380255e4cd6d0bc616 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Fri, 31 May 2024 15:45:39 -0400 Subject: [PATCH] [38] Added `total_runtime` as a special text overlay variable (#2089) --- CHANGELOG | 1 + VERSION | 2 +- defaults/overlays/runtimes.yml | 3 ++- docs/defaults/overlays/runtimes.md | 7 ++++--- docs/files/overlays.md | 11 ++++++----- modules/overlay.py | 2 ++ modules/overlays.py | 6 +++++- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a44708ab..365807ef 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ Update setuptools requirement to 70.0.0 Checks requirement versions to print a message if one needs to be updated Added the `mass_added_at_update` operation to mass set the Added At field of Movies and Shows. Add automated Anime Aggregations for AniDB matching +Added `total_runtime` as a special text overlay variable. Added `top_tamil`, `top_telugu`, `top_malayalam`, `trending_india`, `trending_tamil`, and `trending_telugu` as options for `imdb_chart` Adds the `sort_by` attribute to `imdb_list` diff --git a/VERSION b/VERSION index 9db4b4be..40d49975 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.1-build37 +2.0.1-build38 diff --git a/defaults/overlays/runtimes.yml b/defaults/overlays/runtimes.yml index b3aa1843..8d3c6a0a 100644 --- a/defaults/overlays/runtimes.yml +++ b/defaults/overlays/runtimes.yml @@ -10,6 +10,7 @@ external_templates: template_variables: default: text: "Runtime: " + format: "<>h <>m" horizontal_align: right vertical_align: bottom conditionals: @@ -32,7 +33,7 @@ external_templates: back_color: "#00000099" back_width: 600 back_height: 105 - final_name: "text(<><>h <>m)" + final_name: "text(<><>)" overlays: runtime_info: diff --git a/docs/defaults/overlays/runtimes.md b/docs/defaults/overlays/runtimes.md index dcd6386a..abe2c272 100644 --- a/docs/defaults/overlays/runtimes.md +++ b/docs/defaults/overlays/runtimes.md @@ -57,9 +57,10 @@ work. Any value not specified will use its default value if it has one if not it === "File-Specific Template Variables" - | Variable | Description & Values | - |:----------|:-----------------------------------------------------------------------------------------------------------------------------------------| - | `text` | **Description:** Choose the text that appears prior to the runtime on the Overlay.
**Default:** `Runtime: `
**Values:** Any String | + | Variable | Description & Values | + |:---------|:-----------------------------------------------------------------------------------------------------------------------------------------| + | `text` | **Description:** Choose the text that appears prior to the runtime on the Overlay.
**Default:** `Runtime: `
**Values:** Any String | + | `format` | **Description:** Choose the format of the the displayed runtime.
**Default:** `<>h <>m`
**Values:** Any String | === "Overlay Template Variables" diff --git a/docs/files/overlays.md b/docs/files/overlays.md index 73077de4..0391a40b 100644 --- a/docs/files/overlays.md +++ b/docs/files/overlays.md @@ -391,11 +391,12 @@ Each Special Text Variables has multiple modifiers that can be used to format th ##### Other Special Text -| Special Text Variables & Mods | Item Types | -|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------| -| `<>`: Complete Runtime of the Item in minutes (`150`)
`<>`: Hours in runtime of the Item (`2`)
`<>`: Minutes remaining in the hour in the runtime of the Item (`30`)
**Show and Season use average Episode Runtime.** | `Movies`, `Shows`, `Seasons`, or `Episodes` | -| `<>`: Bitrate of the first media file for an item.
`<>`: Bitrate of the media file with the highest bitrate
`<>`: Bitrate of the media file with the lowest bitrate | `Movies` or `Episodes` | -| `<>`: Original Available Date of the Item
`<>`: Original Available Date of the Item in the given format. [Format Options](https://strftime.org/) | `Movies`, `Shows`, or `Episodes` | +| Special Text Variables & Mods | Item Types | +|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------| +| `<>`: Complete Runtime of the Item in minutes (`150`)
`<>`: Hours in runtime of the Item (`2`)
`<>`: Minutes remaining in the hour in the runtime of the Item (`30`)
**Show and Season use average Episode Runtime.** | `Movies`, `Shows`, `Seasons`, or `Episodes` | +| `<>`: Complete combined Runtime of all Episodes/Tracks of the Item in minutes (`150`)
`<>`: Hours in total runtime of the Item (`2`)
`<>`: Minutes remaining in the hour in the runtime of the Item (`30`) | `Shows`, `Seasons`, `Artists`, or `Albums` | +| `<>`: Bitrate of the first media file for an item.
`<>`: Bitrate of the media file with the highest bitrate
`<>`: Bitrate of the media file with the lowest bitrate | `Movies` or `Episodes` | +| `<>`: Original Available Date of the Item
`<>`: Original Available Date of the Item in the given format. [Format Options](https://strftime.org/) | `Movies`, `Shows`, or `Episodes` | ```yaml overlays: diff --git a/modules/overlay.py b/modules/overlay.py index 97a2e200..9f8e62f4 100644 --- a/modules/overlay.py +++ b/modules/overlay.py @@ -25,6 +25,7 @@ types_for_var = { "movie_show_season_episode_artist_album": ["runtime", "user_rating", "title"], "movie_show_episode_album": ["critic_rating", "originally_available"], "movie_show_season_episode": ["tmdb_rating"], + "show_season_artist_album": ["total_runtime"], "movie_show_episode": ["audience_rating", "content_rating", "tmdb_rating", "imdb_rating"], "movie_show": [ "original_title", "trakt_user_rating", "omdb_rating", "mdb_rating", "mdb_average_rating", "mdb_imdb_rating", @@ -42,6 +43,7 @@ var_mods = { "bitrate": ["", "H", "L"], "originally_available": ["", "["], "runtime": ["", "H", "M"], + "total_runtime": ["", "H", "M"], } for mod in float_vars: var_mods[mod] = ["", "%", "#", "/"] diff --git a/modules/overlays.py b/modules/overlays.py index 7d6de060..a0933b02 100644 --- a/modules/overlays.py +++ b/modules/overlays.py @@ -390,6 +390,10 @@ class Overlays: sub_items = item.episodes() if text_overlay.level in ["show", "season"] else item.tracks() sub_items = [ep.duration for ep in sub_items if hasattr(ep, "duration") and ep.duration] actual_value = sum(sub_items) / len(sub_items) + elif format_var == "total_runtime": + sub_items = item.episodes() if text_overlay.level in ["show", "season"] else item.tracks() + sub_items = [ep.duration for ep in sub_items if hasattr(ep, "duration") and ep.duration] + actual_value = sum(sub_items) else: if not hasattr(item, actual_attr) or getattr(item, actual_attr) is None: raise Failed(f"Overlay Warning: No {full_text} found") @@ -406,7 +410,7 @@ class Overlays: final_value = actual_value.strftime(mod) else: final_value = actual_value.strftime("%Y-%m-%d") - elif format_var == "runtime": + elif format_var in ["runtime", "total_runtime"]: if mod == "H": final_value = int((actual_value / 60000) // 60) elif mod == "M":