Lookup parts of the filename in CSV

All about user-defined episode / movie / file name format expressions
Post Reply
aj1216
Posts: 7
Joined: 13 Jul 2015, 10:17

Lookup parts of the filename in CSV

Post 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...
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Lookup parts of the filename in CSV

Post by rednoah »

Yes.

Here's an example: 4. Mappings from a CSV file => viewtopic.php?f=5&t=182
:idea: Please read the FAQ and How to Request Help.
aj1216
Posts: 7
Joined: 13 Jul 2015, 10:17

Re: Lookup parts of the filename in CSV

Post 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
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Lookup parts of the filename in CSV

Post 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}}
:idea: Please read the FAQ and How to Request Help.
aj1216
Posts: 7
Joined: 13 Jul 2015, 10:17

Re: Lookup parts of the filename in CSV

Post 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
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Lookup parts of the filename in CSV

Post by rednoah »

I can add patterns for {tags} for the next release if you can give me your list. ;)
:idea: Please read the FAQ and How to Request Help.
aj1216
Posts: 7
Joined: 13 Jul 2015, 10:17

Re: Lookup parts of the filename in CSV

Post 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.
Post Reply