Default value for {source} if nothing is found?

All your suggestions, requests and ideas for future development
Post Reply
casperse
Posts: 29
Joined: 19 Aug 2017, 09:17

Default value for {source} if nothing is found?

Post by casperse »

Hi All

I bought the version in windows 10 app store and love how I can fix things!

Lately I have some problems with source, and would like to know if I can add a "default" value if nothing is found?

What I am trying to do is adding "WEB-DL." if nothing is found?
I already have a rule so all the different naming like /WEB.RIP|WEBRip|WEBDL|WEB.DL|WEB|web/ ? /WEB-DL/ : null} is named WEB-DL

Code: Select all

\\#FILEBOT_TV/{primaryTitle.ascii().replace(':','')}/{plex[2]}/{n} - {episode.special ? 's00e'+special.pad(2) : s00e00.lower()} - {t.replaceAll(/[`´‘’?]/, /'/).replaceAll(/[!?.]+$/).replacePart(', Part $1')} [{any{fn =~ /WEB.RIP|WEBRip|WEBDL|WEB.DL|WEB|web/ ? /WEB-DL/ : null}{source}}{'.'+VF}{'.'+VC}{'.'+BITDEPTH+'Bit'}{'.'+AC}{'.'+AF}]{'.'+lang}
Again thanks for a great tool! - Oh And please DONT remove the "override" function I use it alot! :lol:
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Default value for {source} if nothing is found?

Post by rednoah »

e.g.

Code: Select all

any{source}{'No Source'}
:arrow: viewtopic.php?f=5&t=1895
:idea: Please read the FAQ and How to Request Help.
casperse
Posts: 29
Joined: 19 Aug 2017, 09:17

Re: Default value for {source} if nothing is found?

Post by casperse »

Hmmm like this?

Code: Select all

any{fn =~ /WEB.RIP|WEBRip|WEBDL|WEB.DL|WEB|web/ ? /WEB-DL/ : null}{source} {'WEB-DL'}
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Default value for {source} if nothing is found?

Post by rednoah »

That'll work. The any function will execute each {closure} one after another until one returns a good non-null / non-empty / non-error value.
:idea: Please read the FAQ and How to Request Help.
casperse
Posts: 29
Joined: 19 Aug 2017, 09:17

Re: Default value for {source} if nothing is found?

Post by casperse »

Thanks, great to learn new things!
Post Reply