Developing a Regex for Anime TV Series - Printable Version
+- Kodi Community Forum (http://forum.kodi.tv)
+-- Forum: Development (/forumdisplay.php?fid=32)
+--- Forum: Scrapers (/forumdisplay.php?fid=60)
+--- Thread: Developing a Regex for Anime TV Series (/showthread.php?tid=45369)
Developing a Regex for Anime TV Series - Maxim - 2009-02-11 22:43
I thought this might be the best place to post this question.
I'm looking to develop a regex or few for the Anime TV Series I have. I plan on doing one for movies and OVAs too, but that's later.
Here is what I have now.
I have excluded the "Season" part and just focusing on the file name for right now. This line will get, as far as I understand, almost all of the files I have. I am running into a few files that are giving me trouble. Also i'm not sure if i'm making the line properly since it's also matching the character to the left, and to the right of the string I actually want to match. Here is a list of files that are giving me issues:
In order to test the line I've been using this site here: http://regexpal.com/
The issues i'm having are regarding double episodes, where it doesn't pickup the second episode. The group names that are abbreviated similar to the characters around the episode numbers. Codec names appearing similar to the episodes. And the "Ep" that appears in front of wolf's rain.
I'm very new to regular expression so please forgive my ignorance.
- Maxim - 2009-02-12 20:44
Ok. This string here:
- Maxim - 2009-02-12 21:35
Oh man. Totally got it. So exciting.
Here is the string in all it's glory:
This regexp is able to find the episode numbers in 930 files from various release groups and several varying filename formats. I must say that Regex is simply awesome.
- althekiller - 2009-02-12 22:28
That last expression group seems to be ignored? You probably want (?:expr) in that case.
- Maxim - 2009-02-12 22:47
Well, I haven't tested it in XBMC yet. I was using this webpage to act as my test bed:
It was able to isolate group 1 which would be the first episode or only episode, and it was able to isolate the group 2 which would be picked up as the second episode in the sequence ##-##.
I'll have to do some testing when I get a chance to see if it actually works in XBMC.
I also used this page here:
Which is by far the best regular expression page i've seen.
I'm not familiar with that (?:) sequence, i'll take a look at that also. From what I understand putting the ? makes the preceding token optional.
- althekiller - 2009-02-12 22:53
(?:expr) groups expressions but doesn't create an output based on the field. Have a look at the wiki for how we currently handle multiple eps.
- Maxim - 2009-02-13 00:02
Hmm, after looking at the wiki I seem to have come up confused.
On this page:
It has a note regarding multi part episode files:
NOTE: for multi-episode matching to work, there needs to be a third set of parentheses on the end. This part is fed back into the regexp engine.
I wasn't really sure what that meant, but I added a second grouping on, so that with the Season grouping which has been excluded it would make three sets of parentheses, with the second episode in the filename being the third grouping.
However, this theory is limited to just two episode files, three episode files it wouldn't work, or probably not return the same results.
Then there is this page here:
Which describes multi-part episodes and says that the regex will get applied multiple times, but is not clear on whether then "entire" expression gets applied to the same string (filename) or whether just the episode portion does. If the latter is true then how does it differentiate between the season portion, and the episode portion.
The regex given in that section is this:
All in all i'm pretty confused over the matter, but really won't be able to do anything until I get home and poke around in advancedsettings and the debug log.
- Maxim - 2009-02-13 01:26
It seems that it's not picking up the regex at all.
I have a DEBUG log here:
I can see in the log that it loads advancedsettings.xml properly, however when it gathers the files it doesn't say that it's checking against the regex like i've seen in other log files in other regex threads. An example of what appears to be missing from my log file:
DEBUG: running expression \[[Ss]([0-9]+)\]_\[[Ee]([0-9]+)\]?([^\\/]*)$ on label m:\tv\30 rock\season 01\1 - pilot.avi
Here is the contents of my advancedsettings.xml
- Maxim - 2009-02-15 17:32
It seems my regex was yet again malformed. The latest incarnation which works with XBMC is: