Page 1 of 1

Country of origin

Posted: 24 Aug 2014, 22:55
by 0rca
Just a very quick question: Is it possible to add the country of origin of a movie? I know that IMDB has them listed with each movie (http://www.imdb.com/country) but I couldn't find anything here on the forum about it.

Re: Country of origin

Posted: 25 Aug 2014, 06:44
by rednoah
No.

Besides, IMDb is no longer supported.

Re: Country of origin

Posted: 25 Aug 2014, 20:10
by 0rca
Thanks rednoah, then I'll have a look, if I can add that info with some others tools.

But what do you mean with the IMDB support, is that something that's going to happen and will it be removed or is there simply no further development for IMDB?

Cheers,

Michael

Re: Country of origin

Posted: 25 Aug 2014, 23:16
by rednoah
IMDb related code has been removed completely with v4.3 and higher.

Re: Country of origin

Posted: 25 Aug 2014, 23:59
by 0rca
Puh, than I am lucky that I am still on 4.2. I am new here and just started to use Filebot and I love it. I just did a quick search, but couldn't find anything regarding IMDB support and I almost don't dare to ask, but what the hell, I'll ask anyway ;-)

Why?

Re: Country of origin

Posted: 26 Aug 2014, 00:13
by rednoah

Re: Country of origin

Posted: 21 Feb 2015, 00:41
by 0rca
Hi again,

I found out meanwhile that {info.ProductionCountries} works fine. I have pieced together most of the things I wanted for renaming my files from bits and pieces here on the forum without fully understanding everything I have found working, sometimes simply by trial and error ;-)

There are 2 more things I would love to be able to do, but I can't figure them out for myself. First, here's my complete format expression:

Code: Select all

{genre}/{n.replaceAll(/[:|]/, "-")} ({primaryTitle.replaceAll(/[:|]/, "-")}) ({y}) {info.ProductionCountries}/{n.replaceAll(/[:|]/, "-")} ({y}) [{imdb.rating} - {minutes}min] [{audios.collect{ aud -> allOf{any{aud.language.upper()}{'EN'}}{aud.format.lower()}{aud.channels+'ch'} }*.join(' ').join(', ')}] [{vc} {video.frameRate}fps {vf}]{if (ext != /nfo/) {"-CD$pi"}}{if (ext =~ /jpg/) {'-fanart'}}
As you can see i am trying to sort everything by genre, then display the most interesting informations (for me) in the folder and then a lot of details in the file name. I am happy with the file name, but for the folder name I would wish for two things:

I have a lot of foreign movies and am trying to show the international title and the the original title in brackets. BUT: I would love to be able to skip the original title part if the're both the same. Can anyone help me do that?

E.G. A Better Tomorrow (Ying hung boon sik) (1986) [Hong Kong] is fine as it is, but "47 Ronin" should ideally end up as 47 Ronin (2013) [United States of America] instead of 47 Ronin (47 Ronin) (2013) [United States of America]

Which brings me to the second wish I can't get done myself: Instead of the full country name I would love to use 2-letter country codes, like
A Better Tomorrow (Ying hung boon sik) (1986) [HK] or 47 Ronin (2013) [US]
Is there a way to do that? I could get a list of all country codes and their full names, but how would I look that up?

I would appreciate any kind of help, as I am way out of my depth here.. :)

Re: Country of origin

Posted: 21 Feb 2015, 02:41
by rednoah
1.
I'd do something like: {allOf{ /a/ }{ /b/ }.unique()}

2.
You'd have to somehow map country names to code. The Java Locale APIs might be a solution. It'll require same basic Java/Groovy coding expertise.

Maybe a simple replace logic with csv file would be easier. There's certainly more help for this in the forums here.

Re: Country of origin

Posted: 21 Feb 2015, 17:54
by 0rca
Thanks a lot, I've managed to sort 1.

But for 2. I can't get it right. Schouldn't

Code: Select all

 {csv('C:/Desktop/countrycodes.csv').get(info.ProductionCountries) ?: (info.ProductionCountries) }
result in [US] instead of [United States of America] if my only line in the CSV file is

Code: Select all

United States of America;US
(assuming I do this on an US movie....)

No matter what I try, I only get the full name... :-(

Re: Country of origin

Posted: 24 Feb 2015, 06:14
by rednoah
info.ProductionCountries is a list. Use info.ProductionCountries[0] if you want the first element in that list.

Re: Country of origin

Posted: 25 Feb 2015, 01:52
by 0rca
Thanks again, Rednoah. I'm almost there:

Code: Select all

{genre}/{( n == info.originalName) ? n.replaceFirst(/^(?i)(The|A|An|)\s(.+)/, /$2, $1/).replaceAll(/[:|]/, "-") : n.replaceFirst(/^(?i)(The|A|An|)\s(.+)/, /$2, $1/).replaceAll(/[:|]/, "-") + (' ') + ([info.originalName])} ({y}{csv('c:/Program Files/FileBot/countrycodes.csv').get(info.ProductionCountries[0]) ?: ('')}{csv('c:/Program Files/FileBot/countrycodes.csv').get(info.ProductionCountries[1]) ?: ('')})/{n.replaceAll(/[:|]/, "-")} ({y}{csv('c:/Program Files/FileBot/countrycodes.csv').get(info.ProductionCountries[0]) ?: ('')}) [{imdb.rating} - {minutes}min] [{audios.collect{ aud -> allOf{any{aud.language.upper()}{'EN'}}{aud.format.lower()}{aud.channels+'ch'} }*.join(' ').join(', ')}] [{vc} {video.frameRate}fps {vf}]{if (ext != /nfo/) {'-CD'+pi}}{if (ext =~ /jpg/) {'-fanart'}}
I'm probably doing redundant stuff with

Code: Select all

{csv('c:/Program Files/FileBot/countrycodes.csv').get(info.ProductionCountries[0]) ?: ('')}{csv('c:/Program Files/FileBot/countrycodes.csv').get(info.ProductionCountries[1]) ?: ('')}
but that was the only way I could get both Countries to display, if there is a second one. And even then I had to add a space before the 2-letter country code in the CSV, because I couldn't figure out, how else to do it in the code :-/ Now I have tried to get a f***ng comma between the country codes, but I failed again and again. I thought I could do some IF info.ProductionCountries[1] == null THEN ELSE (',') but without any clue its simply endless trials and errors :-(

Would anybody help me once more? The goal would be to have it like this

12 Years a Slave (2012 GB, US)

Re: Country of origin

Posted: 25 Feb 2015, 03:02
by rednoah
If you wanna get multiple keys you can do something like this:

Code: Select all

[0:'a', 1:'b', 2:'c'].subMap([0, 2])
If you access the 2nd element of 1-element list you won't get NULL back, you'll get a OutOfBoundsException thrown, which unwinds the code.


The solution you're looking for is probably something like:

Code: Select all

{['United Kingdom':'UK'].subMap(info.ProductionCountries).values()}
or

Code: Select all

{info.ProductionCountries.findResults{ ['United Kingdom':'UK'].withDefault{ 'Unmapped Country: '+it }.get(it) }}
In your case the Map is read from the CSV file of course.