hasProperty() is always FALSE

Any questions? Need some help?
Post Reply
Pat
Posts: 23
Joined: 07 Nov 2014, 15:52

hasProperty() is always FALSE

Post by Pat »

I am trying to rename my videos with language information, or show the audio streams count when no language info is available. This is imposible, hasPropertiy() is broken as this example shows:

{ (audio.hasProperty("language")) ? "YES" : "NO " + audio.language }

if defined (ie: language=ru), it prints: "NO ru"
if not defined, it prints nothing (throws an exception trying to get audio.language)

That is, in both cases audio.hasProperty("language") is FALSE, regardless of .language being defined or not.

Is this a bug where?

Tested both, 4.5 and 4.5.2 with
openjdk version "1.8.0_40"
OpenJDK Runtime Environment (build 1.8.0_40-b10)
OpenJDK 64-Bit Server VM (build 25.40-b14, mixed mode)
User avatar
rednoah
The Source
Posts: 23004
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: hasProperty() is always FALSE

Post by rednoah »

audio does not implement hasProperty. It's not a "normal" map/object since everything is only lazy evaluated, so "properties" only exist on access.

This is how I'd write a conditional format:

Code: Select all

{ any{'Language is '+audio.language}{'No Language'} } 
:idea: Please read the FAQ and How to Request Help.
Pat
Posts: 23
Joined: 07 Nov 2014, 15:52

Re: hasProperty() is always FALSE

Post by Pat »

Not being my field, I thought for hours about a workaround, nothing I tried worked. You made my day, thanks!

{n} - {s00e00.lower()} - {t} [{vf}.{vc}.{ac}.{ any{af+'('+audios.language.join(" ")+")"}{(audios.size()>1) ? audios.size()+"x"+af : af}}{any{'.Sub('+texts.language.join(".")+")"}{(texts.size()>0) ? '.'+texts.size()+"xSub":""}{""}}]{"."+lang}

Which translates for video to ie:
The Walking Dead - s05e01 - No Sanctuary [720p.HEVC.AAC.2ch(en).Sub(en.fr)]
The Walking Dead - s05e02 - The title here [720p.HEVC.AAC.2ch(en).2xSub)]
And for aditional external subtitles to:
The Walking Dead - s05e02 - The title here [720p.HEVC.AAC.2ch(en).2xSub)].rus
Post Reply