Page 1 of 1

Help on scripting

Posted: 09 Mar 2016, 01:40
by cemmec
Hi,

I am new to scripting but could find some samples that are working fine to me. But I have on doubt with the following part:

Code: Select all

{"["}{def a= [];"[$media.Audio_Codec_List]".contains("DTS") ? a.add("DTS") : "";"[$media.Audio_Codec_List]".contains("AC3") ? a.add("AC3") : "";"[$media.Audio_Codec_List]".contains("MPEG-1 Audio layer 3") ? a.add("MP3") : "";a.join("+")}{"]"}
In this case if I have a DTS or AC3 on any other condition, the result is: [DTS] or [DTS+AC3] or [AC3] otherwise the result is []. I would like to have nothing as a result not []. I know that {"["} and {"]"} are returning this, but how can I make a condition with it?

Re: Help on scripting

Posted: 09 Mar 2016, 03:59
by rednoah
I'd do it like this:

Code: Select all

{audios.codec.collect{ it[0, 1, -1] }.join('+') ?: ''}

Re: Help on scripting

Posted: 09 Mar 2016, 06:02
by rednoah
FileBot r3639+ makes this easier:

Add prefix/suffix:

Code: Select all

{audios.codec.collect{ it[0, 1, -1] }.join('+', '[', ']')}
Unwind-on-empty behaviour:

Code: Select all

{[].join('+', '[', ']')}

Re: Help on scripting

Posted: 09 Mar 2016, 23:37
by cemmec
Did not find version r3639 on https://sourceforge.net/projects/filebo ... ebot/HEAD/ I'm using r3315, which I think is the latest stable version.

Where can I download r3639 ?

On version r3315 I couldn't add prefix and sufix on {audios.codec.collect{ it[0, 1, -1] }.join('+') ?: ''}

Re: Help on scripting

Posted: 10 Mar 2016, 20:03
by cemmec
Nevermind... it's working...

Thanks one more time!