Kodi Community Forum
Regular Expressions - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: OS independent / Other (https://forum.kodi.tv/forumdisplay.php?fid=228)
+---- Thread: Regular Expressions (/showthread.php?tid=25349)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17


- Dadde - 2012-01-27

Ok new regexp but same resultSad

Dir structure:

D:\Telefilm\The Dead Zone\Stagione 6\The Dead Zone - 6x01 - Un Gesto Eroico.avi

regexp:

Code:
<tvshowmatching action="append">
<regexp>(?i)[/\\](?:s|Stagione)\W?(\d{1,2})\D*[/\\].*?\1\W?x\W?(\d{1,2})([^/\\]*)</regexp>
</tvshowmatching>

Xbox.log say:

Code:
22:14:51 T:96796672   DEBUG: OnProcessSeriesFolder - no match for show: 'The Dead Zone', season: -1, episode: -1, airdate: '31/12/1969', title: 'the dead zone - 6x01 - un gesto eroico.avi'

22:14:51 T:96796672   DEBUG: VideoInfoScanner: No NFO file found. Using title search for 'upnp://f9b00e1b-a55b-3c2f-b101-b7731030fd1d/V%5fF%5eFOL%5fR2%24F165%24F173%24MI1606'

Please masters of regexp help me Sad


- scudlee - 2012-01-27

Your problem isn't regexp related, your problem is in using upnp.
upnp isn't supported in library mode.


- Dadde - 2012-01-28

Tnx very much scudlee, now i understand because never work, but will be supported upnp in future ?


- Dadde - 2012-01-28

Changed upnp setting to smb condivision and everything works great.

TNX scudlee


- CaptainDju - 2012-02-02

Hi all,

I have read a bit about regexp, and managed to setup my XBMC pretty well to recognize my file naming convention for single episodes.

Now what I'd like to tackle is double episodes, I've tested my regexp first and they seem to work, can I ask you to confirm as I won't have access to my media center for a while?

File naming convention:
X:\Series\Serie Title\Serie Title Season #\Serie Title [#x##] Episode Name.avi

Where the season and episodes are found between the square brackets, separated by the x

For single episodes here's the expression I'm using:

[\\/].*\[([0-9]*)x([0-9]*)\][^\\/]*

Now for two-parters the naming convention is like this:

X:\Series\Serie Title\Serie Title Season #\Serie Title [#x##-##] Episode Name.avi

So I went with this regexp:

[\\/].*\[([0-9]*)x([0-9]*)-([0-9]*)\][^\\/]*

To summarize, my advancedsettings.xml file would look like this

Code:
<advancedsettings>
          <tvshowmatching>
                    <regexp>[\\/].*\[([0-9]*)x([0-9]*)\][^\\/]*</regexp>
                    <twopart>
                              <regexp>[\\/].*\[([0-9]*)x([0-9]*)-([0-9]*)\][^\\/]*</regexp>
                    </twopart>
          </tvshowmatching>
</advancedsettings>

Does that look like it's gonna work?

Thank you in advance!

EDIT: One more question I forgot to ask: I have seen this in the beginning of regexp used on this forum, but I'm not sure what it means?

Code:
[/\._ \-]



RE: Regular Expressions - catastrofuk - 2012-07-07

Thought I would ask here before I go any further with this;

I am in the process of cataloging World Cup games.

I would like to have series folders names as "Group A", "Group B" etc, Semi-Finals, Finals etc instead of the the standard "season 1". An example of an individual file name would be say Group Cx02 Argentina vs Brazil.avi

Is this possible with regexp and xbmc? If so where do I begin Big Grin?


Regular Expressions with replacement? - At2010 - 2012-09-18

Hello.

I'm trying to improve upon the IMDB movie scraper. It seems that IMDB sometimes puts the MPAA rating at the top, sometimes in the middle, sometimes both places, and sometimes neither place.
The current scraper only collects info from the middle of the html.
So I modded metadata.common.imdb.com/imdb.xml

Code:
<ParseIMDBUSACert dest="5">
    <RegExp input="$$2" output="&lt;details&gt;\1&lt;/details&gt;" dest="5">
        <RegExp input="$$1" output="&lt;mpaa&gt;$INFO[certprefix]\1&lt;/mpaa&gt;" dest="2">
            <expression>class=&quot;absmiddle&quot; title=&quot;([^&quot;]*)&quot;</expression>
        </RegExp>
        <RegExp input="$$1" output="&lt;mpaa&gt;$INFO[certprefix]\1&lt;/mpaa&gt;" dest="2">
            <expression>MPAA&lt;/a&gt;\)&lt;/h4&gt;\n?&lt;span itemprop=&quot;contentRating&quot;&gt;Rated\s([^&lt;]*)</expression>
        </RegExp>
        <expression noclean="1" />
    </RegExp>
</ParseIMDBUSACert>

This works Ok. Except for ratings like PG-13 where the top html always uses an underscore instead of a dash "PG_13". To keep things consistent, I would like to change the underscore to a dash.

Example movie: Bird on a WIre (1990) http://www.imdb.com/title/tt0099141/

A regex search & replace would be easy enough "s/_/-/"
Is it possible to do this in XBMC?

If not, then I can break the input using the regex below (changed for readability), but I am not sure how to reassemble without a conditional.

Code:
class="absmiddle" title="([^_"]*)(_*)([^"]*)"

PG_13 matches as (PG)(_)(13) . So I could use \1-\3 with output PG-13, but
PG matches as (PG)()() and would end up as PG-

How can the <regexp> <expression>... be written to change underscore to dash in PG_13, NC_17, etc, but leave others alone G,PG,R, et al.

Any help would be appreciated.
At2010


RE: Regular Expressions - scudlee - 2012-09-18

@At2010
The anidb.net scraper does a type of search & replace to fix the apostrophes that are used by anidb. This is the code:
Code:
<RegExp input="$$16" output="\1" dest="8+">
  <RegExp input="$$16" output="'\1" dest="16">
    <expression clear="yes" repeat="yes" noclean="1">`?([^`]+)</expression>
  </RegExp>
  <expression noclean="1">'(.*)</expression>
</RegExp>
Basically, it breaks the input up into apostrophe-separated blocks, and then outputs those blocks with the corrected apostrophe preceding them (with repeat="yes" so all matches are done). Then a little clean-up is needed to remove the stray apostrophe created at the start.

Perhaps you can adapt that to your needs?


RE: Regular Expressions - At2010 - 2012-09-19

@scudlee
Thanks again!
I've almost got it. The code gives the corrected dashed or non-dashed rating correctly.

One final problem: It always returns "Rated " (The value of $INFO[certprefix]) even if there is no rating available. There should be nothing returned when the inner expressions are blank/null. I tried using clear="yes" on the inner expressions, but no change. Any suggestions?
At2010

Code:
<ParseIMDBUSACert dest="5">
    <RegExp input="$$2" output="&lt;details&gt;&lt;mpaa&gt;$INFO[certprefix]\1&lt;/mpaa&gt;&lt;/details&gt;" dest="5">
        <RegExp input="$$1" output="\1" dest="16">
            <expression noclean="1">class=&quot;absmiddle&quot; title=&quot;([^&quot;]*)&quot;</expression>
        </RegExp>
        <RegExp input="$$16" output="\1" dest="2">
            <RegExp input="$$16" output="-\1" dest="16">
                <expression clear="yes" repeat="yes" noclean="1">_?([^_]+)</expression>
            </RegExp>
            <expression noclean="1">-(.*)</expression>
        </RegExp>
        <RegExp input="$$1" output="\1" dest="2">
            <expression>MPAA&lt;/a&gt;\)&lt;/h4&gt;\n?&lt;span itemprop=&quot;contentRating&quot;&gt;Rated\s([^&lt;]*)</expression>
        </RegExp>
        <expression noclean="1" clear="yes" />
    </RegExp>
</ParseIMDBUSACert>



RE: Regular Expressions - scudlee - 2012-09-19

Maybe move the $INFO[certprefix] into the output of the last RegExp, and then have a clear="yes" on an expression that matches $INFO[certprefix].+
Something like:
Code:
<ParseIMDBUSACert dest="5">
    <RegExp input="$$2" output="&lt;details&gt;&lt;mpaa&gt;\1&lt;/mpaa&gt;&lt;/details&gt;" dest="5">
        <RegExp input="$$1" output="\1" dest="16">
            <expression noclean="1">class=&quot;absmiddle&quot; title=&quot;([^&quot;]*)&quot;</expression>
        </RegExp>
        <RegExp input="$$16" output="\1" dest="2">
            <RegExp input="$$16" output="-\1" dest="16">
                <expression clear="yes" repeat="yes" noclean="1">_?([^_]+)</expression>
            </RegExp>
            <expression noclean="1">-(.*)</expression>
        </RegExp>
        <RegExp input="$$1" output="$INFO[certprefix]\1" dest="2">
            <expression>MPAA&lt;/a&gt;\)&lt;/h4&gt;\n?&lt;span itemprop=&quot;contentRating&quot;&gt;Rated\s([^&lt;]*)</expression>
        </RegExp>
        <expression noclean="1" clear="yes">($INFO[certprefix].+)</expression>
    </RegExp>
</ParseIMDBUSACert>
(Not in any way tested or checked.)


RE: Regular Expressions - At2010 - 2012-09-21

@scudlee

Thanks for all the help. This is what I have that works.
At2010

Code:
<ParseIMDBUSACert dest="5">
    <RegExp input="$$2" output="&lt;details&gt;&lt;mpaa&gt;\1&lt;/mpaa&gt;&lt;/details&gt;" dest="5">
        <RegExp input="$$1" output="\1" dest="16">
            <expression>class=&quot;absmiddle&quot; title=&quot;([^&quot;]*)&quot;</expression>
        </RegExp>
        <RegExp input="$$16" output="\2" dest="16">
            <expression noclean="1">(NOT_RATED)?(.*)</expression>
        </RegExp>
        <RegExp input="$$16" output="$INFO[certprefix]\1" dest="2">
            <RegExp input="$$16" output="-\1" dest="16">
                <expression clear="yes" repeat="yes" noclean="1">_?([^_]+)</expression>
            </RegExp>
            <expression noclean="1">-(.*)</expression>
        </RegExp>
        <RegExp input="$$1" output="$INFO[certprefix]\1" dest="2">
            <expression>MPAA&lt;/a&gt;\)&lt;/h4&gt;\n?&lt;span itemprop=&quot;contentRating&quot;&gt;Rated\s([^&lt;]*)</expression>
        </RegExp>
        <expression noclean="1" />
    </RegExp>
</ParseIMDBUSACert>



RE: Regular Expressions - xbmcuser123 - 2012-11-01

I hope someone cal help me.
I have several hard drives, each containing a folder for TV Series, TV1, TV2, ..., TVn.
I created a main TV directory with serveral subfolders, each one pointing to a TVx folder, using junction link.
Is that possible to add, as a source, only TV folder, instead of each TVx subfolder, and tell XBMC to start scanning at the subfolder level of TV directory ?
The purpose is that when a new TVx sufolder is created, it will be automatically scanned.
Thanks for your help.


RE: Regular Expressions - wsnipex - 2012-11-01

yes, select recursive scan on the TV source


RE: Regular Expressions - xbmcuser123 - 2012-11-01

Thanks.
But I can see recursive scan ONLY on Movies, NOT on TV Shows.
I am using Eden.
Is there a trick to activate it ?


RE: Regular Expressions - wsnipex - 2012-11-01

right, I guess recursive is default unless you enable "selected folder contains a single TV Show", so keep that disabled.