issues sorting genres

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
NeonLightning
Posts: 16
Joined: 24 Jun 2013, 02:17

issues sorting genres

Post by NeonLightning »

Code: Select all

y:\TV\{csv('y:/TV/names.csv').get(n) ?: c{info.certification} ?: "No Known Rating"}\{n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')}\Season {s.pad(2)}\E{e.pad(2)} - {t.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')}
output at present is y:\TV\TV-14\Firefly\Season 01\E01 - Serenity.ext
trying to make it be y:\TV\TV-14\Science-Fiction\Drama\Western\Firefly\Season 01\E01 - Serenity.ext
or even just the first two like y:\TV\TV-14\Science-Fiction\Drama\Firefly\Season 01\E01 - Serenity.ext
in essense i want to be setup a way to set priority for genres and be able to split the output of {genres} to be able to do so
with this

Code: Select all

y:\TV\{c{genres} ?: "No Known Genres"}\{csv('y:/TV/names.csv').get(n) ?: c{info.certification} ?: "No Known Rating"}\{n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')}\Season {s.pad(2)}\E{e.pad(2)} - {t.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')}
output becomes y:\TV\[Drama, Science-Fiction, Western]\TV-14\Firefly\Season 01\E01 - Serenity.ext
am i going to have to set up ?: entries for every genres? and if so i don't know how to seperate them or be able to check all them....
as in i don't know how to seperate drama science-fiction and western and once i do manage to i don't know how to check them so i can prioritise them
User avatar
rednoah
The Source
Posts: 23927
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: issues sorting genres

Post by rednoah »

I'd start like this:

Code: Select all

{genres.take(2).join('/')}
Pretty sure you wanna keep the original order of the {genres} list.

You can come up with any kind of sort order yourself if you want, but you'll have to implement the logic for that yourself:

Code: Select all

{genres.take(2).sort{ a, b -> a <=> b }.join('/')}
:idea: Please read the FAQ and How to Request Help.
NeonLightning
Posts: 16
Joined: 24 Jun 2013, 02:17

Re: issues sorting genres

Post by NeonLightning »

for now this is what i've got it setup as

Code: Select all

y:\TV\{csv('y:/TV/names.csv').get(n) ?: c{info.certification} ?: "No Known Rating"}\{c{genres.take(3).join(' ').match(/Comedy|Documentary|Drama|Children|Reality|Science-Fiction|Adventure|Action|Drama/)} ?: "Unknown"/{genres}}\{n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')}\Season {s.pad(2)}\E{e.pad(2)} - {t.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')}
User avatar
rednoah
The Source
Posts: 23927
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: issues sorting genres

Post by rednoah »

In the newer version you can use any(Closure...) function to slightly simplify things:

Code: Select all

{any{csv('y:/TV/names.csv').get(n)}{info.certification}{'No Known Rating'}}
:idea: Please read the FAQ and How to Request Help.
Post Reply