if statements followed by else if. How to do this?

All about user-defined episode / movie / file name format expressions
Post Reply
stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

if statements followed by else if. How to do this?

Post by stephen147 »

Hi all,

I have the code below:

Code: Select all

{n} - ({d}) {s00e00} - {t.replace(':','-').replaceAll(/[\/:*?"<>|]/,' - ')} {vf} {"${self.source ?: 'NA'}"} {ac} {af.replaceAll(/2ch/, "2ch").replaceAll(/6ch/, "5.1ch")} {vc}{"_${self.group ?: 'NA'}"}
Which outputs the string: Mad Men - (2013-06-09) S06E11 - Favors 720p HDTV AC3 5.1ch x264_PublicHD

So that's what I have so far.

But I've came across a slight problem. I know the file was encoded by 'Ehhhh' but the group binding does not have that info.

What I was after was if it does have the binding group then write that (Which is what I have) but if it doesn't then look in the title for it and write it or ELSE IF write '_NA' (Which is what I have also).

See screenshot for a visual idea what i mean.

Image

Thanks.

EDIT: I've learned this

Code: Select all

{"_"+fn.after(/[_]/)}
works to grap anything after an '_' to give me '_Ehhhh' . So.

How I incorporate that into:

Code: Select all

{"_${self.group ?: 'NA'}"}
User avatar
rednoah
The Source
Posts: 23004
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: if statements followed by else if. How to do this?

Post by rednoah »

@see "Learn how {expressions} work and useful Helper Functions"

Use the any{...}{...}
:idea: Please read the FAQ and How to Request Help.
stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

Re: if statements followed by else if. How to do this?

Post by stephen147 »

Thanks, I can now see how that works. I did read that link. Just need to get used to the syntax.

Trouble is I think Java is stopping the application from getting its bindings.

I've read others on here with the same problem and followed their fixes but nothing works.

v4.6, win x64

Will I create a new thread for this?
stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

Re: if statements followed by else if. How to do this?

Post by stephen147 »

Code: Select all

{any{"_$group"}{fn.match(/_.+?$/)}{'_NA'}}
Working Code above. Thanks for your help.

I fixed the Java thing. Not sure how or what fixed it. I only install x64 java after removing them all and cleaning the registry. Then my browser only supports x86. So when I went to verify it, it couldn't find it so I installed the x86 ver. And it 'seems' to be working. I'll see how this progresses.

Thanks for a wonderful app.

My full code now:

Code: Select all

{n} - ({d}) {s00e00} - {t.replace(':','-').replaceAll(/[\/:*?"<>|]/,' - ')}     {self.vf ? self.vf + "" : self.hpi} {"${self.source ?: 'NA'}"} {ac} {af.replaceAll(/2ch/, "2ch").replaceAll(/6ch/, "5.1ch")} {vc}{any{"_$group"}{fn.match(/_.+?$/)}{'_NA'}}
Result:
Mad Men - (2008-10-19) S02E12 - The Mountain King 720p BRRip AC3 5.1ch x264_Ehhhh

Or

Mad Men - (2008-10-19) S02E12 - The Mountain King 720p BRRip AC3 5.1ch x264_NA



:evil: I SWEAR TO GOD.

The [vc] bindings and the like are not recognisable after closing the app and opening it straight back up. I made no changes in-between.
Post Reply