How to get the correct poster from TMDB?

Support for Windows 10 users and the Microsoft Store package
Post Reply
SebasNights
Posts: 6
Joined: 21 Dec 2016, 00:25

How to get the correct poster from TMDB?

Post by SebasNights »

Hi, I'm using the last version with the UI and the post processing fetch artwork and cover images.

It works great but the posters that I'm getting in several movies are not the primary ones.

What I would like is that the posters that I get are the same of the TMDB website.

Also the fanart seems to take priority in size instead of order. Commonly the first one is the nicer one.

Is that posible?

Thanks
kim
Power User
Posts: 1046
Joined: 15 May 2014, 16:17

Re: How to get the correct poster from TMDB?

Post by kim »

movie ?
result ?
result YOU want ?
language ?

we are not mind readers ;)
kim
Power User
Posts: 1046
Joined: 15 May 2014, 16:17

Re: How to get the correct poster from TMDB?

Post by kim »

@rednoah

just tried the GUI make movie.nfo and I think there is multiple errors:

sample:

Code: Select all

<uniqueid default="true" tmdb="1234"/>
correct =

Code: Select all

<uniqueid type='tmdb'>1234</uniqueid>

Code: Select all

<rating default="true" max="10" name="themoviedb">
correct =

Code: Select all

<rating name='tmdb' max='10' default='true'>
switched

Code: Select all

<imdb id="tt12345678">https://www.themoviedb.org/movie/1234</imdb>
<tmdb id="1234">https://www.imdb.com/title/tt12345678</tmdb>
User avatar
rednoah
The Source
Posts: 19130
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to get the correct poster from TMDB?

Post by rednoah »

kim wrote: 12 Nov 2020, 00:24 just tried the GUI make movie.nfo and I think there is multiple errors:
FileBot r8139 implements the suggested changes.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1046
Joined: 15 May 2014, 16:17

Re: How to get the correct poster from TMDB?

Post by kim »

just to be clear
kim wrote: 12 Nov 2020, 00:24 @rednoah

switched

Code: Select all

<imdb id="tt12345678">https://www.themoviedb.org/movie/1234</imdb>
<tmdb id="1234">https://www.imdb.com/title/tt12345678</tmdb>
correct =

Code: Select all

<tmdb id="1234">https://www.themoviedb.org/movie/1234</tmdb>
<imdb id="tt12345678">https://www.imdb.com/title/tt12345678</imdb>
User avatar
rednoah
The Source
Posts: 19130
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to get the correct poster from TMDB?

Post by rednoah »

Yep. Looks like a copy & paste error nobody noticed. Fixed that too.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1046
Joined: 15 May 2014, 16:17

Re: How to get the correct poster from TMDB?

Post by kim »

is it possible (or can you make it so) to make the nfo's with custom scripts (like i do with amc/htpc.groovy) ?
User avatar
rednoah
The Source
Posts: 19130
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to get the correct poster from TMDB?

Post by rednoah »

kim wrote: 12 Nov 2020, 06:34 is it possible (or can you make it so) to make the nfo's with custom scripts (like i do with amc/htpc.groovy) ?
Not currently possible and not planned as far as the GUI is concerned.
:idea: Please read the FAQ and How to Request Help.
SebasNights
Posts: 6
Joined: 21 Dec 2016, 00:25

Re: How to get the correct poster from TMDB?

Post by SebasNights »

kim wrote: 12 Nov 2020, 00:00 movie ?
result ?
result YOU want ?
language ?

we are not mind readers ;)
Sorry didn't have notifications on.

For example, this movie: https://www.themoviedb.org/movie/369972 ... es/posters

FileBot downloads the second picture, and I want the first one, the primary in this case.

Language is English.
User avatar
rednoah
The Source
Posts: 19130
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to get the correct poster from TMDB?

Post by rednoah »

TheMovieDB doesn't strictly make that possible, since there's no "primary" field:
https://pastebin.com/3M6yxEJx


:idea: We could just take the first poster, which seems to be the primary one in this case. I'm not sure if the API guarantees any kind of order though. Also, we'd lose support for getting the language-specific poster because currently FileBot will pick the poster that matches your preferred language whichever has the highest rating.
:idea: Please read the FAQ and How to Request Help.
SebasNights
Posts: 6
Joined: 21 Dec 2016, 00:25

Re: How to get the correct poster from TMDB?

Post by SebasNights »

rednoah wrote: 12 Nov 2020, 14:46 TheMovieDB doesn't strictly make that possible, since there's no "primary" field:
https://pastebin.com/3M6yxEJx


:idea: We could just take the first poster, which seems to be the primary one in this case. I'm not sure if the API guarantees any kind of order though. Also, we'd lose support for getting the language-specific poster because currently FileBot will pick the poster that matches your preferred language whichever has the highest rating.
For what I could test, the first one on the web (backdrop or poster), filtered by language (English in this case), seems to be the primary one. If the order on the API is the same, you could filter by language and maintain the original order? Or just take the first one in the list with that language.

The fanart (backdrop) in this case also retrieves the second one: https://www.themoviedb.org/movie/1726-i ... anguage=en
kim
Power User
Posts: 1046
Joined: 15 May 2014, 16:17

Re: How to get the correct poster from TMDB?

Post by kim »

the "primary" is = a moderator select it manually = not most or best votes

you can get in

Code: Select all

poster_path	"/i91mfvFcPPlaegcbOyjGgiWfZzh.jpg"

Code: Select all

https://api.themoviedb.org/3/movie/369972?language=en-US&api_key=

btw: Backdrops "No Language" is best NOT language
User avatar
rednoah
The Source
Posts: 19130
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to get the correct poster from TMDB?

Post by rednoah »

SebasNights wrote: 12 Nov 2020, 15:06 For what I could test, the first one on the web (backdrop or poster), filtered by language (English in this case), seems to be the primary one. If the order on the API is the same, you could filter by language and maintain the original order? Or just take the first one in the list with that language.
backdrops are already not sorted in website order:
https://pastebin.com/JH8v6P5S

:idea: FileBot r8146 will use vote_average * vote_count instead of just vote_average for picking the one with the highest rating. The most popular artwork typically has lots of votes. So that should make things better. Plus whenever you get one you don't like, then you can go to the website to up-vote the good ones, for the benefit of all.


kim wrote: 12 Nov 2020, 15:48 the "primary" is = a moderator select it manually = not most or best votes

you can get in

Code: Select all

poster_path	"/i91mfvFcPPlaegcbOyjGgiWfZzh.jpg"
I've updated --apply cover to use that, so --apply cover and --apply artwork may now possibly end up fetching different images.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1046
Joined: 15 May 2014, 16:17

Re: How to get the correct poster from TMDB?

Post by kim »

maybe better to:

poster:
filter by "language"
check if primary is diff. then first of filtered "language"
yes = select primary
no = select first from filtered "language"

then it will be like on the website = easy to use ;)

backdrops:
"language" is bad (use only as backup) "No Language" (null or xx) is best
select first

btw:
Primary Poster

New PRIMARY Designation for Posters
User avatar
rednoah
The Source
Posts: 19130
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to get the correct poster from TMDB?

Post by rednoah »

Does the amc / htpc script have any specific selection logic for backdrops?

Does --apply artwork select different artwork compared to the scripts?

Because the htpc script code hasn't been touched in years, so I'm weary of making changes that might break things for the possibly silent majority (?) that are happy with the current behavior.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1046
Joined: 15 May 2014, 16:17

Re: How to get the correct poster from TMDB?

Post by kim »

Code: Select all

def selection = [locale.language, 'en', null].findResult{ lang -> artwork.find{ it.matches(lang) } }
https://github.com/filebot/scripts/blob ... roovy#L209

I think the null is not working my fix is

Code: Select all

it.language.toString().replace(/null/,'xx')
anyway for it to work proper you need to change to ( my way here)

Code: Select all

def artFilter = { it.findResult{ lang -> artwork.find{ it.language == lang } }?.language }

if (category == 'posters') {
preferredLang = artFilter( [locale.language, 'en', movieInfo.originalLanguage , 'xx'] )
}

if (category == 'backdrops') {
preferredLang = artFilter( ['xx', locale.language, 'en'] )
}
never tried it so...
Does --apply artwork select different artwork compared to the scripts?
can I see the source code ?

you may need to change in fetchAllMovieArtwork also

Code: Select all

def selection = ['null', 'xx', locale.language, 'en', movieInfo.originalLanguage].findResults{ lang -> artwork.findAll{ it.language.toString().matches(lang) } }.flatten().unique()
User avatar
rednoah
The Source
Posts: 19130
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to get the correct poster from TMDB?

Post by rednoah »

Can you give me a test case for a movie where we prefer the xx backdrop?



The Java code is completely different, and unfortunately not a one liner, but it boils down to sorting all the artwork and then picking the first one according to the relevanceOrder() comparator:

Code: Select all

	public static Comparator<Artwork> ratingOrder() {
		return Comparator.comparing(Artwork::getRating, reverseOrder());
	}

	public static Comparator<Artwork> languageOrder(Locale locale) {
		return Comparator.comparingInt(a -> a.language == null ? 1 : locale.getLanguage().equals(a.language) ? 0 : 2);
	}

	public static Comparator<Artwork> relevanceOrder(Locale locale) {
		Comparator<Artwork> c = languageOrder(locale);

		if (!locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) {
			c = c.thenComparing(languageOrder(Locale.ENGLISH));
		}

		return c.thenComparing(ratingOrder());
	}



:idea: There's no support for order of preferred locale. If we were to add that, then we'd have to make sure that we prefer xx/null only for backdrops, but not for everything else. Because lots of non-
English speaking users like how things work right now.


:idea: Note that Artwork.matches(null) (i.e. accept anything) always returns true. You'd have to explicitly check artwork.language == null to find artwork where the language is null specifically.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1046
Joined: 15 May 2014, 16:17

Re: How to get the correct poster from TMDB?

Post by kim »

User avatar
rednoah
The Source
Posts: 19130
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to get the correct poster from TMDB?

Post by rednoah »

This one does seem to be sorted in some sort of order again:

Code: Select all

{aspect_ratio=1.777777777777778, file_path=/wu1uilmhM4TdluKi2ytfz8gidHf.jpg, height=2160, iso_639_1=null, vote_average=5.384, vote_count=2, width=3840}
{aspect_ratio=1.777777777777778, file_path=/bt4xA9WZE9P1wiRILRFt0Zh2wmV.jpg, height=2160, iso_639_1=null, vote_average=5.246, vote_count=2, width=3840}
{aspect_ratio=1.777777777777778, file_path=/7KakIVhCsh28zNcoL3BJQjnyJMY.jpg, height=720, iso_639_1=null, vote_average=5.18, vote_count=3, width=1280}
{aspect_ratio=1.777777777777778, file_path=/hESI1Z8OMfj2xz22fAfCOnwyIXX.jpg, height=2160, iso_639_1=pt, vote_average=0.0, vote_count=0, width=3840}
{aspect_ratio=1.777777777777778, file_path=/zhCu4iJHSKBf4uAIQyaR5IQ5nhi.jpg, height=720, iso_639_1=en, vote_average=0.0, vote_count=0, width=1280}
{aspect_ratio=1.777777777777778, file_path=/5nHj5Yl44pAWb1rgPbZU01a15Bo.jpg, height=720, iso_639_1=null, vote_average=0.0, vote_count=0, width=1280}
{aspect_ratio=1.777777777777778, file_path=/jKCipHpHBbwlJO4QBKp7Ap0h2hL.jpg, height=720, iso_639_1=null, vote_average=0.0, vote_count=0, width=1280}
{aspect_ratio=1.777777777777778, file_path=/aoo0VIMD2iqt0ACP3XPnCIojy2J.jpg, height=1080, iso_639_1=fr, vote_average=0.0, vote_count=0, width=1920}
{aspect_ratio=1.777777777777778, file_path=/9qHMifmzwpp3diJde9ggoowEEsn.jpg, height=720, iso_639_1=fr, vote_average=0.0, vote_count=0, width=1280}
{aspect_ratio=1.777777777777778, file_path=/lbRZFOZIW0Ut7wcGAmDuvFPNnyp.jpg, height=2160, iso_639_1=null, vote_average=0.0, vote_count=0, width=3840}
I guess we can try with leaving the original order in tact and picking the first one that matches our language preferences (or has no language explicitly, for backdrops) and then see how that goes.


EDIT:

As far as I can tell, the API simply sorts by vote_average and then pushes the results out. So it's not the same as the website, which does some additional sorting on top of that. Based on the test case above, I'm now calculating the rating with voteAverage * voteCount * height (so that large images get priority over similarly voted smaller ones). Implemented with FileBot r8155.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1046
Joined: 15 May 2014, 16:17

Re: How to get the correct poster from TMDB?

Post by kim »

Code: Select all

<movie>
        <name>Ryan Gosling</name>
        <role>Neil Armstrong</role>
    </movie>
correct

Code: Select all

  <actor>
    <name>Ryan Gosling</name>
    <role>Neil Armstrong</role>
    <order>0</order>
    <thumb>https://image.tmdb.org/t/p/original/lyUyVARQKhGxaxy0FbPJCQRpiaW.jpg</thumb>
  </actor>
maybe this

Code: Select all

<sorttitle>First Man</sorttitle>
correct

Code: Select all

<sorttitle>First Man::2018-10-11</sorttitle>
User avatar
rednoah
The Source
Posts: 19130
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to get the correct poster from TMDB?

Post by rednoah »

Implemented with FileBot r8211.
:idea: Please read the FAQ and How to Request Help.
Post Reply