Kometa-Team / Kometa

Python script to update metadata information for items in plex as well as automatically build collections and playlists. The Wiki Documentation is linked below.
https://kometa.wiki
MIT License
2.44k stars 303 forks source link

"Duration" filter might not be working as intended #2192

Open Darkridge opened 1 month ago

Darkridge commented 1 month ago

Version Number

2.0.2-build28 (Docker: nightly)

What branch are you on?

nightly

Describe the Bug

The duration filter seems to return single episode runtimes even if used explicitly with build_level: show. Not sure if this is intended or if it should instead return the show runtime (similar to the <<total_runtime>> overlay).

Relevant Collection/Overlay/Playlist Definition

templates:
  show_duration:
    default:
      horizontal_offset: 10
      horizontal_align: left
      vertical_offset: 20
      vertical_align: bottom
    conditionals:
      files:
        conditions:
          - key: runtime_5_shadow
            value: config/tc_overlays/runtime/runtime_tv_5_shadow.png
          - key: runtime_4_shadow
            value: config/tc_overlays/runtime/runtime_tv_4_shadow.png
          - key: runtime_3_shadow
            value: config/tc_overlays/runtime/runtime_tv_3_shadow.png
          - key: runtime_2_shadow
            value: config/tc_overlays/runtime/runtime_tv_2_shadow.png
          - key: runtime_1_shadow
            value: config/tc_overlays/runtime/runtime_tv_1_shadow.png
      duration.gte:
        conditions:
          - key: [runtime_5, runtime_5_shadow]
            value: 10000
          - key: [runtime_4, runtime_4_shadow]
            value: 1000
          - key: [runtime_3, runtime_3_shadow]
            value: 100
          - key: [runtime_2, runtime_2_shadow]
            value: 10
          - key: [runtime_1, runtime_1_shadow]
            value: 0
      names:
        default: <<overlay_name>>
        conditions:
          - key: [runtime_5, runtime_4, runtime_3, runtime_2, runtime_1]
            value: text(<<total_runtime>>m)
    optional:
      - file
    plex_all: true
    filters:
      duration.gte: <<duration.gte>>
    builder_level: show
    overlay:
      name: <<names>>
      group: <<group>>
      weight: <<weight>>
      file: <<files>>
      horizontal_offset: <<horizontal_offset>>
      horizontal_align: <<horizontal_align>>
      vertical_offset: <<vertical_offset>>
      vertical_align: <<vertical_align>>
      back_width: 248
      back_height: 182
      back_align: left
      font_color: "#FFFFFF"
      font_size: 55
      stroke_width: 7
      stroke_color: "#000000CC"

overlays:
  runtime_5_shadow:
    variables: { key: runtime_5_shadow, weight: 500, group: backdrop }
    template: [ name: show_duration ]
  runtime_4_shadow:
    variables: { key: runtime_4_shadow, weight: 400, group: backdrop }
    template: [ name: show_duration ]
  runtime_3_shadow:
    variables: { key: runtime_3_shadow, weight: 300, group: backdrop }
    template: [ name: show_duration ]
  runtime_2_shadow:
    variables: { key: runtime_2_shadow, weight: 200, group: backdrop }
    template: [ name: show_duration ]
  runtime_1_shadow:
    variables: { key: runtime_1_shadow, weight: 100, group: backdrop }
    template: [ name: show_duration ]
  runtime_5:
    variables: { key: runtime_5, weight: 500, group: showlength }
    template: [ name: show_duration ]
  runtime_4:
    variables: { key: runtime_4, weight: 400, group: showlength }
    template: [ name: show_duration ]
  runtime_3:
    variables: { key: runtime_3, weight: 300, group: showlength }
    template: [ name: show_duration ]
  runtime_2:
    variables: { key: runtime_2, weight: 200, group: showlength }
    template: [ name: show_duration ]
  runtime_1:
    variables: { key: runtime_1, weight: 100, group: showlength }
    template: [ name: show_duration ]

Logs

No response

YozoraXCII commented 4 weeks ago

This data comes from Plex itself.

Looking at the XML of one of my shows, "Come Dine With Me", the duration of the show is listed as 1800000 which is milliseconds, equates to 30 minutes.

I appreciate that this can seem nonsensical, but it's the data that Plex provides

Darkridge commented 4 weeks ago

You might be right, hence the "might not be working as intended". The reason I brought this up originally in Discord (and was instructed to raise an issue here) is because duration is usable at both the show and episode levels. It seems logical that when used at show level, it should return the total Show runtime. Any other behavior such as show level returning episode runtimes should probably be expressly spelled out in the wiki to avoid confusion. Otherwise, there's no way to reasonably expect anyone to know that duration would return the same length whether used at show or episode level.

YozoraXCII commented 4 weeks ago

I'm not disagreeing with anything you say, but this is ultimately a Plex "issue" - when you ask for the duration of a show it gives you the duration of one of the episodes.

It would be a painstakingly tedious task for us to go through every attribute that Plex provides and make sure it is "logical".

I can look to adding some wording in the docs to state that the data returned is from Plex, so there may be some oddities similar to what you've experienced, but I don't think we have the capacity to check and document every attribute at every level.