Page 1 of 1

How does filename parsing work?

Posted: 23 Mar 2015, 16:41
by tehjrow
I'm writing a small program to check filenames and see if I have all the latest episodes. I'm wondering how you go about parsing the filenames. It seems like there could be so many Season number Episode number combinations to look out for EX:(S03E04, S3E4, Season 03 Episode 04, 3x04, 03x04, etc.). Do you just search the filename for all possible combinations or is there a better way to do it?

Re: How does filename parsing work?

Posted: 23 Mar 2015, 17:23
by rednoah
Long answer: It's VERY complicated and fine-tuned over years. Known SxE patterns are a reliable metric in the decision making logic, but if there's no SxE pattern matches it'll move on to other numeric similarity metrics.

Short answer: You can capture the most common SxE patterns with 2-3 patterns. FileBot uses 7 patterns.

Best answer: @see net.filebot.similarity.SeasonEpisodeMatcher


PS: Are you perhaps building something like this? viewtopic.php?f=8&t=1681

Re: How does filename parsing work?

Posted: 23 Mar 2015, 17:49
by tehjrow
Holy crap, thanks!

Re: How does filename parsing work?

Posted: 27 Mar 2015, 17:17
by tehjrow
After digging into this more, i'm going to forge a sword with Regex written on it and kill myself with it.

Re: How does filename parsing work?

Posted: 27 Mar 2015, 20:31
by rednoah
Or just use Groovy with functions provided by FileBot: https://github.com/filebot/scripts/sear ... sodeNumber

Re: How does filename parsing work?

Posted: 27 Mar 2015, 20:33
by tehjrow
rednoah wrote:Or just use Groovy with functions provided by FileBot: https://github.com/filebot/scripts/sear ... sodeNumber
I'm using C# so i'm not sure how easy that would be to integrate. The Regex expressions require a bit of tweaking to get them to work in C# as it it.

Re: How does filename parsing work?

Posted: 28 Mar 2015, 07:23
by rednoah
The Regex would be identical. But there's multiple expressions and some logic build around on effectively applying them. Whatever you're doing, if it's close to something FileBot does, It's probably easier with Groovy and hook into all the media parsing functions as required.