Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add locale for each request #3

Closed
modmax opened this issue Aug 11, 2015 · 6 comments
Closed

Add locale for each request #3

modmax opened this issue Aug 11, 2015 · 6 comments

Comments

@modmax
Copy link

modmax commented Aug 11, 2015

For each request a common locale should be set; if not set, then the default locale from ImdbApi should be used.

Reason: It makes sense to request some values without locale or with english locale.

@Omertron
Copy link
Owner

Not sure what you mean, can you explain?

@modmax
Copy link
Author

modmax commented Nov 12, 2015

If you call ImdbApi.setLocale(Locale) then the locale will be passed to ApiBuilder.setLocale(Locale).
Due the fact, that ApiBuilder is a static class and has a static reference of "ApiBuilder.imdbLocale".

This is fine in single threade environments where every request wants the same locale.
But if you have multiple threads and some of them wants to use a different Locale then you have a problem; cause then you must synchronize over all Imdb-Api-Calls and set the locale, so that each thread can use it's own locale.

The static reference can be there; as default, But then there should be the possibilit to give a different locale per request. The same is done in TheTVApi and TheMovieDBApi where you pass the language for every request instead of setting a static reference for language in those APIs.

I came to this, cause the ImdbApi does not deliver the same results for different locales; cause some values are localized. Let's regard the cast list: if I use Locale.US everything is fine, but for Locale the role is localized, so that you "(uncredited)" with Locale.US is not the same than with Locale.DE cause the additional values of roles are localized. That makes it very hard to decide for multiple languages if a actor is uncredited or not .. as example.
Therefore I use Locale.US for cast call and for the rest Locale.DE. But due multi-threading I had
to synchromnize the calls, cause I have to set the static locale before every request to have the expected result when multiple threads are used.
Perhaps it's clearer when you have a close look into the "ImbApiWrapper" class in the YAMJ3 project.

@modmax
Copy link
Author

modmax commented Nov 12, 2015

Furtheron I investigated that the API does not return all informations from the web page.
For example the parental guide is missing in the API;
also the API does not return the Top250 info for a movie; and sometime not the biography of a person.
So in YAMJ3 I needed to do some website calls in addition to the API calls to get all informations I want .. :-)

@modmax
Copy link
Author

modmax commented Nov 12, 2015

Just another thing:
Call "imdbApi.setLocale(Locale.US) in the ImdbApiTest constructor.
Otherwise the default locale (for me DE) will be used and for that country the parentalguid does not work ...

@Omertron
Copy link
Owner

You have to remember that this is an "undocumented" API and that most of this is just guess work as to what does and doesn't work in terms of data.

I will refactor to make the locale a per-method call.

@modmax
Copy link
Author

modmax commented Nov 12, 2015

I know ... :-) ... Much better, that you have "documented" somehow ... :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants