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

0 Members and 1 Guest are viewing this topic.

Offline nostra

  • Administrator
  • *****
  • Posts: 2852
    • View Profile
    • Personal Video Database
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #40 on: March 21, 2010, 08:26:44 pm »
1. You can't get category, quality or custom fields using regexps.
2. "Original Title" ("Year") should be processed correctly with default regexps.
3. for "English Title" - "Original Title" ("Year") ("Category") ["Source"] you need:
Code: [Select]
(?i)^.*\\(?P<title>.*) - (?P<origtitle>.*) \((?P<year>[0-9]{4})\).*
Gentlemen, you can’t fight in here! This is the War Room!

buah

  • Guest
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #41 on: March 21, 2010, 10:23:18 pm »
Tnx nostra, it works great!!!

Hoping that I'm not taking you too much time, just two more things.

1. Is it possible to get ID from the name, cause actually I forgot that the full syntax of my folders (and videos) is:
"ID" - "English Title" - "Original Title" ("Year") ("Category") ["Source"]

2. Is it possible and how to replace "^" with "?", and "--" with ":" wherever it occurs in the name?

I really feel ungrateful now, because I forgot to ask this in my previous post. I guess it happened cause I've been working during weekend as well, and making a lot of reports.

Cheers

Offline nostra

  • Administrator
  • *****
  • Posts: 2852
    • View Profile
    • Personal Video Database
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #42 on: March 21, 2010, 11:50:56 pm »
Quote
1. Is it possible to get ID from the name, cause actually I forgot that the full syntax of my folders (and videos) is:
"ID" - "English Title" - "Original Title" ("Year") ("Category") ["Source"]

No. Only these fields: title, original title, year, season number, episode number, episode title

Quote
2. Is it possible and how to replace "^" with "?", and "--" with ":" wherever it occurs in the name?

Yes, you have a "Find and replace" table at the bottom of File scanner preferences for this.
Do not forget to escape ? and ^ with \.
Gentlemen, you can’t fight in here! This is the War Room!

buah

  • Guest
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #43 on: March 22, 2010, 09:23:39 am »
Tnx once again. It all works like a charm.

buah

  • Guest
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #44 on: March 22, 2010, 11:40:43 pm »
OK, my head exploded.

1. I want to match \d{5}\s-\s ("04523 - ", for instance) which is at the start of the string and not to capture it, but to capture everything after that match, which is what nostra gave me two posts above. Example:

05013 - Antichrist (2009)

I want to capture only <title> and <year>. First 8 characters are always \d{5}\s-\s

2. Nostra, it seems that your regex can't capture movie [REC] (2007)?

Please!
« Last Edit: March 22, 2010, 11:42:42 pm by buah »

Offline nostra

  • Administrator
  • *****
  • Posts: 2852
    • View Profile
    • Personal Video Database
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #45 on: March 23, 2010, 12:14:18 am »
1. I want to match \d{5}\s-\s ("04523 - ", for instance) which is at the start of the string and not to capture it, but to capture everything after that match, which is what nostra gave me two posts above. Example:

05013 - Antichrist (2009)

I want to capture only <title> and <year>. First 8 characters are always \d{5}\s-\s

Code: [Select]
(?i)^.*\\.*- (?P<title>.*) \((?P<year>[0-9]{4})\).*
Quote
2. Nostra, it seems that your regex can't capture movie [REC] (2007)?

There is no original title here, so you need:

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

buah

  • Guest
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #46 on: March 23, 2010, 12:11:11 pm »
Tnx, I need now only to handle situation when there are both title and origtitle. I hope I'll figure it out somehow.

But...

Quote
2. Nostra, it seems that your regex can't capture movie [REC] (2007)?

There is no original title here, so you need:

Code: [Select]
(?i)^.*\\(?P<title>.*) \((?P<year>[0-9]{4})\).*

... it seems that the problem with the [Rec] (2007) movie is how to escape "[" and "]" and make them literal. Also, I have on my mind .45 (2006) movie, or Tristan + Isolde (2006) movie, for example.

They all contain meta-characters in title, that need to be escaped?

Offline nostra

  • Administrator
  • *****
  • Posts: 2852
    • View Profile
    • Personal Video Database
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #47 on: March 23, 2010, 02:31:10 pm »
Quote
They all contain meta-characters in title, that need to be escaped?

You escape characters in a regular expression, but not the result of it's work... In your case there is no need to escape smth.
Gentlemen, you can’t fight in here! This is the War Room!

buah

  • Guest
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #48 on: March 23, 2010, 06:15:27 pm »
Dough!

Nostra, although it doesn't work for me, please ignore me until I'm better concentrated. I mean it ;D

[attachment deleted by admin]
« Last Edit: March 23, 2010, 06:27:10 pm by buah »

Offline nostra

  • Administrator
  • *****
  • Posts: 2852
    • View Profile
    • Personal Video Database
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #49 on: March 23, 2010, 08:45:29 pm »
NMM only suggests original title (I do not know why I did it like this any more, to be honest)
Gentlemen, you can’t fight in here! This is the War Room!

buah

  • Guest
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #50 on: March 24, 2010, 07:41:04 am »
Oh, I thought NMM also would give me the same result as scanner.

As I said earlier, scanner works perfectly. Thank you and sorry for wasting your time, honestly.

So, this is regexp that works for my movie naming convention

"ID" - "Title" - "Original Title" "(Year)" "Whatever-but-to-be-ignored"

Quote
(?i)^.*\\.*- (?P<title>.*) - (?P<origtitle>.*) \((?P<year>[0-9]{4})\).*

[attachment deleted by admin]

Offline STEPHAN

  • Member
  • *
  • Posts: 10
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #51 on: October 10, 2010, 03:02:13 pm »
Hi,

I am using OTR (OnlineTvRecorder.com). This is a website that lets you record and download German TV. I live in the US ....

Personal Video Database was recommended in their forum.

My (their) film files are in this format:

Gangs_of_New_York_08.02.23_20-15_pro7_180_TVOON_DE.mpg.HQ.cut.avi
Der_Dummschwaetzer_10.09.26_20-15_rtl2_105_TVOON_DE.mpg.HQ.cut.avi
Krieg_der_Welten_08.02.24_20-15_pro7_135_TVOON_DE.mpg.HQ.cut.avi
Der_Schakal_08.02.08_20-15_rtl2_135_TVOON_DE.mpg.HQ.cut.avi
Projekt_Peacemaker_08.02.01_20-15_pro7_135_TVOON_DE.mpg.HQ.cut.avi
King_Tut_Der_Fluch_des_Pharao_08.02.02_20-15_pro7_180_TVOON_DE.mpg.HQ.cut.avi


That’s Title, Date it was send, Time it was send, TV Station, Length of the whole broadcast (including advertising) "TVOON" , quality of the recording, if advertising was cut out etc.

So, only the Title really matters. If I manually search using the title everything works okay (using German Film Databases of cause). Now I am trying to get the Regular Expression for this created, but I don't know anything about it and its hard to get started for me – even with the website recommended here.

Any help would be greatly appreciated.

Thanks

Stephan


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 #52 on: October 10, 2010, 11:43:03 pm »
Welcome, Stephan.

(?i)^.*\\(?P<title>.*)(_[0-9]{2}\.[0-9]{2}\.[0-9]{2}_).*\..{3,4}

will handle this pattern. This illustrates what is probably the most common regex technique in this application. The fixed pattern of the date is recognized by (_[0-9]{2}\.[0-9]{2}\.[0-9]{2}_). Having this, the title is always whatever is between the last "\" and the date. The "_" in the title are replaced by " " by a Find & Replace rule. Whatever is after the date can be ignored. The same technique can be used where a title is followed by a fixed pattern of year or season and episode number(s). The .*\..{3,4} after the date means "any number of any character until a '.' followed by 3 or 4 characters." That could probably just as well be .*\.avi, but this will work for any file type.

Offline nostra

  • Administrator
  • *****
  • Posts: 2852
    • View Profile
    • Personal Video Database
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #53 on: October 10, 2010, 11:46:41 pm »
Do not know if you already noticed it, but I have uploaded an app to help writing regular expressions for PVD:
http://www.videodb.info/bin/pvdrt.zip

You still need to write the expression , but it is much easier to test it with this app.
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 #54 on: October 11, 2010, 12:24:12 am »
Quote
but it is much easier to test it with this app.

Indeed, it is. I suggest you add a button to Preferences>File scanner to call this. It's perfect for those of us who do everything by trial & error. ;)

Offline nostra

  • Administrator
  • *****
  • Posts: 2852
    • View Profile
    • Personal Video Database
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #55 on: October 11, 2010, 12:41:26 am »
Quote
I suggest you add a button to Preferences>File scanner to call this.

I could, acutally. The problem is that I do not plan shipping the app with the installation package, but I think I could add such button if RegEx Tester is located in PVD directory.
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 #56 on: October 11, 2010, 12:49:40 am »
Quote
I do not plan shipping the app with the installation package

If you were to include a button, why not?

Offline STEPHAN

  • Member
  • *
  • Posts: 10
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #57 on: October 11, 2010, 12:53:25 am »
First of all thanks for all this help being offered, I am impressed !

I am a software developer, so I am usually not that stupid. However I have never worked with Regular Expressions.

I still can' recognise any files, so I might be doing something completely wrong.

I added this RegEx to the configuration of the filescanner and moved it up so it is first.

Then I select the option from the menu (or press CTRL-F) and select the directory were all the files are ... and he does not find any files.

Am I doing it correct ?

Great that you developed this tool. How should I use it ?


Offline nostra

  • Administrator
  • *****
  • Posts: 2852
    • View Profile
    • Personal Video Database
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #58 on: October 11, 2010, 12:59:56 am »
Enter the full path of the file in the "Test string" field.

A great regex tutorial is available here: http://www.regular-expressions.info/tutorial.html
Gentlemen, you can’t fight in here! This is the War Room!

Offline STEPHAN

  • Member
  • *
  • Posts: 10
    • View Profile
Re: 0.9.9.x File Scanner and Regular Expressions
« Reply #59 on: October 11, 2010, 01:51:32 am »
Enter the full path of the file in the "Test string" field.

Great, that works.

Now I need to figure out how the films get recognized by PDV.


 

anything