Genre selected from .csv per show

All about user-defined episode / movie / file name format expressions
Post Reply
Natator
Posts: 2
Joined: 21 Nov 2016, 14:18

Genre selected from .csv per show

Post by Natator »

Hi all

I'm a recent convert, and huge fan, of Filebot Node. Wow, serious wow, great work RedNoah!

I've finally got it all working, after much stuffing around that was a result of me not really knowing what I'm doing, but I got there and it works brilliantly. There's one thing though that I just can't do, or find in the forums, but I'm pretty sure it is doable. Here's what I'm trying ....

I've been putting TV programs into genres that suit us. These are often not the same as Filebot Node will pull from TVDB. Even selecting from multiple genres won't do what I'm after as my choice is a bit arbitrary (i.e. I might call one program with a crime/drama genre a crime and the next tv program a drama).

What I want to do is the following:

1) Have a .csv file I create manually (Excel and then export as a .csv). This will have two columns .... Program Name & Genre. It will basically be a list of the TV programs we follow and then the genre I want to put them in, which might be completely different to anything TVDB says.

2) Assign the genre I have against any given program to it during the renaming process.

3) If a program is not found in my .CSV file then assign it "Unknown" as a genra, and put in TV/Unknown folder. I would then go and manually add that program to the .csv file for next time.

4) Put them into a /TV/Genre/Program-name folder..... which I am already doing successfully but using the genre from TVDB

So, essentially I want to have my own list of program names (they will match TVDB names exactly) but assign each program to a genre I've selected myself.

Also, assuming I now have a line of code that can do this .... where do I put the .csv? I assume it just needs a path etc.

More than happy to throw a Paypal your way if you can help me get this going Rednoah.

:)

Simon
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Genre selected from .csv per show

Post by rednoah »

Read mappings from CSV file using the series name as key:

Code: Select all

{csv('/path/to/genres.csv').get(n) ?: 'Unknown'}
CSV file:

Code: Select all

Deep Space 9;Star Trek
:idea: Please read the FAQ and How to Request Help.
Natator
Posts: 2
Joined: 21 Nov 2016, 14:18

Re: Genre selected from .csv per show

Post by Natator »

Absolutely awesome! Thanks so very much, will go hit Paypal for you.

I knew it was doable but had no idea how easy (not that I would have come up with it). I didn't find it in search as I didn't realise it was called mapping.
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Genre selected from .csv per show

Post by rednoah »

It does come up occasionally, so there's built-in helper functions for these things nowadays.

csv('/path/to/genres.csv') will give you a Map object so it's literally the same as writing ['Deep Space 9': 'Star Trek'] in the Groovy code.

@see viewtopic.php?f=5&t=182
:idea: Please read the FAQ and How to Request Help.
Post Reply