• 1
  • 4
  • 5
  • 6(current)
  • 7
  • 8
  • 17
Regular Expressions
#76
Been working on this for hours now and can't seem to get it..

My directories are setup like this:

TV/Show/S03E02 - episodetitle.avi

and i'm trying to use :

<regexp>S[0]*([0-9]+)E[0]*([0-9]+)[^\\/]*</regexp>

and the scans find nothing, any ideas?
Reply
#77
I found a website the helps explains how to use regular expressions.
http://www.regular-expressions.info/tutorial.html

I'm still having problems though.
My files are organized as follows:

Tv Shows\Name\season #\(###) Title.avi

I'm trying..
<regexp>Season ([0-9])[\\(.]([0-9]+)[^\\/]*</regexp>
I think...
Season - makes match. Is this needed?
([0-9]) - Parens () says to use match inside, brackets [] define char set 0-9
[\\(.] - Brackets [] say to match data inside \\(. says match \( and one char.
([0-9]+) - () again says to use data inside, [0-9]+ says match any number of digits.
[^\\/]* - I don't know what it does. everyone else seams to like it though.

So.... that is what I'm trying to match and you see what I'm trying. It's not working. Sad

one other question. If I define some regular expressions in the advancedsettings, does it wipe out the defaults?


Thanks.
Reply
#78
I don't think XBMC can pull the season from the directory, so you'll have to get the season number into the filename itself. If your (###) is the season and episode combined, you should consider separating them with an x or period. Recommended naming conventions:

Series - S01E01 - Episode Name.avi
Series - 01x01 - Episode Name.avi

You can leave off "Series", since the scraper pulls that from the folder, but I prefer having it on there in case I'm moving files around. Episode name is also optional, but it helps in case you're viewing stuff in file mode and looking for a specific episode.
Reply
#79
I beive it does use the folder name to dientify the show. I've read it somewhere, could someone verify?

Also the (###) is the season ep number combined. ie :

Season 4 episode 13 would be (413).

I thought about using ([0-9])([0-9][0-9])
That would use the first # and then ##.

But how does the computer know which number is the season number and which is the ep number?

I feel like I'm defining variables. Is that what I'm doing?
Reply
#80
Should be able to handle anywhere within the path of the file.

I suspect you need to escape the (. Try:

<regexp>Season ([0-9])\\\(([0-9]+)[^\\/]*</regexp>

Note that the first \\ is just matching \, then \( matches (. As these are characters used to construct regexps, we need to escape them with a \.

Sites such as http://www.quanetic.com/regex.php are useful for testing (note it'll escape stuff for you).

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
Reply
#81
I'm a bit confused.

If the idea is to match a patteren, I think I can do that.
Is the idea to match the relevant data? Or the data that is not needed?

I could match the entire string... something like this ([0-z]+)

I'm assuming the idea is to capture the name of the tv show, season number and ep number, to send to the internet database.

How does this thing work?
Reply
#82
as is THOROUGHLY explained in the manual, tons of times here (see my first post for instance), all you have to match is the season number and the ep number.
Reply
#83
spiff Wrote:as is THOROUGHLY explained in the manual, tons of times here (see my first post for instance), all you have to match is the season number and the ep number.

What I am confused about is the idea of matching. If I include a char set [Season] the system will 'match' the first occurrence of the word 'Season'.
But what is the point of that? Is the data 'Season' returned to the internet?

I don't mean to sound obtuse, but I am genuinely confused.

I’ll do more reading.
Thanks for the help. Smile
Reply
#84
earthtorob Wrote:What I am confused about is the idea of matching. If I include a char set [Season] the system will 'match' the first occurrence of the word 'Season'.
But what is the point of that?
The point is that you can then match anything before or after whatever string you're putting in there. You also don't need [Season]... you just need Season. By enclosing something in brackets, you're allowing the regex to match anything in there. So your [Season] would match S, e, a, s, o, or n.

When we mention "matching", it means that text in the filename matches that part of the regex. What you want to focus on is "capturing", which is done by enclosing it with parentheses. This is how you capture your season and episode numbers... by enclosing the \d+ or [0-9][0-9] in parens.

If you can't figure it out from looking at the examples or the numerous regex tutorials on Google, you'll probably find it far easier just renaming all of your files to match a common naming structure.
Reply
#85
main thing to remember is what regular expressions lets you do.

they allow you to specify a textual pattern. the point of specifying the Season in the expression is to give them numbers context. without it, you would match any occourence of numbers - certainly not what you are after. when i'm in doubt i usually spell the regular expressions out loud. example:

Season([0-9]+) - Episode([0-9]+)

"my pattern consists of the word 'Season' followed by 1 or more numbers which i'm interested in, then ' - Episode' followed by 1 or more numbers which i'm also interested in"

see, easy as pie Tongue
Reply
#86
As I understand it……

The idea is to send the season number and episode number to the internet.
The data you want to send should be encapsulated in parentheses ( ).
To find the numbers in the string you’ll want to tell the computer to look through the string and ‘match’ any char between 0-9. Like so [0-9].
Brackets [] define a character set to match to. Parens ( ) tell the computer to return the matching data.

So ... ([0-9]) tells the computer to look through the entire string and return the very first number it finds.

Is this right so far?
Reply
#87
correct.
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
Reply
#88
spiff Wrote:main thing to remember is what regular expressions lets you do.

they allow you to specify a textual pattern. the point of specifying the Season in the expression is to give them numbers context. without it, you would match any occourence of numbers - certainly not what you are after. when i'm in doubt i usually spell the regular expressions out loud. example:

Season([0-9]+) - Episode([0-9]+)

"my pattern consists of the word 'Season' followed by 1 or more numbers which i'm interested in, then ' - Episode' followed by 1 or more numbers which i'm also interested in"

see, easy as pie Tongue

So I would not need to match every char after the word season?

If ...
Lost\Season 2\(204) name of show

I could ...

Season([0-9])[0-9]([0-9]+)
or
Season [0-9]([0-9])([0-9]+)

Just useing the word Season to find my place in the string?

Why do I need to find my place? Couldn't I just match the first number and return that? The skip the next and return the next two?
Reply
#89
what if your showname has numbers in it? your episode name has numbers in it? the path has a number somewhere (many urls have ports in them for instance)? and so on. as i said you need to give it context so you match only the correct numbers.

btw, none of those regexps would match your example at all.

Season ([0-9]+)[\\/]\(([0-9]+)\)

my final words on this for sure - if you dont get it read a regexp tutorial.
Reply
#90
You have to find your place incase you are interested in the tv show num3ers. It'd possibly match the 3 otherwise.

Neither of those regexps will work - you want to match "Season " to find your place, then 1 or more numbers, then "\(" then one or more numbers.

So:

Season ([0-9]+)\\\(([0-9]+)

will do the trick. Note that I've replaced the "\(" match with each of those characters escaped with a \ as they otherwise have special meaning in regexps.

Honestly - this isn't a place to get tutorial advice about regexps - we're happy to provide a few pointers, but there's plenty of other sites out there with full tutorials on how regexps work.
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
Reply
  • 1
  • 4
  • 5
  • 6(current)
  • 7
  • 8
  • 17

Logout Mark Read Team Forum Stats Members Help
Regular Expressions1