Skip to content

Commit

Permalink
[38] Added total_runtime as a special text overlay variable (Kometa…
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 authored and actions-user committed May 31, 2024
1 parent 27a6c48 commit edfb618
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1-build37
2.0.1-build38
3 changes: 2 additions & 1 deletion defaults/overlays/runtimes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ external_templates:
template_variables:
default:
text: "Runtime: "
format: "<<runtimeH>>h <<runtimeM>>m"
horizontal_align: right
vertical_align: bottom
conditionals:
Expand All @@ -32,7 +33,7 @@ external_templates:
back_color: "#00000099"
back_width: 600
back_height: 105
final_name: "text(<<text>><<runtimeH>>h <<runtimeM>>m)"
final_name: "text(<<text>><<format>>)"

overlays:
runtime_info:
Expand Down
7 changes: 4 additions & 3 deletions docs/defaults/overlays/runtimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br>**Default:** `Runtime: `<br>**Values:** Any String |
| Variable | Description & Values |
|:---------|:-----------------------------------------------------------------------------------------------------------------------------------------|
| `text` | **Description:** Choose the text that appears prior to the runtime on the Overlay.<br>**Default:** `Runtime: `<br>**Values:** Any String |
| `format` | **Description:** Choose the format of the the displayed runtime.<br>**Default:** `<<runtimeH>>h <<runtimeM>>m`<br>**Values:** Any String |

=== "Overlay Template Variables"

Expand Down
11 changes: 6 additions & 5 deletions docs/files/overlays.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------|
| `<<runtime>>`: Complete Runtime of the Item in minutes (`150`)<br>`<<runtimeH>>`: Hours in runtime of the Item (`2`)<br>`<<runtimeM>>`: Minutes remaining in the hour in the runtime of the Item (`30`)<br>**Show and Season use average Episode Runtime.** | `Movies`, `Shows`, `Seasons`, or `Episodes` |
| `<<bitrate>>`: Bitrate of the first media file for an item.<br>`<<bitrateH>>`: Bitrate of the media file with the highest bitrate<br>`<<bitrateL>>`: Bitrate of the media file with the lowest bitrate | `Movies` or `Episodes` |
| `<<originally_available>>`: Original Available Date of the Item<br>`<<originally_available[FORMAT]>>`: 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 |
|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------|
| `<<runtime>>`: Complete Runtime of the Item in minutes (`150`)<br>`<<runtimeH>>`: Hours in runtime of the Item (`2`)<br>`<<runtimeM>>`: Minutes remaining in the hour in the runtime of the Item (`30`)<br>**Show and Season use average Episode Runtime.** | `Movies`, `Shows`, `Seasons`, or `Episodes` |
| `<<total_runtime>>`: Complete combined Runtime of all Episodes/Tracks of the Item in minutes (`150`)<br>`<<runtimeH>>`: Hours in total runtime of the Item (`2`)<br>`<<runtimeM>>`: Minutes remaining in the hour in the runtime of the Item (`30`) | `Shows`, `Seasons`, `Artists`, or `Albums` |
| `<<bitrate>>`: Bitrate of the first media file for an item.<br>`<<bitrateH>>`: Bitrate of the media file with the highest bitrate<br>`<<bitrateL>>`: Bitrate of the media file with the lowest bitrate | `Movies` or `Episodes` |
| `<<originally_available>>`: Original Available Date of the Item<br>`<<originally_available[FORMAT]>>`: Original Available Date of the Item in the given format. [Format Options](https://strftime.org/) | `Movies`, `Shows`, or `Episodes` |

```yaml
overlays:
Expand Down
2 changes: 2 additions & 0 deletions modules/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"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",
Expand All @@ -42,6 +43,7 @@
"bitrate": ["", "H", "L"],
"originally_available": ["", "["],
"runtime": ["", "H", "M"],
"total_runtime": ["", "H", "M"],
}
for mod in float_vars:
var_mods[mod] = ["", "%", "#", "/"]
Expand Down
6 changes: 5 additions & 1 deletion modules/overlays.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ def get_text(text_overlay):
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")
Expand All @@ -406,7 +410,7 @@ def get_text(text_overlay):
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":
Expand Down

0 comments on commit edfb618

Please sign in to comment.