Better matching based on already exists folders

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
birno
Posts: 8
Joined: 27 Oct 2014, 18:05

Better matching based on already exists folders

Post by birno »

Hi,

First of all, thanks for the amazing software and scripts!
I'm using AMC, with the -non-strict switch and sometimes it can't match the correct series name, which is understandable.
Just wondering, is there a switch or other script which tries to figure out the correct title, based on the already exists folders in the destination path?

E.g. the new series "Kingdom" has the title "Kingdom (2014)" in TheTVDB database, FileBot find these titles: "Kingdom (2014)", "Kingdom", "Kingdom (2012)", "Seed" etc and it finally it picks "Seed".
First time I rename the folder manually to "Kingdom (2014)".
Next time FileBot find ambiguous titles again, but now checks the target folder for already existing folders which may match, if it find one match than using that one, if not, pick up one from the existing ones, based on some algorithm.

Is this functionality exist in some form and I just can't find it or not implemented?

Thanks,
Norbert
User avatar
rednoah
The Source
Posts: 23006
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Better matching based on already exists folders

Post by rednoah »

1.
The destination folder is defined by the File/Episode match. So you can't know the destination folder before you come up with the match.

2.
FileBot may take the full path into account when matching a file, so if the folder contains more information it will help getting the right match. The output format has no effect on matching.

3.
--filter is extremely powerful but it might take some time to get a feeling for how it works. Your filter expression could check for existing folders and only allow episodes where the series title matches one of these folders.

You could also exclude certain shows that you know cause mismatches. You could also exclude bad matches based on other criteria, for example airdate.
Advanced Fine-Tuning
You can use your own --filter rules to fine-tune matching to your needs and avoid mismatches. For example, if one show is confused with another due to bad naming or missing data you can simply exclude the bad one, or if you only process recently aired episodes you could exclude any episode of any show that has been aired for more than a few days.

If you know that you will only process recently aired episodes you could add these options:

Code: Select all

--filter "age < 7" --def "ut_label=TV"
:idea: Please read the FAQ and How to Request Help.
birno
Posts: 8
Joined: 27 Oct 2014, 18:05

Re: Better matching based on already exists folders

Post by birno »

1. But if an output folder defined or the Episode format contains a path, without any substitution mark, for example in the beginning of the format("h:/series/{n}/Season {s.pad(2)}/{sxe}"), then it's a good start.

3.
Your filter expression could check for existing folders
.
It's sounds good, I assume I need to write some groovy code in the filter, right?
Using the "folder" expression for example saying something like "path list contains title".
Does the filter allow groovy code?
birno
Posts: 8
Joined: 27 Oct 2014, 18:05

Re: Better matching based on already exists folders

Post by birno »

I played a little bit with this --filter option.
If I understand correctly, FileBot use this filter on every possible titles and using the first matched one, right?
So

Code: Select all

--filter "new File('h:/series', n).exists()"
allow only titles which already exists in the folder, but what if it's not exists?
In this case I just want to pick one and if necessary, I will fix it and next time FileBot can match based on that.
How can I do that?
And is it possible to reference to the --output folder in the filter, as a variable, like this:

Code: Select all

--output h:/series --filter "new File(output, n).exists()"
Just some suggestions, if you don't mind.
I think the documentation is not clear enough on what the filter accept as a parameter, somebody with less programming knowledge will don't know what "expression" mean, maybe that's why almost nobody using it.
For me at least, annoying too, that I don't know anything about the context, how FileBot will using thr filter, try matching one by one or against a list etc.
Maybe a little bit more complex example would be better, to help people understand this feature, like this(ok, not so complex :)): http://www.filebot.net/forums/viewtopic ... ter+#p9744

A last question for this post.
In the scripts, some function declared in java(e.g.: tryQuietly), but I can't find a list describing which functions/variables etc. available from FileBot code(I mean not part of the Groovy JDK).
Is there a list somewhere?
Or at least links to the source files which contains these, like in the cli page.
User avatar
rednoah
The Source
Posts: 23006
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Better matching based on already exists folders

Post by rednoah »

1.
--filter and --format are pretty much the same. Both work on episode or movie objects. --filter is a single expression that returns true or false. While --format has multiple expressions that all return String objects.

Not sure if you read this one already:
viewtopic.php?f=3&t=2127&p=12223#p12223

Hopefully the screenshot makes it more clear how it works. At the very least you can play with -list and --filter and see what gets included. I only added that page, I'll add examples for use-cases that come along as time goes by. :D

2.
I've added {output} yesterday already. It'll be in the next release.

3.
Format/Filter Bindings:
https://sourceforge.net/p/filebot/code/ ... gBean.java

Format/Filter Expression Extensions:
https://sourceforge.net/p/filebot/code/ ... tions.java
https://sourceforge.net/p/filebot/code/ ... thods.java

FileBot Script Extensions:
https://sourceforge.net/p/filebot/code/ ... Class.java
https://sourceforge.net/p/filebot/code/ ... thods.java



EDIT:

4.
What you want is sort of, run my filter, and if nothing is left, act as if there was no filter. That's just not what it's meant to do.

I'm sure you can get something close though. Just need to find a way to "normalize" all the various "overlapping" series names so you can compare them.

Code: Select all

{output.list().contains(n) ?: !output.list().any{ it =~ n.replaceTrailingBrackets() }}
i.e. if you already have Doctor Who (2005) then ignore Doctor Who, but also the other way around. So the common denominator would be Doctor Who.
:idea: Please read the FAQ and How to Request Help.
birno
Posts: 8
Joined: 27 Oct 2014, 18:05

Re: Better matching based on already exists folders

Post by birno »

1. Yes, I read that topic, that's why I said, some advanced example would make it more clear how it works. I will add this little folder exists snippet too, when finalized.
2. Awesome, thanks! :D
3. Thanks again, useful, I will check them, maybe checkout the source and trying to take a look at the episode matching part.
4. It still doesn't solve the problem, because need to create the folder first manually, even when there's no ambiguity.
But no problem, I writing a program anyway to make torrent handling easier for me, so I will handle this in it, if FileBot can't match, then rerun without filter.
Hackish a little, but more reliable than trying to normalize the overlappings. :)
As I saw I couldn't do it even if I changing the amc script, because it handled internally in a Java call.
birno
Posts: 8
Joined: 27 Oct 2014, 18:05

Re: Better matching based on already exists folders

Post by birno »

Is there a way to know if filebot failed to succesfully run the given command without parsing the output?
I checked the ERRORLEVEL in command line on windows but that always return 0.
User avatar
rednoah
The Source
Posts: 23006
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Better matching based on already exists folders

Post by rednoah »

FileBot does exit with a negative exit code. But due to a known issue with launch4j, it'll always return 0 if the exe launcher is used.
:idea: Please read the FAQ and How to Request Help.
Post Reply