Author Topic: File Scanner and Regular Expressions  (Read 102402 times)

0 Members and 2 Guests are viewing this topic.

Offline patch

  • Older Power User
  • *****
  • Posts: 250
    • View Profile
Re: TV Series & File Scanner
« Reply #20 on: June 06, 2009, 06:08:54 am »
I have all my TV shows in the file format...
E:\Television\Dark Angel\Season 2\Dark Angel - 2-03. Proof of Purchase

See http://www.videodb.info/forum_en/index.php?topic=1168.0
[Thanks, Patch. We're here. ;) ]

You use a similar format to me, add similar regex before the standard ones
I uses season directories of the form "s1" but you use "season 1"
So you will need to replace my "\\s(?P<season>[0-9]{1,2})\\" with with your "\\season (?P<season>[0-9]{1,2})\\" 
Note leave out the bounding quotes
« Last Edit: June 06, 2009, 06:23:21 am by patch »

Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #21 on: June 06, 2009, 06:16:05 am »
Patch beat me to it, but I'm moving your topic anyway. I was wondering who might be brave enough to keep a regex topic moving. I should have known. ;D

Offline darichman

  • User
  • ***
  • Posts: 59
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #22 on: June 06, 2009, 08:33:49 am »
:-[ Should have looked a bit further!

Thanks guys, this thread has given me a lot of useful info :)
*goes off to try and learn regex*

Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #23 on: June 06, 2009, 09:20:35 am »
Quote
*goes off to try and learn regex*

That's what I wanted to hear! Please explain it to me when you're done. ;)

To be a little more helpful... I think you'll find your own "custom" expression(s) will work perfectly—as long as your file path names are consistent.

Offline nostra

  • Administrator
  • *****
  • Posts: 2852
    • View Profile
    • Personal Video Database
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #24 on: June 06, 2009, 01:24:39 pm »
Easy ;)

Code: [Select]
(?i)^.*\\(?P<origtitle>.*).?-.?(?P<season>[0-9]{1,3})-(?P<episode>[0-9]{1,3})\..?(?P<eptitle>.*)\..{1,4}
Gentlemen, you can’t fight in here! This is the War Room!

Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #25 on: June 06, 2009, 01:54:18 pm »
Oh no! What have you done! Usually when darichman goes off to try and learn something, he comes back the resident expert. You should at least insist he explain your expression before he shamelessly uses it. ;)

Offline nostra

  • Administrator
  • *****
  • Posts: 2852
    • View Profile
    • Personal Video Database
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #26 on: June 06, 2009, 02:02:11 pm »
OK, darichman, you heard Rick. You need to explain my RegEx now :)
Gentlemen, you can’t fight in here! This is the War Room!

Offline darichman

  • User
  • ***
  • Posts: 59
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #27 on: June 28, 2009, 04:43:05 am »
Haha, just saw this! I certainly haven't come back an expert :( I went off and did a bit of reading and then applied my tried and tested "trial and error approach" and got it working. With help from patch's example. Only to come back and see Nostra solved it for me anyway ;) I have all my TV shows in PVD now and am just figuring out the best sources for the info. I prefer thetvdb.com's episode lists and release dates, but naturally IMDb has the most comprehensive metadata and the episode numbers don't always match up. Decisions, decisions.

And only four weeks away from finals :-\

Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #28 on: June 28, 2009, 05:28:21 am »
Mastering regex is an excellent way to prepare your mind for any exam. Also, dropping an incomprehensible expression here and there in your paper is an effective way to psych-out the marker. ;)

Offline Tethien

  • Member
  • *
  • Posts: 3
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #29 on: January 26, 2010, 04:15:08 am »
I have a lot of TV series with only one season and the file name like :

Bad.Love.E01.HDTV.X264.720p-Encoder.mkv
Bad.Love.E02.HDTV.X264.720p-Encoder.mkv
.....

Then VDB can't auto recognition that as one movie.

Please help me.

Offline patch

  • Older Power User
  • *****
  • Posts: 250
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #30 on: January 26, 2010, 06:02:57 am »
I have a lot of TV series with only one season and the file name like :

Bad.Love.E01.HDTV.X264.720p-Encoder.mkv
Bad.Love.E02.HDTV.X264.720p-Encoder.mkv

This will not be recognized by the series scanner / regEx as it has no series number only an episode number.
To fix it you must first decide what you are going to change.
1) Rename your files to a standard format such as (a few other variants are also supported)
   <Series name> s01e01 <ignored text>.<std file extension>
    Note this can be semi automated if you files already have some structure, alternatively pasting the correct prefix can also be fast for a few files.
2) Modify the regex expressions in PVD to match your convention. Doing this involves deciding what is unique/consistent about your naming convention which the pvd regex can look for. Bearing in mind you do not want PVD to start classifying all your multi file movies as series.
For example I file my TV series as
<series directory>/<series name>/s1/<approximate series name><series number><episode number><ignored text>.<file extension>
So if "/s1/" or similar is found one directory up from the media file, I can be sure this is a TV series and I only need to find the episode number in the file name. Note I do not expect you to have the same convention, but you will have to be clear about what your convention is (consistent across all files you will be scanning. Next you will need to read a little about regex, it is confusing at first but is an efficient text search language. I recommend making a text file with examples of all the file path & naming conventions used in your collection. You can then rapidly experiment with a variety of regex expression using a text editor supporting regex such as EditPad pro Demo.
« Last Edit: January 26, 2010, 06:14:42 am by patch »

Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #31 on: January 26, 2010, 06:28:47 am »
Quote
2) Modify the regex expressions in PVD to match your convention.

Note this does not appear to be a solution in this particular case. Tethien also needs to respect the fact a season must be recorded, even it's an arbitrary season 0 or 1. So the easiest solution, and perhaps the only one, is to add an "S00" or "S01" to the filename of such episodes.

Offline patch

  • Older Power User
  • *****
  • Posts: 250
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #32 on: January 26, 2010, 06:58:55 am »
this does not appear to be a solution in this particular case. Tethien also needs to respect the fact a season must be recorded
If this data exist in the file path then it does not have to be repeated in the file name (hence my request for him to clarify what his convention is and my example using file path information).

However I agree, in the long term it is likely to be much easier to name series files with Series name, series number, & episode number all in the file name as expected by the current pvd regex expressions.

I suspect the file renaming tools you use rick (bat file creation or Directory Opus) would help Tethien the most.
« Last Edit: January 26, 2010, 07:03:51 am by patch »

Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #33 on: January 26, 2010, 07:28:43 am »
Quote
If this data exist in the file path...

I'm confident he would have told us if it were. ;)

But point taken. The season can be anywhere in the pathname (if a regex statement that can find it is provided). But it has to be somewhere.

Offline Tethien

  • Member
  • *
  • Posts: 3
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #34 on: January 26, 2010, 11:57:10 am »
Thanks for yous reply.
But:
-My film only have one season. And parent directory name is film title. Not have any season number in path.
-I don't know how ? but if i rename the filename like that :
Bad.Love.HDTV.X264.720p-Encoder.E01.mkv
Bad.Love.HDTV.X264.720p-Encoder.E02.mkv

and then PVD recognized OK. Why ?

I  can rename multi file by using Total Commander but if i rename i shuld re-rename back while reseed requested.

Sorry for my bad Englist.

Offline patch

  • Older Power User
  • *****
  • Posts: 250
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #35 on: January 26, 2010, 12:38:04 pm »
My film only have one season. And parent directory name is film title. Not have any season number in path.

If your series has only one season then it is the first season. So name it
Bad Love E01E01.HDTV.X264.720p-Encoder.mkv
Bad Love E01E02.HDTV.X264.720p-Encoder.mkv

All will then run smoothly

Offline rick.ca

  • Global Moderator
  • *****
  • Posts: 3241
  • "I'm willing to shoot you!"
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #36 on: January 26, 2010, 12:40:38 pm »
Quote
and then PVD recognized OK. Why ?

It's not recognized okay. It's recognizing only Title="Bad Love HDTV X264 720p-Encoder E01" instead of Title="Bad Love," Season="1" and Episode="1." Unless Season and Episode are properly recognized, the file will be added as a separate movie record, instead of a nested series record.

You need to understand the function of the regex statements at Preferences - File Scanner. Perhaps you can find a reference source in your native language—like this Wikipedia entry. Is it available in your language (listed in left column)?

Quote
I  can rename multi file by using Total Commander but if i rename i shuld re-rename back while reseed requested.

Yes, this is probably what you'll need to do—if you want to use the file scanner to add these files. You could leave the file name unchanged, and add it to PVD manually. Just add the new record, then enter the File path.

Offline Tethien

  • Member
  • *
  • Posts: 3
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #37 on: January 27, 2010, 07:49:56 am »

Yes, this is probably what you'll need to do—if you want to use the file scanner to add these files. You could leave the file name unchanged, and add it to PVD manually. Just add the new record, then enter the File path.

This is realy a very boring job.

Thank for you help.

Offline xyster

  • Member
  • *
  • Posts: 17
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #38 on: March 09, 2010, 03:32:04 am »
Yay, my time to jjoin in the regex  fun.

I  havent worked with regex for a couple of years now. So this should be a fun at it. I've read this thread and hope i get it now :D

My files are all named quite consistently... for the most part. I am having trouble getting it to distinguish between moves like this.

Wild.Wild.West.1999.DVDRip.XViD.iNT.CD1-JoLLyRoGeR : Title.Title.Title.YEAR.Quality.notuseful
Taken.WS.R5.XViD-PUKKA                                       : Title.QualityVariant.Quality.notuseful
Bangkok.Dangerous.R5.LINE.XviD-COALiTiON               : Title.Title.Quality.Quality.notuseful
Futurama.Benders.Big.Score.DVDRiP.XviD-OPT             : Title.Title.Title.Title.Title.Quality.notuseful (this is the most common naming format, or the first option).

Thats about all the variation i have in my files.

Is it easiest to just set my regex to read til it hits a predefined Quality type? I know all the values it will eventually hit (R5, R5.Line, DVDSCR, DVDRIP, AC3.DVDRIP, SCREENER, WS.R5, TC, TS, BDRIP)

Also, where does the quality of the file get read in, i dont see it as an option. Or does it happen somewhere else?

So something like...
(?i)^.+\\(?P<title>[^\\]+)[^\\]+(?P<year>(19|2\d)\d{2})   - This predefined one should catch the 1st option and im confident in that.

(?i)^.*\\(?P<title>.*)\\(R5|R5\\.LINE|WS\\.R5|DVDSCR|DVDRIP|etc|etc).\..*   - should be matching the 2nd/3rd/4th type? (i cant seem to tell if you need to add the \\ to escape a "." whilst inside the |...| areas)

Sorry to be a pain, i know how aggivating it is to interpret someones regex stuff. Also thanks for any help guys.
« Last Edit: March 22, 2010, 07:57:43 am by xyster »

buah

  • Guest
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #39 on: March 21, 2010, 07:57:44 pm »
RegSearch is really interesting to me. I had an idea to exchange regexps here, but first I wanted to contributed somehow. Being extremely busy at the moment (sorry nostra and rick), I need help if someone is willing to help me.

This is the format of my folders and videos:

"English Title" - "Original Title" ("Year") ("Category") ["Source"],

without qoutes.
Please, note spaces, 5 at all.

Possible examples of naming my folders (and videos) are:

The Matrix (1999)

Is Anybody There^ (2008) (^ is equivalent for ? - the question mark)

Hachiko-- A Dog's Story (2009) (-- is equivalent for : - the colon)

Savage Messiah (1972) [TVRip]

Men Who Hate Women - Män som hatar kvinnor (2009)

A Single Girl - La fille seule (1995) [HS-DVDRip]

Mom at Sixteen (2005) (TV)

Erotic Diary of an Office Lady - OL kanno nikki-- Ah! Watashi no naka de (1977) (V) [HS-DVDRip]


So, I need an expression that will fill in Title field, Original title field (if any), Year, Category (if there are brackets after Year's closing bracket) and Custom field named "Source" (if any) while "[" and"]" have to be recognized as Source only if after a Year or Category (because of the movie [REC] (2007), for example). Or, whatever is possible to fill in, and rest to ignore.

I know it's too much, but any help would be appreciated a lot! Thank you in advance.

 

anything