File Stacking Regular Expressions - Change Default

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Thracx Offline
Junior Member
Posts: 16
Joined: Aug 2008
Reputation: 0
Location: Northern VA
Post: #1
I do apologize in advance if there is a better place to post this, or if there is a similar thread for it which I was unable to locate.

This page (and this) detail how XBMC stacks files using regular expressions, e.g. movie-title-part1.mpg movie-title-part2.mpg becomes a single 'movie-title' in the XBMC interface when stacking is enabled.

Here's an example of the regular expression as it is documented (and I do not know if this documentation is up-to-date for v11):
Quote:<regexp>(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck]|d)[ _.-]*[0-9]+)(.*?)(\.[^.]+)$</regexp>

This expression (and the letter variant) does not handle file names which provide the stacking portion inside parenthesis such as this: Fight Club (1999) [Part 1].avi

Here's an example of an updated RegEx to handle all 3 types of parentheses, although personally I only wish to add ][ bracket matching.
Quote:<regexp>(.*?)([ _.-]*(?:[\(\[\{])?(?:cd|dvd|p(?:ar)?t|dis[ck]|d)[ _.-]*[0-9]+(?:[\)\]\}])?)(.*?)(\.[^.]+)$</regexp>

The change is relatively simple and I do not believe it will allow for any additional false-positives, since the parentheses delimit the 'field' nicely. I have been using this updated expression in my advancedsettings.xml file for a while now and it works well, so I was hoping it could be included in XBMC as the default so I don't have to keep sending people a subset of my xml file.

-Thracx

"Man wants to know, and when he ceases to do so, he is no longer a man."
-Fridtjof Nansen
find quote
jmarshall Offline
Team-XBMC Developer
Posts: 26,181
Joined: Oct 2003
Reputation: 176
Post: #2
The example above stacks fine, just the parantheses stay appended, right? Once scanned, it wouldn't be a problem.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]
find quote
Thracx Offline
Junior Member
Posts: 16
Joined: Aug 2008
Reputation: 0
Location: Northern VA
Post: #3
(2012-03-27 07:15)jmarshall Wrote:  The example above stacks fine, just the parentheses stay appended, right? Once scanned, it wouldn't be a problem.
I can test again to be sure, but I recall the problem being that the resulting scanned name wouldn't scrap correctly without manual intervention (which also happens for other reasons, which I am investigating now that v11 has renewed my interest in customizing or enhancing XBMC). I remember not all of my files stacking correctly too, but thinking about the RegEx now I am not confident why I am remembering this. Perhaps I will try a full rescan late tonight without my customizations and see what happens, perhaps it was a bug in an old version of XBMC.

As a small aside, is there a reason these RegEx don't use named captures or other RegExOptions to make them easier to read? I am not familiar with the XBMC dev stack but I assume all modern RegEx implementations provide these options.

-Thracx

"Man wants to know, and when he ceases to do so, he is no longer a man."
-Fridtjof Nansen
(This post was last modified: 2012-03-27 15:02 by Thracx.)
find quote
jmarshall Offline
Team-XBMC Developer
Posts: 26,181
Joined: Oct 2003
Reputation: 176
Post: #4
Historical mainly. Our first regexp stuff didn't handle named expressions. Pretty sure the current one does, so certainly that would be an option - feel free to take a look.

Also, to be clear, I'm not averse at all to changing the default regexps - the better they are, er, the better. However, I will not accept a change without someone also making at least a token effort to generate test cases so we can be reasonably sure we don't have regressions when we go and change it again. This would be, for example, a list of filenames pairs in a text file (unstacked/stacked) along with a simple routine to run the test.

Cheers,
Jonathan

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]
find quote
evolart Offline
Junior Member
Posts: 6
Joined: Nov 2005
Reputation: 0
Post: #5
I've read the stacking stuff but truthfully do not understand it at all. I created an advancesettings.xml but it does not seem to cover files renamed by a program I use called YAMMM. Here is an example of what I'm trying to get stacked:

Wedding Crashers (2005) [1 of 2].avi
Wedding Crashers (2005) [2 of 2].avi

Anyone have any ideas?
find quote