Page 1 of 1

Lookup parts of the filename in CSV

Posted: 13 Jul 2015, 10:29
by aj1216
Is it possible to lookup a CSV for parts of the filename.

At the moment my code is pretty long to include all the possible movie editions, versions and cuts.

What I would like to do is move all this out to a CSV file.

example.csv
Director cut;Directors cut
Directors cut;Directors cut
Director's cut;Directors cut
dir cut;Directors cut
Special Edition;Special Edition
Extended;Extended Edition
etc...

Re: Lookup parts of the filename in CSV

Posted: 13 Jul 2015, 11:59
by rednoah
Yes.

Here's an example: 4. Mappings from a CSV file => viewtopic.php?f=5&t=182

Re: Lookup parts of the filename in CSV

Posted: 13 Jul 2015, 13:33
by aj1216
I've seen a few of the examples, but the problem is that it looks for a complete match, I just wanna do a partial one.

My script:
{y =~ "2014|2015" ? "\\\\DS3612\\Volume 1\\Video\\Filmer\\" : "\\\\DS3612\\Volume 2\\Filmer\\"}\{n.replaceAll(/[\\/?<>:|]/, "").replaceAll(/[*\s]+/, " ").replaceAll(/[`´‘’ʻ""“”]/, "'")} ({y}) [{imdbid} {(csv('editions.csv').get(fn.lower().replaceAll(/[._]/," ")) ?: "") + " "}{"$source "}{vf} {vc} {af} {ac}{" $group"}]

Filename:
Aliens.Special.Edition.1986.720p.BrRip.x264.YIFY.mp4

editions.csv:
special edition;SPECIAL EDITION

As you can see it wont match since its looking for "aliens special edition 1986 720p brrip x264 yify" in the CSV file

Re: Lookup parts of the filename in CSV

Posted: 13 Jul 2015, 13:44
by rednoah
1.
Why don't you just use the {tags} binding?

2.
csv() will give you a Map. Instead of just using Map.get() you can do lots of other things if you need slightly more complicated logic and conditions.

e.g.

Code: Select all

{['regex':'TAG'].findResult{ k, v -> if (fn =~ k) v}}

Re: Lookup parts of the filename in CSV

Posted: 13 Jul 2015, 16:55
by aj1216
Thanks for you help, got it working by using:
{csv('editions.csv').findResults{ k, v -> if (fn.lower().replaceAll(/[._]/," ") =~ k) v}.unique().join(' ')}

{tags} gave me a undefined error when the filename didnt have tags in them.
A also wanted to pick up strange versions like for example X-Men: Days of Future Past The Rogue Cut

Re: Lookup parts of the filename in CSV

Posted: 13 Jul 2015, 17:12
by rednoah
I can add patterns for {tags} for the next release if you can give me your list. ;)

Re: Lookup parts of the filename in CSV

Posted: 13 Jul 2015, 17:29
by aj1216
Only one I seen a few of is "dir cut" which you dont have on your list. The rest is one off for each movie which would be impossible to maintain.