Genres by folder modification

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Genres by folder modification

Post by sp00kie »

Hi,

I am running filebot via the cli in order to sort my movies. I have modified the amc.groovy script to add genres to the path as follows. (I tried doing it via the cli but it would use the literal label instead of the genre)

Code: Select all

	mov:   tryQuietly{ movieFormat  } ?: '''Movies/{any{genre}{'No Genre'}}/{n} ({y}){' CD'+pi}{'.'+lang}''',
It's working really nicely but I would like to make some modifications.

1. I would like "Science Fiction to be "Sci-Fi"
2. I would like all Non-English language non-Australian movies to have their own genre. ie. All French movies to be in the genre folder "French", all Russian Movies to be in the genre folder "Russian".
3. For Australian movies, I would like to put them in the genre folder "Australian" even though I know the language is English. Then within the Australian folder I would liike them sorted into folders by genre.
I hope all that makes sense.

Making the genre change was pretty easy. This is way beyond my skill and knowledge levels. I would really appreciate some guidance.
User avatar
rednoah
The Source
Posts: 23947
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Genres by folder modification

Post by rednoah »

1.
You don't have to modify the script. But passing complex cmdline arguments if you don't know how cmdline works.

2.
Replace String? Use String.replace() method.

3.
Not sure if that information is available. I'd check the {info} binding and see if there's a field that works for you. Same as with the Australian movies. I don't think there's a way to reliable tell if a movie is Australian or not. For French you can probably tell by SpokenLanguage field.
:idea: Please read the FAQ and How to Request Help.
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

Thanks for your response!

1. I tried for an hour with the commandline and it turned out it was easier to modify the script than spend more time on that. I'm sure with more skill and probably better use of \" "\ I could probably figure it out. I still would like to modify the code

Code: Select all

   mov:   tryQuietly{ movieFormat  } ?: '''Movies/{any{genre}{'No Genre'}}/{n} ({y}){' CD'+pi}{'.'+lang}''',


to include changing the genre "Science Fiction" to "Sci-Fi". Can anyone suggest how?

2. Thanks! I will take a look at the SpokenLanguage field and do some testing to see how complete the data is and how well it works.

3. So it sounds like I am out of luck with using the database to sort by country. It's a shame TMDB doesn't have that data.
User avatar
rednoah
The Source
Posts: 23947
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Genres by folder modification

Post by rednoah »

1.
Whatever you do, any prototyping you really really wanna do in the GUI Format Editor, and only paste a tested & working format into the script.

Also:
@see http://www.filebot.net/forums/viewtopic.php?f=4&t=1899
@see http://www.filebot.net/forums/viewtopic.php?f=4&t=1041
:idea: Please read the FAQ and How to Request Help.
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

So, Here is where I am so far;

1. Nothing new. Still can't figure it out.
2. Spoken Languages is good for this field. I will go with that. Now I just need to figure out what the actual code is. Hmm. It turns out {spokenlanguages} is undefined. I also tried it with different capitalisations. No luck. Any suggestions?
3. I think I have found a solution for this. There is a field in TMDB which is called "Production Countries" It has an ISO code and a name. For example for Adore (2013), it lists them as Australia and France and it lists SpokenLanguages name as English. Perfect!

Here is a link to sample data for the movie.

http://api.themoviedb.org/3/movie/tt210 ... d45be99f13
Last edited by sp00kie on 20 Sep 2014, 17:53, edited 1 time in total.
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

rednoah wrote:1.
Whatever you do, any prototyping you really really wanna do in the GUI Format Editor, and only paste a tested & working format into the script.

Also:
@see http://www.filebot.net/forums/viewtopic.php?f=4&t=1899
@see http://www.filebot.net/forums/viewtopic.php?f=4&t=1041
Thanks for the advice! Will do!
User avatar
rednoah
The Source
Posts: 23947
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Genres by folder modification

Post by rednoah »

You can do {info.ProductionCountries} with r2578.
:idea: Please read the FAQ and How to Request Help.
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

ok, I just checked and I'm still running v 4.2 which is from the Ubuntu 14.04 official repo and yup, it is r2326. Ouch. Will look for a way to upgrade.
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

ok, So I installed Java 8 and then I found there is no deb version of this latest filebot. I can run the gui using java but I don't know how to run it from the command line. Can someone please tell me how to replace my existing filebot on Ubuntu with the Jar file I downloaded from sourceforge?

Both of the info fields work but I need to do some adjustments. I need only the first ProductionCountries item and I need to look up the iso code in Spokenlanguages and change them to the word. eg. [en] -> English

I've found a link here to some info I might be able to use.

http://www.filebot.net/forums/viewtopic.php?t=2

So, I figured out how to get the first item in the list using [0] so now I just need to figure out how to lookup the iso code and replace it with the word. Also, how to replace "United States of America" with "USA"
Last edited by sp00kie on 21 Sep 2014, 09:03, edited 1 time in total.
User avatar
rednoah
The Source
Posts: 23947
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Genres by folder modification

Post by rednoah »

1.
Use the .deb for the latest beta and then override the jar with the latest jar. It's Copy & Replace really.

2.
SpokenLanguages will give you a List of Local objects. So you can do Locale.displayLanguage.
:idea: Please read the FAQ and How to Request Help.
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

rednoah wrote:1.
Use the .deb for the latest beta and then override the jar with the latest jar. It's Copy & Replace really.

2.
SpokenLanguages will give you a List of Local objects. So you can do Locale.displayLanguage.
1. ok. I will look for the jar and replace it.
2. I'm sorry, I don't understand. I tried using SpokenLanguages[0].Locale.DisplayLanguage and variations of it and I just keep getting errors. I think I need more help with understanding the syntax.
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

ok, I got it.

Code: Select all

{info.SpokenLanguages[0].displayLanguage}
Found the jar file in /usr/share/filebot. Replaced the file. It Works!
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

ok, So it's coming together. Here is the logic I need to implement

Code: Select all

If productioncountry = Australia
          Genre = Australian
else
          if SpokenLanguage<>English and not empty
                    Genre = spokenLanguage
          else
                   If Genre = Empty
                            Genre = "No Genre"
                   else
                            Genre = Genre[0]
                   endif
           endif
endif

Here is the code I have so far. I'm sure this is really ugly and theres probably a neat, elegant way to do it with regular expressions but they make my head hurt.

Code: Select all

if ({info.ProductionCountries[0]} = "Australia")
      "Australian"
else
       If ({SpokenLanguages[0].displayLanguage} != "English" [b](I don't know how to check for a null here)[/b])
                    {info.SpokenLanguages[0].displayLanguage}
       else        
                    {any{genre}{'No Genre'}
       endif
endif
Im not sure if I should put this in place or write it to a variable and then use that in the assignment. I think it will be unreadable if I paste all this into the movie assignment line.
User avatar
rednoah
The Source
Posts: 23947
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Genres by folder modification

Post by rednoah »

Here's the solution:

Code: Select all

{any{(info.ProductionCountries as String).match(/Australia/)}{(info.SpokenLanguages.displayLanguage as String).match(/English/)}{genre}{'No Genre'}}
:idea: Please read the FAQ and How to Request Help.
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

rednoah wrote:Here's the solution:

Code: Select all

{any{(info.ProductionCountries as String).match(/Australia/)}{(info.SpokenLanguages.displayLanguage as String).match(/English/)}{genre}{'No Genre'}}
Wow, That is much cleaner but it's not giving me the results I expected. Movies that are English and NOT Australian should use the genre. Otherwise, they should use the spokenlanguage. I think the problem is the match(/English/ It should be "If spoken language is English, use the genre (or no genre if there isn't one), otherwise, use the spoken language". Now it is "If spoken language is english, use "English", otherwise, use Genre, (or no genre if there isn't one)". I'm searching the website for how to use conditions in expressions without if then else.
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

ok, I am SOOOO close! I found the conditional

I am using .contains then ? : else

I guess there are other forms but contains will work I think.

Code: Select all

{info.ProductionCountries.contains('Australia') ? 'Australian' : {SpokenLanguages[0].displayLanguage.contains('English') ? genres[0] : SpokenLanguages[0].displayLanguagege}}
The only thing it's doing wrong is it isn't picking up the non-English language. It's giving me some random number and letters instead of "France", "Germany", etc
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

ok, I think this is it.

Code: Select all

{info.ProductionCountries.contains('Australia') ? 'Australian' : info.SpokenLanguages[0].displayLanguage.contains('English') ? any{genre}{'No Genre'} : info.ProductionCountries[0] }
The only thing it doesn't do is if it is Science Fiction, make it Sci-Fi but really, I am too tired to look at it now. Maybe next weekend!
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

ok, I've already discovered a lot of bad data - especially with USA movies that for some reason have a spoken language that isn't English. Also, the "No Genre" thing isn't working. It's just putting them in the main folder. Ypu, I can't rely on spokenlanguages. I'm going to have to go it all with productioncountries which seems more reliable.

I would like to do something like this but or doesn’t work.

Code: Select all

{info.ProductionCountries.contains('Australia') ? 'Australian' : info.ProductionCountries.contains('United Kingdom' or 'United States of America')) ? any{genre}{'No Genre'} : info.ProductionCountries[0]}
User avatar
rednoah
The Source
Posts: 23947
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Genres by folder modification

Post by rednoah »

I'd do it like this:

Code: Select all

info.ProductionCountries.any{ it in ['United Kingdom', 'United States of America'] } ? 'English Movie' : 'Other Movie'
:idea: Please read the FAQ and How to Request Help.
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

I tried to incorporate your code into mine. I couldn't get it working. I found a solution, not as elegant as yours but its simpler in syntax so my brain could understand it. :lol:

Here is what I have so far.

Code: Select all

{info.ProductionCountries.contains('Australia') ? 'Australian' : info.ProductionCountries.contains('United Kingdom') ? any{genre}{'No Genre'} : info.ProductionCountries.contains('United States of America') ? any{genre}{'No Genre'} : info.ProductionCountries[0]}
It works better than before but it still doesn't use the "No Genre" folder :roll:

Any suggestions for that and making "Science Fiction" Sci-Fi would be greatly appreciated.
User avatar
rednoah
The Source
Posts: 23947
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Genres by folder modification

Post by rednoah »

1.
I suppose it'll be hard to find a movie that doesn't have at least 1 genre. Movie where no ProductionCountry has been entered yet is probably easier to find.

2.

Code: Select all

'A Science Fiction Movie'.replace('Science Fiction', 'Sci-Fi')
:idea: Please read the FAQ and How to Request Help.
sp00kie
Posts: 17
Joined: 20 Sep 2014, 10:59

Re: Genres by folder modification

Post by sp00kie »

ok. I think it's really done now. Sci-fi works and also it responds with "No genre" if there is no production country and no genre.

For any that might want to use my script as a basis for there own, here it is.

Disclaimer: I'm certain theres a better way to do this. It's just that my knowledge is a touch above zero and this works.

Code: Select all

{info.ProductionCountries.contains('Australia') ? 'Australian' : info.ProductionCountries.contains('United Kingdom') ? genres.contains('Science Fiction') ? 'Sci-Fi' : any{genre}{'No Genre'} : info.ProductionCountries.contains('United States of America') ? genres.contains('Science Fiction') ? 'Sci-Fi' : any{genre}{'No Genre'} : any{info.ProductionCountries[0]}{any{genre}{'No Genre'}}}
Rednoah Thank you SO MUCH for all the help. Sorry I must have seems so stupid sometimes!
User avatar
rednoah
The Source
Posts: 23947
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Genres by folder modification

Post by rednoah »

This is how I'd do it:

Code: Select all

{any{info.ProductionCountries.find{it=='Australia'} ?: info.ProductionCountries.find{it in ['United Kingdom', 'United Kingdom']} ? genre.replace('Science Fiction', 'Sci-Fi') : null} {info.ProductionCountries[0]} {'No Genre'}}
:idea: Please read the FAQ and How to Request Help.
Post Reply