tboothman / imdbphp

PHP library for retrieving film and tv information from IMDb
251 stars 84 forks source link

Some kind of documentation on GraphQL? #309

Closed duck7000 closed 1 year ago

duck7000 commented 1 year ago

Can somebody explain a little bit how the GraphQL works?

Especially how do you find out what kind of query is needed to convert a method to use GraphQL? i see some kind of the same structure in the methods that are already converted but where comes $id from? And how do i find out the correct names to use?

query AlsoKnow(\$id: ID!) {
  title(id: \$id) {
    akas(first: 9999) {
      edges {
        node {

More and more imdb pages are converted to a new layout where you can't get all info anymore so i'm thinking to try to convert methods to GraphQL. Just for the record this is not just for my own version, i will share if i can make it work! @tboothman has done most of the ground work so if i can contribute to make this work i will as it will benefit us all.

jetrosuni commented 1 year ago

You can use e.g. Chrome DevTools and extensions like GraphQL Network Inspector ( https://chrome.google.com/webstore/detail/graphql-network-inspector/ndlbedplllcgconngcnfmkadhokfaaln ) to study what's happening behind the scenes while browsing IMDb pages. This way you can find out the correct query and field names.

$id gets defined when graphql->query() is called (3rd argument), e.g.: $data = $this->graphql->query($query, "AlsoKnow", ["id" => "tt$this->imdbID"]);

duck7000 commented 1 year ago

@jetrosuni Thanks for the info! much appreciated! I use Firefox but the same extension is available for Firefox too.

Let see if i can make something work

duck7000 commented 1 year ago

That extension is great, you can exactly see the structure needed to make the query Thanks again @jetrosuni

duck7000 commented 1 year ago

@all

I have successfully converted a few methods to GraphQL: Locations Soundtrack Quotes

Feel free to use them here in imdbphp but remember that my personal version differs from this version so you can't copy the methods directly. Adjustments are needed. They are basically the same but might fetch more data or in different format.

I have no more interest in making pull requests for those methods anymore, let's say there is a reason that i use my own version now .

This way i can still contribute to this version, i hope that somebody will pick this up further so everybody can benefit from it.

I will continue to convert other methods as well as i need them in my version.

Thomasdouscha commented 1 year ago

It is a pity that you are not interested of Person Class like this.

duck7000 @.***>, 22 Haz 2023 Per, 19:49 tarihinde şunu yazdı:

Does anyone know how to get the markdown below the name field?

For example seasons() the name is series according to grapQL but the markdown below is not available so it is almost impossible to get arround. I did find a few methods by guessing and studying other methods but there are a few that are impossible: Like creator, country, languages and seasons

— Reply to this email directly, view it on GitHub https://github.com/tboothman/imdbphp/issues/309#issuecomment-1603002002, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKPFI3CUSDYON4SQPY3KRMDXMRZQNANCNFSM6AAAAAAZGGEYKE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

duck7000 commented 1 year ago

Well personally i have no interest but i might try to get that info as well. But only after i'm done working on my own version and no guarantees. It is hard work to find out how GraphQL works, it is a learning process, sometimes by trial and error..

Nobody else seems to do this work or is not capable off, and to be honest I'm doing this because my version is not getting all the data anymore. I first settled for no AKA but now about half the methods don't work anymore so i kind of have to. And because @tboothman did all the groundwork it is for me easier to pick up, although it is still a big learning curve..

I will not make any pull requests myself, so if i ever going to try you or somebody else must do the work to get it merged, so be prepared for that.