Request: Pre-editor editor

All your suggestions, requests and ideas for future development
Post Reply
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Request: Pre-editor editor

Post by Wolfie »

Hi @rednoah, I'm baaaaaaaaaaaaaaack! lol

I know I mentioned something like this before in one of my billion posts, but this is an official request, if it's possible to do.

Basically, an editor to allow adding or altering of values before the main line is parsed. I'm sure that's confusing, so to clear it up, when double clicking on a destination title (list on right side) to bring up the format editor, have a little button on the right (near the options to choose a recently format, etc) to open up an 'pre-format editor', where the user can define (or change) values that are used in the format string.

So, for example, I could change {n} to something else if I wanted, or add a new value of {newN} or {n2} etc. Benefit here would be that if the same thing is done multiple times in the format string, or if the user wants to simplify how the format string looks, they can do it easily.

Of course, the values should be available to the command line as well, or perhaps include an option to specify a file to include for processing before the format string is used.

Could even make it so that little button toggles an 'expert' mode that opens up another editing window in the format editor, so someone could do real-time editing in either window.

Oh and before you go looking for a gun to shoot me with, try drinking a glass of wine instead... That will do a better job of relaxing the nerves I just rattled. :lol:
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Request: Pre-editor editor

Post by rednoah »

Kinda like C pre-processor instructions? Can you describe real-world examples and use-cases?

Why not use Presets if you need different formats for different situations?

Why not access environment variables if you want the same format do different things on different machines?
:idea: Please read the FAQ and How to Request Help.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Request: Pre-editor editor

Post by Wolfie »

The idea would be to have a "pre-processor" that would do the dirty work, so that the main expression can look better.

Take, for example, the recent issue with TheTVDB, where the series start date isn't available due to a bug (for new shows). To counter the issue, using {n} and then getting the initial year from the first episode would seem simple enough. But if it's a remake of a show, then part of the {n} has the year in it, so then the year would be listed twice. So, making a folder with the name and year, then a folder with the season number, then the file with the name and year on it, that requires hacking at the name and year twice, at least without getting a little more complex. (More times for other reasons, just trust me on this one.)

Being able to remove any (yyyy) from {n} before hand, as well as making sure {y} is populated, would make it easier. Mind you, this is just a simple example.


How does one use env variables from inside filebot?

Edit: The pre-processor would only be prior to the expression, with all values already populated, with the ability to modify or define additional values.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Request: Pre-editor editor

Post by rednoah »

1.
You can use variables to avoid code duplication:

Code: Select all

{
	// VARIABLES
	def name = n.replaceTrailingBrackets()
	def year = any{y}{episodelist[0].airdate.year}{'0000'}
	def series = "$name ($year)"
	def season = "Season $s"
	def filename = "$series - $sxe - $t"

	// MAIN
	return series / season / filename
}

2.
You can access environment variables like so:

Code: Select all

System.env.HOME
:idea: You can also access Java System Properties as well as FileBot --def name=value parameters.
:idea: Please read the FAQ and How to Request Help.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Request: Pre-editor editor

Post by Wolfie »

Can you show me an actual example of that code being used?

When I try to do a { def something=something ; return something } (with and without the ; mark), it simple displays it but doesn't allow me to use the value another time.

Code: Select all

{ def name="123"; return name } ={name}=
Shows "123==" instead of "=123=" as desired.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Request: Pre-editor editor

Post by rednoah »

Note that I use a single {expression} to generate the entire file path. If you def a local variable in one {expression} then it still won't be available in another.

i.e. you cannot do this:

Code: Select all

{ def name="123"; return name } ={name}=
but you can do this:

Code: Select all

{ def name="123"; return name + ' =' + name + '=' }
:idea: Please read the FAQ and How to Request Help.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Request: Pre-editor editor

Post by Wolfie »

Okay, so redoing my entire expression, and this is what I have so far (working so far, have a few more tweaks to add to it).

Code: Select all

{
   def root="P:"
   def numb="35"
   def path=file.path.match(/(?<=${root}\\(?:dev\\)?_)..(?=\\)/)
   def wolf=any{file.path.match(/(?i)(\\WOLF\\)/)}{"/"}
   def tv="TV"
   year=any{y}{episodelist[0].airdate.year}{'0000'}
   name=n.removeAll(/\s*\((00|19|20)\d\d\)/).colon(' - ').validateFileName()
   show="${name} (${year})"
   ep=s00e00.lower()
   def season=(episode.special || episode.special == 0 ? '00':s.pad(2))
   if (any{genres.toString().match(/(?i)Talk ?Shows?/)}{0}!=0)
      { season=airdate.toString().match(/^\d{4}/); show=name; ep=airdate; tv="TALKSHOWS" }
   def folder=any{readLines('P:/collections.txt').find{ it =~ /^${info.id}\s/ }.after(/^\d+\s+/).before(/[:#\t*]/)}{show}
   path="${root}/_${any{path.match(/^(0[123]|35|4[45]|ED)$/)}{numb}}/${wolf}/${tv}/${folder}/Season ${season}"
   def filename="${show} - ${ep}"
   def trim=fn.after(n.match(/(?:\s?\(\d{4}\)\s?)?$/)).after(/(s\d{1,3}e\d{1,3}(-?(s\d{1,3})?e?\d{1,3})|\d{4}[-.]\d{2}[-.]\d{2})([ .-]+)?/).removeAll(/\.\[?[\da-f]{8}\]?\.?/)
   def post=" - "+trim
   def tail=allOf{".[${crc32}]"}{fn.find(/(?<=[. -])(cd|part)\d/).upper()}{subt}.toString().match(/(?<=^\[).*(?=\]$)/).replaceAll(/, /,'.')
   filename=(filename+post+tail).colon(' - ').validateFileName()
   
   return "${path}/${filename}"
}
Any chance of the "Example" box becoming collapsible so that I can get more visible working room (and a button to auto maximize so I don't have to resize each time)? :D
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Request: Pre-editor editor

Post by rednoah »

Would it make that much of a difference? If you write lots of code, you probably wanna edit in Sublime (or any other editor that has Groovy highlighting) and copy & paste once in a while for testing.
:idea: Please read the FAQ and How to Request Help.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Request: Pre-editor editor

Post by Wolfie »

I like to see the results real-time whenever possible. If making it possible to hide the example box isn't easy, then it's not worth it.

Trying to do something but can't seem to figure out how to get the desired results. Trying to make an array using labels, then join, but without the labels showing. Any ideas?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Request: Pre-editor editor

Post by rednoah »

Wolfie wrote: 20 Nov 2018, 16:16 I like to see the results real-time whenever possible. If making it possible to hide the example box isn't easy, then it's not worth it.
Yeah, unfortunately those components aren't collapsible.

Wolfie wrote: 20 Nov 2018, 16:16 Trying to do something but can't seem to figure out how to get the desired results. Trying to make an array using labels, then join, but without the labels showing. Any ideas?
Do you mean a Map?

Code: Select all

{
	['key1': 'value1', 'key2': 'value2'].values().join(', ')
}
:idea: Please read the FAQ and How to Request Help.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Request: Pre-editor editor

Post by Wolfie »

.values() is what I needed, thanks!

Gonna toy with the idea of using an array (or map) for the main structure, then update in the following lines (as needed). Might not be much of a benefit, but could be fun.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Request: Pre-editor editor

Post by Wolfie »

Okay, a tweak to the request. Option to have an editor window that doesn't contain the examples window, sort of like an 'expert mode' toggle. Possible?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Request: Pre-editor editor

Post by rednoah »

Wolfie wrote: 22 Nov 2018, 18:52 Okay, a tweak to the request. Option to have an editor window that doesn't contain the examples window, sort of like an 'expert mode' toggle. Possible?
Well, it does somewhat make sense, and with a Java System Property it'd be quite trivial to add an advanced option for that. But is it really too small? How big is your screen? The large format you posted the other day fits into my 24" screen with plenty of room the spare.


EDIT:

I've added a keyboard shortcut F1 to toggle the help panel on and off. Maybe a bit of a hidden feature that only you know about though. :lol:

Image
:idea: Please read the FAQ and How to Request Help.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Request: Pre-editor editor

Post by Wolfie »

I RDP into a VM running WS2012R2 Datacenter (legit copy that I got free) and so I don't get the full height due to double task bars.

Since you brought it up (thank you!), what do you think of that expression? :D

(Btw, thank you. I'm sure others will discover the F1 feature and start making use of it too.)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Request: Pre-editor editor

Post by rednoah »

Wolfie wrote: 23 Nov 2018, 13:17 Since you brought it up (thank you!), what do you think of that expression? :D
Looking at it from far away, looks like a painting. I like the new syntax highlighting. :lol: I'd probably be 10x more lines if I formatted it to my liking though. :lol:
:idea: Please read the FAQ and How to Request Help.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Request: Pre-editor editor

Post by Wolfie »

Don't suppose I could get any hints on how to try it out, could I? I downloaded the changes.tar.xz file and 'replaced' the file (renamed it before extracting the file inside) and it says 4.8.4, but F1 isn't working. Or was it not done before the nightly build was done?

I'm guessing the F1 toggle is only in effect while the window is open, and resets when the dialog box is opened again? If so, even though it will be annoying, I think it's a good idea, in case someone toggles it by accident (then they can close and reopen to 'fix' it).
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Request: Pre-editor editor

Post by rednoah »

Sorry, I haven't uploaded a new build for that one, and I won't upload builds in the foreseeable future since everything is broken right now. You'll have to wait for the next major release.
:idea: Please read the FAQ and How to Request Help.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Request: Pre-editor editor

Post by Wolfie »

:O
How dare you make me wait! lol

Okay that's cool, at least I know it's not a bug or anything like that. :)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Request: Pre-editor editor

Post by rednoah »

Next release is in BETA and release packages are available now:
https://get.filebot.net/filebot/FileBot_4.8.5/
:idea: Please read the FAQ and How to Request Help.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Request: Pre-editor editor

Post by Wolfie »

There's a bug in the editor where you can't move up or down if there is a blank line. You have to use the left/right keys to get past it (end of line, right arrow when trying to move down, or start of line, left arrow, to move up).

Edit: Oh and, loving the F1 feature.
:D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Request: Pre-editor editor

Post by rednoah »

Fck... what strange a bug / behavior... this is gonna take forever...
:idea: Please read the FAQ and How to Request Help.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Request: Pre-editor editor

Post by Wolfie »

If it helps any, it's almost like it sees the blank line as being the top (or bottom) of the entire expression, thus discarding the up/down arrow input.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Request: Pre-editor editor

Post by rednoah »

Oddly enough, L and R work. It's probably something strange internally in the syntax parser / document model / syntax editor.
:idea: Please read the FAQ and How to Request Help.
User avatar
Wolfie
Posts: 114
Joined: 27 Oct 2015, 02:59

Re: Request: Pre-editor editor

Post by Wolfie »

Yeah I know. Only the up and down arrows are getting discarded/ignored when encountering a blank line.

Still love the F1 feature though.

I'm wondering, is there a way of changing the 'examples' show? Reason I ask is because it would be helpful to be able to put in my own 'examples' to view (when it's toggled on). Like seeing what certain values should be producing, in case I need to view the values without having to go to bindings or add them in to test.

Oh and have fun figuring this bug out, I'm sure you'll be be foaming at the mouth later on like, "WHY IS IT DOING THIS?!?" I know that feeling all too well when trying to figure out why something isn't working right.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Request: Pre-editor editor

Post by rednoah »

Wolfie wrote: 27 Nov 2018, 20:12 There's a bug in the editor where you can't move up or down if there is a blank line. You have to use the left/right keys to get past it (end of line, right arrow when trying to move down, or start of line, left arrow, to move up).
Possibly fixed with r5956.
:idea: Please read the FAQ and How to Request Help.
Post Reply