How do I use String.removeIllegalCharacters() in my custom format?

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
User avatar
MrEthernet
Posts: 13
Joined: 11 May 2020, 23:11

How do I use String.removeIllegalCharacters() in my custom format?

Post by MrEthernet »

I'm using the following format expression:

Code: Select all

{n}/{'Season '+s.pad(2)}/{n} - {s00e00.lower()} - {t.removeIllegalCharacters()}
It works great so far but I would also like illegal characters in the season name string to be excluded. How can I achieve this?

I tried the following, but it didn't work as I put the ".removeIllegalCharacters()" in the wrong place:

Code: Select all

{n}/{'Season '+s.pad(2).removeIllegalCharacters()}/{n} - {s00e00.lower()} - {t.removeIllegalCharacters()}
Any ideas?
Last edited by MrEthernet on 13 May 2020, 02:48, edited 1 time in total.
kim
Power User
Posts: 1027
Joined: 15 May 2014, 16:17

Re: Scripting help (basic question!)

Post by kim »

Code: Select all

{n.removeIllegalCharacters()}{'/' + 'Season '+s.pad(2)}{'/' + n.removeIllegalCharacters()}{' - ' + s00e00.lower()}{' - ' + t.removeIllegalCharacters()}
btw: but why

Code: Select all

[b].removeIllegalCharacters()[/b]
User avatar
MrEthernet
Posts: 13
Joined: 11 May 2020, 23:11

Re: Scripting help (basic question!)

Post by MrEthernet »

kim wrote: 13 May 2020, 02:20

Code: Select all

{n.removeIllegalCharacters()}{'/' + 'Season '+s.pad(2)}{'/' + n.removeIllegalCharacters()}{' - ' + s00e00.lower()}{' - ' + t.removeIllegalCharacters()}
Thank you! That works beautifully. :D

btw: but why

Code: Select all

[b].removeIllegalCharacters()[/b]
I put the tags around it to try to emphasize the part that wasn't working.

Just noticed it didn't bold it anyway! I've taken them back out.
User avatar
MrEthernet
Posts: 13
Joined: 11 May 2020, 23:11

Re: Scripting help (basic question!)

Post by MrEthernet »

Would you be able to do the same for the format expression for my movies?

Code: Select all

{n.colon(' - ')} ({y})
User avatar
rednoah
The Source
Posts: 18995
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Scripting help (basic question!)

Post by rednoah »

String.removeIllegalCharacters() works on every String object, so you can use it anywhere you want.


:arrow: Sounds like you just want to use {plex} though, which will take care of everything implicitly:
viewtopic.php?t=4116
:idea: Please read the FAQ and How to Request Help.
User avatar
MrEthernet
Posts: 13
Joined: 11 May 2020, 23:11

Re: Scripting help (basic question!)

Post by MrEthernet »

rednoah wrote: 13 May 2020, 05:46 :arrow: Sounds like you just want to use {plex} though, which will take care of everything implicitly:
viewtopic.php?t=4116
Thanks. I'm using {plex} now. :)

Is there any way to view all of the expressions contained within a binding, such as {plex}, in order to see exactly how it will behave and to study it more closely?

For example, I'm not sure if the {plex} binding handles subtitle naming. It would be nice to see exactly what expressions it uses by viewing the code itself. Is this possible by any chance?
User avatar
rednoah
The Source
Posts: 18995
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How do I use String.removeIllegalCharacters() in my custom format?

Post by rednoah »

You can inspect Groovy properties for any Object like so:

Code: Select all

{plex.properties}

:arrow: You can check the code. But running tests on a representative set of files is probably better, because the latter you should be doing anyway. ;)


:idea: If you drop a set of files into List then you can prototype format expressions while simultaneously testing it against a number of files, so you can easily test how your format works on different files as you go along.
:idea: Please read the FAQ and How to Request Help.
User avatar
MrEthernet
Posts: 13
Joined: 11 May 2020, 23:11

Re: How do I use String.removeIllegalCharacters() in my custom format?

Post by MrEthernet »

rednoah wrote: 14 May 2020, 04:26 You can inspect Groovy properties for any Object like so:

Code: Select all

{plex.properties}
Good to know!
rednoah wrote: 14 May 2020, 04:26 :arrow: You can check the code. But running tests on a representative set of files is probably better, because the latter you should be doing anyway. ;)
Makes sense. I'll probably use a combination of both. I can't code yet and I think it would help me to learn by messing around with some real-world code that is actually useful.
rednoah wrote: 14 May 2020, 04:26 :idea: If you drop a set of files into List then you can prototype format expressions while simultaneously testing it against a number of files, so you can easily test how your format works on different files as you go along.
I haven't dabbled with the List tab yet but maybe now's the time!
User avatar
MrEthernet
Posts: 13
Joined: 11 May 2020, 23:11

Re: How do I use String.removeIllegalCharacters() in my custom format?

Post by MrEthernet »

rednoah wrote: 14 May 2020, 04:26 You can inspect Groovy properties for any Object like so:

Code: Select all

{plex.properties}
I'm guessing that to be able to do that, I would need Groovy and the Java SE Development Kit 8 installed?

So I went ahead and installed them and I think I'm slowly making progress now! The first thing I noticed was that my presets in FileBot had all disappeared. Maybe installing Groovy overwrote some FileBot data or something? Any ideas?

It's not a problem at all, as I already had everything copied into a text file but I'm just curious if you've ever heard of presets all suddenly disappearing like that.

After installing these:

Image

These all vanished:

Image

So anyway, to inspect Groovy properties for an object, would I run something like this in Command Prompt?

Code: Select all

groovy {plex.properties}]
I feel like I need to point Groovy to a directory where it would find the {plex} object defined, maybe the FileBot directory or something? Am I way off base here?

I've also tried using the Groovy Shell but no luck yet.

Sorry, I don't have a coding background, hence my very basic questions! :)
User avatar
rednoah
The Source
Posts: 18995
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How do I use String.removeIllegalCharacters() in my custom format?

Post by rednoah »

1.
You're way off base. You need neither Java nor Groovy. FileBot uses these technologies as a platform, and FileBot wouldn't work if these technologies weren't already built into the FileBot installer package. Installing Java and Groovy separately, or not, will generally have no effect on FileBot.


:idea: Your persistent settings may disappear if you purge the registry. I don't think any of those installers would do that though, especially not on install.



2.
You can play with Groovy format expressions in the FileBot Format Editor:

Code: Select all

{plex.properties}
:arrow: Click Image to open the built-in binding explorer that will show you all the commonly used bindings.

Image
:idea: Please read the FAQ and How to Request Help.
User avatar
MrEthernet
Posts: 13
Joined: 11 May 2020, 23:11

Re: How do I use String.removeIllegalCharacters() in my custom format?

Post by MrEthernet »

rednoah wrote: 15 May 2020, 07:04 You're way off base. You need neither Java nor Groovy. FileBot uses these technologies as a platform, and FileBot wouldn't work if these technologies weren't already built into the FileBot installer package. Installing Java and Groovy separately, or not, will generally have no effect on FileBot.
Thanks for explaining it so clearly! :)
rednoah wrote: 15 May 2020, 07:04
:idea: Your persistent settings may disappear if you purge the registry. I don't think any of those installers would do that though, especially not on install.
So I decided to do a little experimenting and was able to pinpoint the cause of my vanishing settings as only uninstalling Java 8 Update 251 (64 bit). Just thought I'd mention it. It's not a problem for me - I don't even need Java anyway.
rednoah wrote: 15 May 2020, 07:04 You can play with Groovy format expressions in the FileBot Format Editor:

Code: Select all

{plex.properties}
That's great! It's so much simpler than I was expecting.

I'll be able to get so much more out of FileBot now! :D
Post Reply