duck7000 / imdbGraphQLPHP

7 stars 0 forks source link

imdb rating add advanced search #72

Closed lunoxis closed 2 weeks ago

lunoxis commented 1 month ago

Hi, how can I add imdb rating filter to advanced search?

duck7000 commented 1 month ago

Mm that is a good question

Do you specifically need to filter on rating? I mean you can sort the results by USER_RATING, MY_RATING or MY_RATING_DATE (see config options)

I'll look in to this

duck7000 commented 1 month ago

If you do need it there is this constrain to be used:

userRatingsConstraint Match titles based on their star rating (this might be what you are looking for) There are 2 options within this constrain, one for user rating and one for imdb star rating

It will be like this: (for imdb star rating) userRatingsConstraint: {aggregateRatingRange: {min: 1.0 max: 9.9}} // it needs to be float Not sure about the range, could be 0.0 until 10.0

you will have to add an extra input parameter and will need to check the inputted values to be float and within range though.

I might add it but TitleSearchAdvanced is already a massive method with a very large query and some users have problems with large request at their hosters (due security measures)

lunoxis commented 1 month ago

Thank you very much, this is exactly what I was looking for

Can I request new features?

For example, showing the top 250 movies https://www.imdb.com/chart/top/?ref_=nv_mv_250

or display all the photos of a movie https://m.imdb.com/title/tt2911666/mediaviewer/rm941766144?ref_=tt_ov_mi_sm

Show the latest trailer https://m.imdb.com/trailers/?ref_=hm_hp_sm

Show collection movies episode johnwick1,2,3 ...

browse buy gener https://m.imdb.com/feature/genre/?ref_=nv_ch_gr

lunoxis commented 1 month ago

How can I see all the features like you?

duck7000 commented 1 month ago

Wow.. yes you can request new features but please do so in new issues so it is in separate ones to keep the oversight. I only add new features if there is a common interest/benefit.

So you want top250 movie list, there is a Calendar Class which gets the upcoming new releases, you mean something like that?

Glad to help you out! If you want to know how GraphQL works... be aware that it is a lot, i mean a LOT. It took me months to figure it all out Tboothman has described some in this thread https://github.com/tboothman/imdbphp/issues/291 (near the bottom)

duck7000 commented 1 month ago

There is a photo method in Title class though? It won't fetch all photos but the first 12. I mean, all photo's..? that is sometimes thousands!

I don't see much potential in collection movies episodes or browse by genre if i'm honest

The top250 movie list i do see potential, so i'll see what i can come up with, but i don't have much time due a medical issue in the family

lunoxis commented 1 month ago

I mean the information on this page top 250 movie : https://www.imdb.com/chart/top/?ref_=nv_mv_250

How can we benefit from it?

duck7000 commented 1 month ago

I mean the information on this page top 250 movie : https://www.imdb.com/chart/top/?ref_=nv_mv_250

How can we benefit from it?

I will try to add this, it will be as a separate class just like Calendar

lunoxis commented 1 month ago

tanks :)

GeorgeFive commented 1 month ago

This is a little function I wrote using this library, it will get the top 200 movies from every genre and you can then store the list in your database or display it ("do stuff here").

        $genres = array("Action", "Adult", "Adventure", "Animation", "Comedy", "Crime", "Documentary", "Drama", "Family", "Fantasy", "History", "Horror", "Music", "Musical", "Mystery", "Romance", "Sci-Fi", "Sport", "Thriller", "War", "Western");

    foreach ($genres as $genre) {
        $movies = new \Imdb\TitleSearchAdvanced();
        $results = $movies->advancedSearch("", $genre);

      $i=1;
      foreach ($results as $res) {
        $mid = $res['imdbid'];
        $title = $res['title'];
        $year = $res['year'];
        $type = $res['movietype'];

//do your stuff here

        $i++;
      }
    }
duck7000 commented 1 month ago

@GeorgeFive That also looks interesting, this is a nice example of how to use the advancedSearch() method. advancedSearch() is very complex but for a reason just like this

GeorgeFive commented 1 month ago

I did cut out my query, but I save the ranking with $i. All sorts of fun stuff you can do with this!

duck7000 commented 1 month ago

This is a little function I wrote using this library, it will get the top 200 movies from every genre and you can then store the list in your database or display it ("do stuff here").

        $genres = array("Action", "Adult", "Adventure", "Animation", "Comedy", "Crime", "Documentary", "Drama", "Family", "Fantasy", "History", "Horror", "Music", "Musical", "Mystery", "Romance", "Sci-Fi", "Sport", "Thriller", "War", "Western");

    foreach ($genres as $genre) {
        $movies = new \Imdb\TitleSearchAdvanced();
        $results = $movies->advancedSearch("", $genre);

      $i=1;
      foreach ($results as $res) {
        $mid = $res['imdbid'];
        $title = $res['title'];
        $year = $res['year'];
        $type = $res['movietype'];

//do your stuff here

        $i++;
      }
    }

I think that it is not needed to do the class initiate inside the foreach? If you do that outside the foreach you can still use the methods from the class inside the foreach. This will save a lot of unnecessary new class instances. Just a thought!

GeorgeFive commented 1 month ago

You're right on that... I noticed it when I was copying it to here, but I thought there had to have been a reason I did it like that, haha. Nope, moving that out works just as well!

duck7000 commented 1 month ago

I am working on the top250 list, i manged to get the query so the hard thinking part is done

This can also include a lot of other type lists:

BOTTOM_100 Overall IMDb Bottom 100 Feature List

TOP_50_BENGALI Top 50 Bengali Feature List

TOP_50_MALAYALAM Top 50 Malayalam Feature List

TOP_50_TAMIL Top 50 Tamil Feature List

TOP_50_TELUGU Top 50 Telugu Feature List

TOP_250 Overall IMDb Top 250 Feature List

TOP_250_ENGLISH Top 250 English Feature List

TOP_250_INDIA Top 250 Indian Feature List

TOP_250_TV Overall IMDb Top 250 TV List

Those types will be usable through a parameter, default will be TOP_250 (for the movie list)

Just a update

duck7000 commented 1 month ago

The top250 list method is done.

I added a new class Chart with top250List() method It can list the above types through a parameter and has a parameter for thumbnail or full image url

Al info is in the corresponding wiki page

Let me know what you think!

duck7000 commented 1 month ago

On the imdb chart page at the right there are more lists to get like most popular movies etc Let me know if this is also of any interest?

GeorgeFive commented 1 month ago

I'm not totally sure if I'll be using this, but it's pretty cool to have. My main interest was with the currently popular stuff by genre, which already works pretty well for my uses.

duck7000 commented 1 month ago

Most popular is available but not per genre so for that keep using your own method with advancedSearch.

for other most popular i can add a new class if that is of interest, let me know.

@GeorgeFive, @lunoxis do you want rating added to advanced search or is this too nice for common interest? It will add another constrain so the query will be longer, i'm not sure if this will be a problem?

duck7000 commented 1 month ago

@GeorgeFive Mm i must rephrase that. Most popular by genre IS available, but the outcome would be the same as you already done with advanced search.

If you still want this i will try to add it, as a separate class

GeorgeFive commented 1 month ago

Hmmm.... well, if you brought it over, I might use it just to make things a little easier. If not, I still have advanced to fall back on.

So, up to you!

duck7000 commented 1 month ago

Okay i'm going to try

duck7000 commented 1 month ago

Mm i tried but this isn't working like i thought

Only thing possible is browse by genre which leads to... right, interests! which i can not find in the API

So sorry but this is a dead end

GeorgeFive commented 1 month ago

It may be a case of gradual rollout with the interests... like I said, I'd almost guarantee that they will replace genres eventually, but when.....??

duck7000 commented 2 weeks ago

As @lunoxis never responded back to this issue i'm closing this one as implanted and complete