movie naming scheme that has the specialty of calculating a world average certification

All about user-defined episode / movie / file name format expressions
Post Reply
cafevincent
Posts: 66
Joined: 22 Jun 2017, 10:08

movie naming scheme that has the specialty of calculating a world average certification

Post by cafevincent »

I've got this movie naming scheme that has the specialty of calculating a world average certification (from certifications, average all values under 22) but it fails with many rare movies. I'm guessing that when a movie has no certification numbers listed (or only 1?) it fails.

Format: Select all

{def certifications = net.filebot.WebServices.TheMovieDB.getMovieInfo(movie, Locale.US, true).certifications; def cleanNum = certifications.findResults{key, value -> value.replaceAll('\\D')}.findAll{it}*.toInteger().findAll{it < 22}; def int avg = (cleanNum.sum() / cleanNum.size()).toDouble().round(); (allOf{ny}{director}{omdb.genres}{any{'c'+avg}{certifications.US}{'NR'}}{'r'+(int)(omdb.rating * 10)}{vf}{vc}{ac}{imdbid}).join(' ')}
The credits for this naming scheme goes to RedNoah! I cannot code.
User avatar
rednoah
The Source
Posts: 24637
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Need help fixing this movie naming scheme

Post by rednoah »

:?: Can you give me a TMDB link for one of these rare movies?
:idea: Please read the FAQ and How to Request Help.
cafevincent
Posts: 66
Joined: 22 Jun 2017, 10:08

Re: movie naming scheme that has the specialty of calculating a world average certification

Post by cafevincent »

https://www.imdb.com/title/tt32635624/
https://www.imdb.com/title/tt13407984/

those do not have certifications. this next one does, and has two numbers, but also a potential large problem number with a hashtag. large numbers should be ignored but maybe the hashtag ruins something, or the problem is entirely different.

https://www.imdb.com/title/tt0093952/
User avatar
rednoah
The Source
Posts: 24637
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: movie naming scheme that has the specialty of calculating a world average certification

Post by rednoah »

Alright, lets test with these TMDB IDs:
* https://www.themoviedb.org/movie/1305787-micro-budget
* https://www.themoviedb.org/movie/108101 ... man-flight
* https://www.themoviedb.org/movie/113747-shame



You could rewrite your format like so:

Format: Select all

{
	any{
		'c' + info.certifications.findResults{ k, v -> any{ v.match(/\d+/).toInteger() }{ null } }.findAll{ it < 22 }.average().round()
	}{
		info.certifications.US
	}{
		'NR'
	}
}
That'll give you R (has no numeric certification but does have a US certification) and NR (has no numeric certification and no US certification) for the test cases above.



EDIT
Here's a more modern version of your old format if you need a copy & paste solution:

Format: Select all

{ ny } 
{ director } 
{ genres.take(3) } 
{
	any{
		'c' + info.certifications.findResults{ k, v -> any{ v.match(/\d+/).toInteger() }{ null } }.findAll{ it < 22 }.average().round()
	}{
		info.certifications.US
	}{
		'NR'
	}
} 
{ 'r' + (rating * 10).round() } 
{ vf } 
{ vc } 
{ ac } 
{ 'MID' + tmdbid }
:idea: Please read the FAQ and How to Request Help.
cafevincent
Posts: 66
Joined: 22 Jun 2017, 10:08

Re: movie naming scheme that has the specialty of calculating a world average certification

Post by cafevincent »

Thank you, but I would rather it only averages the found numbers between 0-21, and if we can't get any resulting number this way then do not write the c## or the extra space at all, since we don't know if other countries have similar marking and what their corresponding numbers would be, and they could be changing all the time. Too much hassle to keep knowledgeable about all that, so let's stick to the facts and keep the results accurate and the code a bit easier to manage. I'm sorry for not being more verbal earlier.
cafevincent
Posts: 66
Joined: 22 Jun 2017, 10:08

Re: movie naming scheme that has the specialty of calculating a world average certification

Post by cafevincent »

That reminds me, it is possible to have an imdb entry where there are no imdb rating on it yet, so maybe that same logic (if no number then do not write the r##+space in the filename).
User avatar
rednoah
The Source
Posts: 24637
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: movie naming scheme that has the specialty of calculating a world average certification

Post by rednoah »

cafevincent wrote: Yesterday, 13:02 I would rather it only averages the found numbers between 0-21
The code above does exactly that as far as I can tell.

cafevincent wrote: Yesterday, 13:05 if no number then do not write the r##+space in the filename
The code above uses {rating} which is based on TMDB and thus never undefined.
:idea: Please read the FAQ and How to Request Help.
cafevincent
Posts: 66
Joined: 22 Jun 2017, 10:08

Re: movie naming scheme that has the specialty of calculating a world average certification

Post by cafevincent »

It seems to replace my certification (c## = c for certification followed by 1-2 numbers which is the calculated average) with either NR, PG or R. Any of my attempts to fix the issue seems to make it worse.

Plus using your new version also gives me incorrect imdb ratings. For example The Dark Knight displays 8.5 instead of 9.1
User avatar
rednoah
The Source
Posts: 24637
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: movie naming scheme that has the specialty of calculating a world average certification

Post by rednoah »

Can you give a few examples of movie + certification value that you want to see for that movie?

The new code will give you TMDB ratings, not IMDB ratings. We can change the code if you must have IMDB ratings (and account for IMDB rating not being available for the given TMDB ID).
:idea: Please read the FAQ and How to Request Help.
Post Reply