Page 1 of 1

Specific Genre naming based on several genres.

Posted: 24 Jan 2015, 03:40
by DevXen
So i've looked through the forum, and kinda found info on this. but i'm having an issue.
I want to define my own custom genres. based on the genres the movie has.
For example, I want movies that have Documentary|History|Biography & Drama To be sorted into: Docudrama

I have:
{(imdb.genres.contains('Drama') && imdb.genres.contains('Biography')) ? '[Docudrama]' : imdb.genres.take(1)}

Which works. But how do i add other genres to check?

I've tried:
{(imdb.genres.contains('Drama') && (imdb.genres.contains('History') || imdb.genres.contains('Biography'))) ? '[Docudrama]' : imdb.genres.take(1)}

which that doesn't work. - or is there another way to do it? - Right now this is the only one I can think of that I want, but i might want to add more later on.
ideally i'd like it to be as easy as editing a csv file. but i don't think that's possible with multiple genres sadly.

So something else i've noticed the imdb.genres returns with [ and ] around it. is there a way to change/disable that? I tried the .replace() and that didn't work.


Thanks,
-Dev

Re: Specific Genre naming based on several genres.

Posted: 24 Jan 2015, 10:16
by rednoah
I'd set up my own CSV file that maps the original genre value to something you like.

:idea: Sample

Code: Select all

{csv('mygenres.csv').get(genre) ?: genre}

Re: Specific Genre naming based on several genres.

Posted: 24 Jan 2015, 10:41
by DevXen
Yeah, I did that with my TV Show naming. but with the movies, in this example it's a little more complicated.
I want to separate into a new folder, but only if multiple genres exist.
Drama + Biography or History. and with a csv file, that's not possible, is it?

Re: Specific Genre naming based on several genres.

Posted: 24 Jan 2015, 10:59
by DevXen
So in theory, Could'nt I do something like:


{(imdb.genres.contains('Drama') && imdb.genres.contains('Biography')) ? {csv('mygenres.csv').get(genre) ?: Drama-Biography} : imdb.genres.take(1)}
{(imdb.genres.contains('Drama') && imdb.genres.contains('History')) ? {csv('mygenres.csv').get(genre) ?: Drama-History} : imdb.genres.take(1)}

no. cause that would have it twice as long and put the default genre twice. Hmm.

Re: Specific Genre naming based on several genres.

Posted: 24 Jan 2015, 11:50
by rednoah
For long if-then-else-if-then-else-etc chains you might be able to use one of my helper functions:
@see viewtopic.php?f=5&t=1895

Maybe any{a}{b}{c}{'default'} would help?

Note that {imdb} has been removed, and {omdb} has been added, which should be pretty much the same. Though I still discourage mixing data from different datasources.

Re: Specific Genre naming based on several genres.

Posted: 25 Jan 2015, 13:55
by DevXen
I was able to get that to work with some RegEx, thank you.

and why would ya remove the imdb?

I only used imdb.genres instead of genres. as the 'genres' for the ones i tested on, only showed 1 genre, and randomly it would show 2. and they were completely different than the imdb ones and I wanted to keep consistency with my other files.

Re: Specific Genre naming based on several genres.

Posted: 25 Jan 2015, 13:58
by DevXen
I was able to get it working with:
{any{if (imdb.genres.join(', ').matchAll(/^(?=.*Drama)(?=.*Biography|History)/)){'[Docudrama]'}}{imdb.genres.take(1)}}

I couldn't think of a way to use the csv file, that would make it easier to add too. but this works. i can just keep adding to it, if i need to add say Dramedy. or Dark Comedy.

Re: Specific Genre naming based on several genres.

Posted: 05 Feb 2016, 06:38
by DHoarder
I'm trying to sort films into different folders based on the language:

Code: Select all

def movieformat="//mnt/MyMedia/{omdb.language.contains('Hindi') ? 'Hindi' : 'English' }/..... "
However movie always goes to 'English' folder. What's wrong with this snippet? :?

Re: Specific Genre naming based on several genres.

Posted: 05 Feb 2016, 09:01
by rednoah
1.
What's wrong with this snippet?
omdb.language does not contain "Hindi". That's all I can tell you. :D I don't recommend using {omdb} unless you have a good reason to do so.


2.
TheMovieDB has SpokenLanguages metadata, so that should work:

Code: Select all

{info.SpokenLanguages =~ /de/ ? 'German' : 'Not German'}

PS: Smart people use the FileBot GUI to prototype and test their new formats quickly before pasting them into the command-line.

Re: Specific Genre naming based on several genres.

Posted: 05 Feb 2016, 09:28
by DHoarder
Searching Examples section at http://www.omdbapi.com/ gives:

Code: Select all

{"Title":"Airlift","Year":"2016","Rated":"N/A","Released":"22 Jan 2016","Runtime":"N/A","Genre":"Drama, History, Thriller","Director":"Raja Menon","Writer":"Ritesh Shah, Suresh Nair, Raja Menon, Rahul Nangia","Actors":"Akshay Kumar, Nimrat Kaur, Feryna Wazheir, Pawan Chopra","Plot":"Airlift is an uplifting and entertaining edge-of-the-seat thriller and is the story of the biggest ever human evacuation in the history of mankind.","Language":"[b]Hindi[/b]","Country":"India","Awards":"N/A","Poster":"http://ia.media-imdb.com/images/M/MV5BMTAzZmJiOGQtOWM3NS00MDEwLWJiNGEtN2QzMDM3NDJjMWQwXkEyXkFqcGdeQXVyNDUzOTQ5MjY@._V1_SX300.jpg","Metascore":"N/A","imdbRating":"N/A","imdbVotes":"N/A","imdbID":"tt4387040","Type":"movie","Response":"True"}
So I presume "Hindi" language is there. Will try moviedb today. And , I run filebot headless on a Pi, Yeah..We not so smart folks! :)

Re: Specific Genre naming based on several genres.

Posted: 05 Feb 2016, 09:57
by rednoah
That "language" field is currently not mapped the SpokenLanguages property, so you won't be able to (easily) access it from the format. I'll fix that for the next release, but you should be using TheMovieDB instead anyway. ;)

Re: Specific Genre naming based on several genres.

Posted: 22 Apr 2016, 21:31
by macdalor
DHoarder wrote:I'm trying to sort films into different folders based on the language:

Code: Select all

def movieformat="//mnt/MyMedia/{omdb.language.contains('Hindi') ? 'Hindi' : 'English' }/..... "
However movie always goes to 'English' folder. What's wrong with this snippet? :?
Hi Hoarder, I have a similar need in which I want to sort movies, series and animes (including animation) into different folders based on the language.
I am pretty new to filbert and close to total ignorant about coding but not afraid to try kind of guy ;)

Have you sorted your script out to your likings at all? Would you be able to help please?

Re: Specific Genre naming based on several genres.

Posted: 10 May 2016, 09:32
by DHoarder
Hi Hoarder, I have a similar need in which I want to sort movies, series and animes (including animation) into different folders based on the language.
I am pretty new to filbert and close to total ignorant about coding but not afraid to try kind of guy ;)

Have you sorted your script out to your likings at all? Would you be able to help please?
This seems to be working for me in AMC script:

Code: Select all

--def "movieFormat=//mnt/MyMedia/{info.genres.contains('Documentary') ? 'Documentaries': info.SpokenLanguages =~ /hi/  ? 'Hindi' : 'Movies'}/........
For movie files, it sorts them into 'Documentaries' folder if its genre contains 'documentary'. If not, it checks for its language. For Hindi movies, it goes to 'Hindi' folder; rest goes to 'Movies' folder. Just replace your preferred languages and add this code to your pattern.

Re: Specific Genre naming based on several genres.

Posted: 10 May 2016, 09:45
by rednoah
This would be shorter ;)

Code: Select all

/mnt/Media/{genres =~ /Documentary/ ? 'Documentaries': languages =~ /hi/  ? 'Hindi' : 'Movies'}/...