duck7000 / imdbGraphQLPHP

5 stars 0 forks source link

How to set locale? #36

Closed paxter closed 5 months ago

paxter commented 5 months ago

I finally had some time to review this fork if it fits into my project and I'm wondering if there is any option to set the wanted language.

A while ago IMDb started to deliver different languages depending on the browsers language header. Can't find any information about that in this project. Is this english only?

duck7000 commented 5 months ago

The short answer, yes English only

I discussed this with the other users of this version and nobody uses the language settings so i removed all of it. The data is coming from the graphql endpoint and it does not seem to care about languages so i doubt it could even work. The browsers language header has nothing to do with this, the data is not coming from a browser anymore.

duck7000 commented 5 months ago

See #33

paxter commented 5 months ago

Thanks for your reply. I have to look for another project or add that feature by myself. Different languages is an essential feature for me.

duck7000 commented 5 months ago

I doubt you can add languages to graphQL, even tboothman didn't seem to get it done. It is surely possible but i think only for pro members, we use the free version.

The only thing that seems possible, according to tboothman, is x-imdb-user-country, this changes title https://github.com/tboothman/imdbphp/blob/master/src/Imdb/GraphQL.php (from line 70)

I did add orginalTitle() so you can get that. That is the title from the original country.

And remember that the old "scraping" method in most cases doesn't work anymore, so the only solid way to get imdb data is through GraphQL

paxter commented 5 months ago

Unless IMDb delivers different languages for different browsers it has to be possible. I will do a traffic analysis of the queries later.

duck7000 commented 5 months ago

@paxter any luck so far?

paxter commented 5 months ago

Yes. First of all, the whole imdb infrastructure is a giant piece of shit. I've seen a lot of applications and infrastructures in my life and this is one of the worst.

The extra headers X-Imdb-User-Language: de-DE and X-Imdb-User-Country: DE are needed to getting plot and title in foreign languages. Looks like it's reliable and working fine. It doesn't affect genres, so all information can be queried with one single GraphQL query.

Furthermore, I intercepted the http traffic of the imdb android app and found out the app uses persisted GraphQL queries which are not reliable because of the used SHA256 hash which can be invalid in the future. Although it was interesting to see additional fields and tables of IMDB's GraphQL API I didn't see on the website or in this project.

I ended up building my own php library and built some custom GraphQL queries to reduce the number of requests. I'm not done yet (my project is quiet complex and uses more data providers than imdb).

I'm not finished yet, but if you are interested, I can post the full custom GraphQL queries I'm using later. It's nothing special. It's more mixing of fields and table names of existing queries I've found in this project. But in my case it saves a lot of http requests.

duck7000 commented 5 months ago

Yes there are far more data fields then IMDb uses on their websites, a few of them i asked the other users if they are interested, so far everybody seems happy with what is in my current version, including me.

So if i understand correctly language and country are working but only on title and plot? In the docs there are some methods in the IMDb graphql API that state that language and country are not used, some state they are used.

That problem with SHA256 is what people are using in imdbphp and is not reliable (although it seems to work at this moment)

The number of requests does not seems to be a problem as i and others didn't have any problems with my version. I didn't combine too many things to be able to use a single method if somebody wants to. For title year etc id did combine it.

Sure I'm interested in your work, especially if that involves the languages and country working as i might use that in my version (as anybody is interested, I'm probably not)

For now I'm happy to get it working so far, as you now now it is a complicated thing.

And feel free to use my work if it helps you any further, even if you use it to fix imdbphp itself. I made my own version because of the lack of interest and i wanted a version without the bloat that i don't use.