duck7000 / imdbGraphQLPHP

5 stars 0 forks source link

comingSoon method #25

Closed duck7000 closed 8 months ago

duck7000 commented 9 months ago

I'm currently working on this method.

@Thomasdouscha asked/discussed this on imdbphp and i did made a new class for it there. I never found a solution for this with GraphQL until now! I've got almost the query complete, including title, IMDbID, release date, genre, stars. primary image is in progress.

A few points would be: 1 The primary image is thumb only i guess? Unless someone need a full image of course, let me know if you do.

2 Currently i use a date span of today date until the same date next year (so from 2023-10-01 until 2024-10-01), this will be a php variable based on date() and can be anything you like. A full year seems enough and it will never return more than 100 titles

3 There is a limit of 100, so no more titles are ever returned.

4 comingSoonType this can be MOVIE, TV or TV_EPISODE (this will be method parameter?)

5 regionOverride this way you can override the default "US" (this will be method parameter?)

6 sort this can be POPULARITY of RELEASE_DATE, currently i use RELEASE_DATE but this can also be a method parameter?

7 this will return data for "US" no matter what x-imdb-user-country value is passed in.

All those method parameters can also be in the config file, so you can set default values? I don't really know if that is handy or not so let me know your thoughts.

I'm not sure how to name this method, comingSoon() seems right to me?

The rest of the method and the new class is the next project. (currently partial done)

I'm not sure if someone will use this method (including me i guess) but it seems right to include it no i know how it works

@georgeFive @jcvignoli @Thomasdouscha Do you have any thoughts about this?

jcvignoli commented 9 months ago

Just to understand: would be a list of results retrieving data from https://www.imdb.com/calendar/? I have no opinion, as for now I would not implement such function, unless I get a requet from users. But my two cents is make sure there is consistent with library; pictures should be offerted in both thumbs and posters. I guess this is important for some users. Good luck!

duck7000 commented 9 months ago

@jcvignoli Yes calendar is what i meant, i did found out how this works with GraphQL so i will include it anyway. I made the calendar class in imdbphp on request so i thought about it to include it here if i did found out how it works. It is a separate class so it is up to the user if it is used or not, it won't interfere with the other classes

Consistency is for sure important so i will include thumb and poster as well, thanks for the feedback!

GeorgeFive commented 9 months ago

One thing that would be cool with this, is if you could set a custom start date. Not to go too far back or anything, but like... if you look at IMDb's calendar on a Saturday, you can't see the big new releases that started on Friday. Think of it as "brand new, just came out today and yesterday, and coming soon" combined. I'm not sure if this is possible with the data that they provide, though....?

Also, again, I'm not sure if this is possible due to the data they provide, but does this show the movies off of their calendar page, or could it be designed to show ALL upcoming movies? IMDb handpicks the movies that show up on there, that does not reflect all movies that are actually releasing soon.

ie, https://www.imdb.com/title/tt14145436/releaseinfo/ releases on October 6, but is not shown on the calendar.

Still, this will be cool to have, even if neither of these can be addressed. Thanks!

duck7000 commented 9 months ago

Custom start and end date is absolute possible, it can be anything you want, so yes this can be a date in the past. As far as i have seen on imdb calendar page they use a date span of one year, starting from today and sort them by date. We can only get 100 while imdb can get all of them.

@GeorgeFive can you give me a exact example of what you mean? Maybe i can add 2 method parameters for the startDate and FutureDate. Those dates have to be in iso8601 format like this: YYYY-M-D

I think that imdb uses their disablePopularityFilter set to false so only popular movies show up in the list. I have set this to true so it will return all movies within the date span (limited to 100)

Here are all query arguments that are possible and set to what i think is usable, explanation is in the first post:

  first: 9999 (this will be limited to 100)
  comingSoonType: MOVIE
  disablePopularityFilter: true
  regionOverride: "US"
  releasingOnOrAfter: "$startDate"
  releasingOnOrBefore: "$futureDate"
  sort: {sortBy: RELEASE_DATE, sortOrder: ASC})
GeorgeFive commented 9 months ago

What I was thinking is pretty well covered there... I, personally, would set startdate to something like today's date, minus 2-3 days. So, if you looked at it today, you would see the stuff that just released in theaters Friday as well as the stuff that is coming soon.

I did not know about the popularityfilter.... that makes sense. Yeah, I would definitely disable that for my own needs.

Perhaps it's time to make a config file for user settings? Stuff like this, so that we don't have to revert our settings when downloading new releases?

duck7000 commented 9 months ago

@GeorgeFive okay i understand what you want. So would you like startDate and FutureDate in the config file? or in a separate config file for user settings? That will make things complicated and i don't want to go that route. You can save the config file and use it in a new release (you do need to check if there are differences though) Or should i set startDate at today minus 3 days without a config or parameter? For now i will set it fixed to today minus 3 days. FutureDate one year ahead also fixed.

disablePopularityFilter: true will stay disabled, i don't think this will need a setting in config file.

regionOverride: "US" this will be a config file setting? comingSoonType: MOVIE this will be a config file setting? Or is MOVIE the only thing that is useful?

So the main questions are do we want method parameters or settings in the config file? All other methods have (if needed) method parameters so for consistency we should go that route. Config settings is a better option as all settings will be in a fixed place but maybe that is something for later on. And with method parameters the user has control in his/her project how to use the method without worrying about config settings, so i think this is the best route to go.

GeorgeFive commented 9 months ago

With the config file, I'm thinking long term on the class. Let's say you updated Title today with a bug fix or something. In a perfect world, I could download the latest version of the file, overwrite my local copy, and wahlah.... that's it. However, if I have checked any config settings in my copy, I have to remember what's different and go through and reapply those changes.

Right now, this isn't so much of an issue, as I only have a few things modified... but over time, with new releases and new features and new things to tinker with, these changes may add up.

I've thought this for a while, but this seems to be a number of new options which there's no real "right" way to do, and the user will definitely want to tweak things. Example, I would only want movies from the calendar, but someone else may want tv episodes as well. So, if movies only is the default, that user will need to update their version with every new release. Same with startdate.... minus three days is perfect for me, but some may want it to mirror imdb's way of doing it.

duck7000 commented 9 months ago

So method parameters overcomes this problem instead of config options. With method parameters you only have to set that once in your application. you can call this method with different parameters or you can change the default parameters in the method, but this requires to change it again by new releases.

And to be clear the setting comingSoonType is only one of those 3, no combinations possible.

I will make it method parameters then, but the startDate i'm not sure jet as they have to be set by php. I can add startDate override parameter so you can alter this date with days plus or minus. futurDate will be fixed one year ahead of startDate

Agree?

GeorgeFive commented 9 months ago

Ok, I completely read your previous comment wrong, I see what you mean now.... just got off work and it's been a long night, haha. Yeah, that will be totally fine.

Everything sounds good to me! Out of curiosity, with disablePopularityFilter set to true, how many movies returns for, say, October 6? The site is showing 12 releases, I'm wondering how many there actually are and how this will affect usage.

duck7000 commented 9 months ago

Everything sounds good to me! Out of curiosity, with disablePopularityFilter set to true, how many movies returns for, say, October 6? The site is showing 12 releases, I'm wondering how many there actually are and how this will affect usage.

Well this made a huge difference, with the filter set there are far less results. I notice that even the docs says there is a limit of 100 with disablePopulairityFilter to true i got (today) 368 results so maybe that limit is set only for disablePopulairityFilter to false?

For now i made this also a method parameter so you can use it as you want.

I'm getting close to publish

duck7000 commented 9 months ago

It is published now

So check it out if you like and let met know if there are issues I tried to make things clear in the doc block, if there are any inconsistencies let me know

It works the same as calling the title class, change Title to Calendar and call comingSoon()

GeorgeFive commented 9 months ago

I'm assuming that with the filter set, we get what is shown on IMDb's own calendar page... correct?

Any chance you could do a quick copy+paste of what is returned with the filter off? Again, curiosity, I'm wondering what kind of data is being returned by them.

Edit - I see you just published it..... nice, I'll take a look at it tomorrow when I get off work.

duck7000 commented 9 months ago

filter set to false means enable the filter and the results are like on imdb calendar page filter set to true means disable the filter and all results will be included

Always hard to understand what it actually mean hah (me included as i have read this about 10 times)

Try it yourself and play with the parameters :)

duck7000 commented 9 months ago

I made a wiki page with more explaining about all parameters and what those do https://github.com/duck7000/imdbphp6/wiki/Calendar-Class

duck7000 commented 9 months ago

@paxter Maybe this thread is interested for you as well?

duck7000 commented 9 months ago

if needed i can make sort also a method parameter? Possible values: POPULARITY or RELEASE_DATE set for now: RELEASE_DATE

GeorgeFive commented 9 months ago

I've noticed on their search page, it seems to be sorted by release date asc, popularity desc. Is that how the class works if you sort by date?

duck7000 commented 9 months ago

Well on their page they sort by blocks of release dates, this is done after the GraphQL api call i guess.

In the GraphQL api call i can only sort on above values, so the output is sorted on popularity or release date

Sort has in the api call 2 options: sortBy (that is the above sort) and sortOrder ASC or DESC

Like this in the GraphQL api query: sort: {sortBy: RELEASE_DATE, sortOrder: ASC})

I can add both sort options as method parameters?

GeorgeFive commented 9 months ago

Playing around with this for myself before I ask any more questions, hah. I've noticed it does return some empty results with invalid imdb ids, ie


    ["title"]=>
    string(0) ""
    ["imdbid"]=>
    string(8) "18990260"
    ["releaseDate"]=>
    array(3) {
      ["day"]=>
      NULL
      ["mon"]=>
      NULL
      ["year"]=>
      NULL
    }
    ["genres"]=>
    array(0) {
    }
    ["cast"]=>
    array(0) {
    }
    ["imgUrl"]=>
    string(0) ""
  }```

I could handle these in my own application, but not sure why they are returning to begin with...?
duck7000 commented 9 months ago

Mm I think they are occurring in the output array because there is a IMDbID but the rest of the info is not available jet

What can i do? Skip the complete title if title == ''? (best option i guess) Skip the complete title if imdbid == number and title == ''?

duck7000 commented 9 months ago

i just uploaded a fix Added a check if title == '' and skip this one Best option i think, no point to go any further if there is no title, probably there is nothing else.

Thanks for testing!

GeorgeFive commented 9 months ago

Looking good! Not seeing any other issues, and seems to be working nicely. Awesome!

duck7000 commented 9 months ago

nice!

Do you want sort as method parameters as well or are the default settings sufficient?

paxter commented 9 months ago

Thanks for mention me @duck7000. Didn't notice this new project. Looks awesome so far and uses the new GraphQL imdb api. That should be much more reliable than the old parsing stuff I guess.

Also nice that you are still support PHP 5.6. Looks like this lib could replace the old, a little bit bloated (no offense), imdbphp lib. I will test it later and checking if possible to use this new lib as replacement. :)

duck7000 commented 9 months ago

Thanks for mention me @duck7000. Didn't notice this new project. Looks awesome so far and uses the new GraphQL imdb api. That should be much more reliable than the old parsing stuff I guess.

Also nice that you are still support PHP 5.6. Looks like this lib could replace the old, a little bit bloated (no offense), imdbphp lib. I will test it later and checking if possible to use this new lib as replacement. :)

Glad to let you know but remember this lib is not a fork or clone of imdbphp, although much is the same there are differences like different method names, different method outputs, new methods not included in imdbphp (like principalCredits() and removed methods. It does include Person, Title and now Calendar classes but it has no logger, cache or any other stuff that i didn't absolutely needed. So in a way i "debloated" imdphp in too imdbphp6 a lot.

So if you want to use it, use it like it is and don't mix imdbphp with imdbphp6

If you find something missing, odd, different etc. let me know as i have altered my original version already to make other users happy as well.

All methods are explained in my wiki pages so if you read them there shouldn't be too much surprises

paxter commented 9 months ago

Glad to let you know but remember this lib is not a fork or clone of imdbphp, although much is the same there are differences like different method names, different method outputs, new methods not included in imdbphp (like principalCredits() and removed methods. It does include Person, Title and now Calendar classes but it has no logger, cache or any other stuff that i didn't absolutely needed. So in a way i "debloated" imdphp in too imdbphp6 a lot.

Yeah, I see. That is exactly what I need. My project only uses Person and Title atm. :) I have to rework the media stuff of my project in the next months, so this comes at the right time. :)

If you find something missing, odd, different etc. let me know as i have altered my original version already to make other users happy as well.

That's for sure. ;)

All methods are explained in my wiki pages so if you read them there shouldn't be too much surprises

Yes, I see. I already checked the wiki. Looks nice.

Thanks again for your work on this project. Looks very promising!

duck7000 commented 9 months ago

@paxter welcome aboard:)

For the record i'm not a professional programmer, just a hobby coder, but i think you already know that. And to be honest if @tboothman did not make all the ground work in imdbphp i wasn't able to figure out how GraphQL works so credits to him