duck7000 / imdbGraphQLPHP

6 stars 0 forks source link

Advanced search = genres #41

Closed GeorgeFive closed 3 months ago

GeorgeFive commented 5 months ago

You mentioned advanced search in the caching thread.... this is one thing I would love to see from that: a list of the top X movies by genre, ie,

https://www.imdb.com/search/title/?genres=horror

GeorgeFive commented 4 months ago

Yep, that's what I'm getting:

string(8) ""Horror""

I've even tried filling out all parameters to where I know it will find something.

duck7000 commented 4 months ago

TitleSearchAdvanced , line 217 Change to this: return trim($items);

line 105 Change to this: genreConstraint: {allGenreIds: ["$inputGenres"]}

Does that make any difference?

GeorgeFive commented 4 months ago

Same exact thing with those changes. I even tried a different input, which really shouldn't matter, but who knows at this point.

    $movies = new \Imdb\TitleSearchAdvanced();
    $searchTerms = "Dead";
    $genres = "Horror";
    $results = $movies->advancedSearch($searchTerms, $genres);

Same....

duck7000 commented 4 months ago

I am out of options here..

I don't understand why it works at my end but not yours

The problem is that we cannot see (if imdb returns an error on your query) what that error might be

duck7000 commented 4 months ago

I made a test version of titleSearchAdvanced class TitleSearchAdvanced_test.tar.gz

Use all the latest git files and use this test file instead the standard titleSearchAdvanced.php read the comments inside the test file and call the function with only a search string or word

If this fails the problem is for sure at your end, what that problem might be is a big question though

GeorgeFive commented 4 months ago

Ok, this one works! We now have data. The last one is a null though...?

string(0) "" string(4) "null" string(767) "query advancedSearch{ advancedTitleSearch( first: 200, sort: {sortBy: POPULARITY sortOrder: ASC} constraints: { titleTextConstraint: {searchTerm: null} } ) { edges { node{ title { id originalTitleText { text } titleText { text } titleType { text } releaseYear { year endYear } meterRanking { currentRank } ratingsSummary { aggregateRating } plot { plotText { plainText } } primaryImage { url } } } } } }" object(stdClass)#2405 (1) { ["advancedTitleSearch"]=> object(stdClass)#2404 (1) { ["edges"]=> array(200) { [0]=> object(stdClass)#17 (1) { ["node"]=> object(stdClass)#16 (1) { ["title"]=> object(stdClass)#6 (9) { ["id"]=> string(9) "tt2356777" ["originalTitleText"]=> object(stdClass)#7 (1) { ["text"]=> string(14) "True Detective" } ["titleText"]=> object(stdClass)#8 (1) { ["text"]=> string(14) "True Detective" } ["titleType"]=> object(stdClass)#9 (1) { ["text"]=> string(9) "TV Series" } ["releaseYear"]=> object(stdClass)#10 (2) { ["year"]=> int(2014) ["endYear"]=> NULL } ["meterRanking"]=> object(stdClass)#11 (1) { ["currentRank"]=> int(1) } ["ratingsSummary"]=> object(stdClass)#12 (1) { ["aggregateRating"]=> float(8.9) } ["plot"]=> object(stdClass)#14 (1) { ["plotText"]=> object(stdClass)#13 (1) { ["plainText"]=> string(145) "Anthology series in which police investigations unearth the personal and professional secrets of those involved, both within and outside the law." } } ["primaryImage"]=> object(stdClass)#15 (1) { ["url"]=> string(125) "https://m.media-amazon.com/images/M/MV5BNTEzMzBiNGYtYThiZS00MzBjLTk5ZWItM2FmMzU3Y2RjYTVlXkEyXkFqcGdeQXVyMjkwOTAyMDU@._V1_.jpg" } } } } [1]=> object(stdClass)#29 (1) { ["node"]=> object(stdClass)#28 (1) { ["title"]=> object(stdClass)#18 (9) { ["id"]=> string(9) "tt9018736" ["originalTitleText"]=> object(stdClass)#19 (1) { ["text"]=> string(26) "Avatar: The Last Airbender" } ["titleText"]=> object(stdClass)#20 (1) { ["text"]=> string(26) "Avatar: The Last Airbender" } ["titleType"]=> object(stdClass)#21 (1) { ["text"]=> string(9) "TV Series" } ["releaseYear"]=> object(stdClass)#22 (2) { ["year"]=> int(2024) ["endYear"]=> NULL } ["meterRanking"]=> object(stdClass)#23 (1) { ["currentRank"]=> int(2) } ["ratingsSummary"]=> object(stdClass)#24 (1) { ["aggregateRating"]=> float(7.4) } ["plot"]=> object(stdClass)#26 (1) { ["plotText"]=> object(stdClass)#25 (1) { ["plainText"]=> string(137) "A young boy known as the Avatar must master the four elemental powers to save the world, and fight against an enemy bent on stopping him." } } ["primaryImage"]=> object(stdClass)#27 (1) { ["url"]=> string(125) "https://m.media-amazon.com/images/M/MV5BMTViNTY2MjMtYmUwOC00ZGYxLThjOWEtYjNjZWU3MTYwYzZmXkEyXkFqcGdeQXVyMTEzMTI1Mjk3._V1_.jpg" } } } } [2]=> object(stdClass)#41 (1) { ["node"]=> object(stdClass)#40 (1) { ["title"]=> object(stdClass)#30 (9) { ["id"]=> string(10) "tt11057302" ["originalTitleText"]=> object(stdClass)#31 (1) { ["text"]=> string(10) "Madame Web" } ["titleText"]=> object(stdClass)#32 (1) { ["text"]=> string(10) "Madame Web" } ["titleType"]=> object(stdClass)#33 (1) { ["text"]=> string(5) "Movie" } ["releaseYear"]=> object(stdClass)#34 (2) { ["year"]=> int(2024) ["endYear"]=> NULL } ["meterRanking"]=> object(stdClass)#35 (1) { ["currentRank"]=> int(1) } ["ratingsSummary"]=> object(stdClass)#36 (1) { ["aggregateRating"]=> float(3.7) } ["plot"]=> object(stdClass)#38 (1) { ["plotText"]=> object(stdClass)#37 (1) { ["plainText"]=> string(237) "Cassandra Webb is a New York metropolis paramedic who begins to demonstrate signs of clairvoyance. Forced to challenge revelations about her past, she needs to safeguard three young women from a deadly adversary who wants them destroyed." } } ["primaryImage"]=> object(stdClass)#39 (1) { ["url"]=> string(125) "https://m.media-

--snipped lots of data---

NULL

duck7000 commented 4 months ago

You called the method without any parameters.. The data you see is random and does not mean anything as there is not search term

Try to call with a search term like "day of the dead" or so If this fails the problem is in your parameter, the quotes is somehow a problem i guess

GeorgeFive commented 4 months ago

I'm not at my PC right now (work), but I did try without quotes before...

$movies = new \Imdb\TitleSearchAdvanced();
$searchTerms = "Dead";
$genres = "Horror";
$results = $movies->advancedSearch($searchTerms, $genres);

I've also tried one word strings with no quotes....

$results = $movies->advancedSearch(dead,Horror);

Will investigate further when I get home.

duck7000 commented 4 months ago

The test version only contains searchTerms nothing else.

It isn't difficult, call it like this:

$results = $movies->advancedSearch("day of the dead");

If this fails try to add the searchTerm directly in the query like this: titleTextConstraint: {searchTerm: "day of the dead"} And call the method without any parameters:

$movies = new \Imdb\TitleSearchAdvanced();
$results = $movies->advancedSearch();

If this works there must be something you do with quotes. Do you use any functions that adds quotes?

GeorgeFive commented 4 months ago

Ignore my previous few messages, I skimmed your post before getting ready for work and I was rushing. I completely botched this test, I'll admit that, haha.

Ok, and calling the test version of the script with parameters does indeed work!

string(16) "dawn of the dead" string(18) ""dawn of the dead"" string(781) "query advancedSearch{ advancedTitleSearch( first: 200, sort: {sortBy: POPULARITY sortOrder: ASC} constraints: { titleTextConstraint: {searchTerm: "dawn of the dead"} } ) { edges { node{ title { id originalTitleText { text } titleText { text } titleType { text } releaseYear { year endYear } meterRanking { currentRank } ratingsSummary { aggregateRating } plot { plotText { plainText } } primaryImage { url } } } } } }" object(stdClass)#1453 (1) { ["advancedTitleSearch"]=> object(stdClass)#1452 (1) { ["edges"]=> array(160) { [0]=> object(stdClass)#17 (1) { ["node"]=> object(stdClass)#16 (1) { ["title"]=> object(stdClass)#6 (9) { ["id"]=> string(9) "tt0363547" ["originalTitleText"]=> object(stdClass)#7 (1) { ["text"]=> string(16) "Dawn of the Dead" } ["titleText"]=> object(stdClass)#8 (1) { ["text"]=> string(16) "Dawn of the Dead" } ["titleType"]=> object(stdClass)#9 (1) { ["text"]=> string(5) "Movie" } ["releaseYear"]=> object(stdClass)#10 (2) { ["year"]=> int(2004) ["endYear"]=> NULL } ["meterRanking"]=> object(stdClass)#11 (1) { ["currentRank"]=> int(1243) } ["ratingsSummary"]=> object(stdClass)#12 (1) { ["aggregateRating"]=> float(7.3) } ["plot"]=> object(stdClass)#14 (1) { ["plotText"]=> object(stdClass)#13 (1) { ["plainText"]=> string(198) "A nurse, a policeman, a young married couple, a salesman and other survivors of a worldwide plague that is producing aggressive, flesh-eating zombies, take refuge in a mega Midwestern shopping mall." } } ["primaryImage"]=> object(stdClass)#15 (1) { ["url"]=> string(125) "https://m.media-amazon.com/images/M/MV5BN2M2ZmU2OGQtNmU5Yi00MTIyLTgwNWMtYjljMzZlYTdiNjBhXkEyXkFqcGdeQXVyNTAyODkwOQ@@._V1_.jpg" } } } } [1]=> object(stdClass)#29 (1) { ["node"]=> object(stdClass)#28 (1) { ["title"]=> object(stdClass)#18 (9) { ["id"]=> string(9) "tt0077402" ["originalTitleText"]=> object(stdClass)#19 (1) { ["text"]=> string(16) "Dawn of the Dead" } ["titleText"]=> object(stdClass)#20 (1) { ["text"]=> string(16) "Dawn of the Dead" } ["titleType"]=> object(stdClass)#21 (1) { ["text"]=> string(5) "Movie" } ["releaseYear"]=> object(stdClass)#22 (2) { ["year"]=> int(1978) ["endYear"]=> NULL } ["meterRanking"]=> object(stdClass)#23 (1) { ["currentRank"]=> int(2558) } ["ratingsSummary"]=> object(stdClass)#24 (1) { ["aggregateRating"]=> float(7.8) } ["plot"]=> object(stdClass)#26 (1) { ["plotText"]=> object(stdClass)#25 (1) { ["plainText"]=> string(165) "During an escalating zombie epidemic, two Philadelphia SWAT team members, a traffic reporter and his TV executive girlfriend seek refuge in a secluded shopping mall." } } ["primaryImage"]=> object(stdClass)#27 (1) { ["url"]=> string(125) "https://m.media-amazon.com/images/M/MV5BMzc1YTIyNjctYzhlNy00ZmYzLWI2ZWQtMzk4MmQwYzA0NGQ1XkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_.jpg" } } } } [2]=> object(stdClass)#40 (1) { ["node"]=> object(stdClass)#39 (1) { ["title"]=> object(stdClass)#30 (9) { ["id"]=> string(9) "tt3332282" ["originalTitleText"]=> object(stdClass)#31 (1) { ["text"]=> string(10) "Apocalypse" } ["titleText"]=> object(stdClass)#32 (1) { ["text"]=> string(19) "Dawning of the Dead" } ["titleType"]=> object(stdClass)#33 (1) { ["text"]=> string(5) "Movie" }

----snip------

duck7000 commented 4 months ago

Okay so if this works so should the normal version?

Call the normal version the same as above: $results = $movies->advancedSearch("day of the dead");

This should also work as the constrain is indentical

GeorgeFive commented 4 months ago

$movies = new \Imdb\TitleSearchAdvanced(); $results = $movies->advancedSearch("dawn of the dead"); TitleSearchAdvanced_test.tar.gz

string(16) "dawn of the dead" string(18) ""dawn of the dead"" string(781) "query advancedSearch{ advancedTitleSearch( first: 200, sort: {sortBy: POPULARITY sortOrder: ASC} constraints: { titleTextConstraint: {searchTerm: "dawn of the dead"} } ) { edges { node{ title { id originalTitleText { text } titleText { text } titleType { text } releaseYear { year endYear } meterRanking { currentRank } ratingsSummary { aggregateRating } plot { plotText { plainText } } primaryImage { url } } } } } }" object(stdClass)#1461 (1) { ["advancedTitleSearch"]=> object(stdClass)#1460 (1) { ["edges"]=> array(161) { [0]=> object(stdClass)#17 (1) { ["node"]=> object(stdClass)#16 (1) { ["title"]=> object(stdClass)#6 (9) { ["id"]=> string(9) "tt0363547" ["originalTitleText"]=> object(stdClass)#7 (1) { ["text"]=> string(16) "Dawn of the Dead" } ---snip---

Exact same calls on my end, did not change my script at all....

$movies = new \Imdb\TitleSearchAdvanced(); $results = $movies->advancedSearch("dawn of the dead"); Release version of titlesearchadvanced

array(0) { }

var_dump($data); object(stdClass)#5 (0) { }

I'm lost... I have no idea.

duck7000 commented 4 months ago

array(0) { }

This indicates that there is a blank array is returned so one of these checks fails:

        if ($inputReleaseDates === false) {
            // insert var_dump here
            return $results;
        }

        // check if there is at least one valid input parameter, array() otherwise
        if ($inputSearchTerm == "null" &&
            empty($inputGenres) &&
            empty($inputTypes) &&
            empty($inputCreditId) &&
            $inputReleaseDates["startDate"] == "null" &&
            $inputReleaseDates["endDate"] == "null" &&
            empty($inputCountryId) &&
            empty($inputLanguageId)
            )
        {
            // insert var_dump here
            return $results;
        }

$data is indeed empty in this case so that is correct. Strangely enough it works great at my end but not yours?

Add a var_dump($results) to the first if at the place of the comment. If that gives nothing on the screen remove it and add it to the second if

GeorgeFive commented 4 months ago

I tried the var_dump at both spots you mentioned, and both returned empty.

HOWEVER! I've figured something out. If I remove all constraints except for the searchterm, it will work.... so remove all these lines:

  genreConstraint: {allGenreIds: [$inputGenres]}
  titleTypeConstraint: {anyTitleTypeIds: [$inputTypes]}
  releaseDateConstraint: {releaseDateRange: {start: $inputReleaseDates[startDate] end: $inputReleaseDates[endDate]}}
  creditedNameConstraint: {anyNameIds: [$inputCreditId]}
  originCountryConstraint: {anyCountries: [$inputCountryId]}
  languageConstraint: {anyLanguages: [$inputLanguageId]}
  explicitContentConstraint: {explicitContentFilter: INCLUDE_ADULT}

If I change my call to

    $movies = new \Imdb\TitleSearchAdvanced();
    $results = $movies->advancedSearch("dawn of the dead", "Horror");

and remove

  titleTypeConstraint: {anyTitleTypeIds: [$inputTypes]}
  releaseDateConstraint: {releaseDateRange: {start: $inputReleaseDates[startDate] end: $inputReleaseDates[endDate]}}
  creditedNameConstraint: {anyNameIds: [$inputCreditId]}
  originCountryConstraint: {anyCountries: [$inputCountryId]}
  languageConstraint: {anyLanguages: [$inputLanguageId]}
  explicitContentConstraint: {explicitContentFilter: INCLUDE_ADULT}

it works.

So I'm thinking, maybe since I'm not calling all constraints... I add blank to the other ones:

    $results = $movies->advancedSearch("dawn of the dead", "Horror", "", "", "", "", "", "");

And get an empty array.

SO! Let's put something in for everything....

    $results = $movies->advancedSearch("dawn of the dead", "Horror", "movie", "nm0001681", "1900-01-01", "2020-01-01", "US", "en");

And still get an empty array.

duck7000 commented 4 months ago

Mmm it gets weirder and weirder

I think the problem lies in the line breaks at the constrains. In your setup apparently a line break at the constrains is a problem, that is why it works with only one constrain i guess

Do you do anything to line breaks? replace them with something etc (i'm guessing here)

What happens if you put all constrains to the same line (this would be a huge line)?

duck7000 commented 4 months ago

Like this:

titleTextConstraint: {searchTerm: $inputSearchTerm} genreConstraint: {allGenreIds: [$inputGenres]} titleTypeConstraint: {anyTitleTypeIds: [$inputTypes]} releaseDateConstraint: {releaseDateRange: {start: $inputReleaseDates[startDate] end: $inputReleaseDates[endDate]}} creditedNameConstraint: {anyNameIds: [$inputCreditId]} originCountryConstraint: {anyCountries: [$inputCountryId]} languageConstraint: {anyLanguages: [$inputLanguageId]} explicitContentConstraint: {explicitContentFilter: INCLUDE_ADULT}}

GeorgeFive commented 4 months ago

I haven't done anything with line breaks, this is straight from git. That made me think, I even tried forcing to utf-8 in my ftp program while uploading... same issues.

Putting everything in one line did not work, I tried with and without spaces between them just to check.

duck7000 commented 4 months ago

Change line 55 of TitleSearchAdvanced to this, so all parameters are in one line:

public function advancedSearch($searchTerm = '', $genres = '', $types = '', $creditId = '', $startDate = '', $endDate = '', $countryId = '', $languageId = '')

Maybe change them to 2 double quotes will help?

duck7000 commented 4 months ago

This may sound stupid but what browser are you using? I use Firefox (on Linux) and it works fine, but i never tested in Chrome

duck7000 commented 4 months ago

if it still don't work try this:

line 83 and 97 change this: return $results; to return false;

Check if there is a mention boolean: false in your browser when you call this function. If there is the problem still is in the input parameters somehow

GeorgeFive commented 4 months ago

Tried all of the above with no success. One thing I did notice, I can call with two parameters....

$results = $movies->advancedSearch("dawn of the dead", "Horror");

...and any three constraints....

  titleTextConstraint: {searchTerm: $inputSearchTerm}
  genreConstraint: {allGenreIds: [$inputGenres]}
  titleTypeConstraint: {anyTitleTypeIds: [$inputTypes]}

or even....

  titleTextConstraint: {searchTerm: $inputSearchTerm}
  genreConstraint: {allGenreIds: [$inputGenres]}
  explicitContentConstraint: {explicitContentFilter: INCLUDE_ADULT}

...and it will work. But as soon as I add any of the other constraints back, it fails. Three of them is fine, any more and it fails. I added another parameter to my $results, and I can still get it to work with three constraints... but adding one more makes it fail.

duck7000 commented 4 months ago

This is f*cking nuts..

What happens when you remove those 2 if statements:

        if ($inputReleaseDates === false) {
            // insert var_dump here
            return $results;
        }

        // check if there is at least one valid input parameter, array() otherwise
        if ($inputSearchTerm == "null" &&
            empty($inputGenres) &&
            empty($inputTypes) &&
            empty($inputCreditId) &&
            $inputReleaseDates["startDate"] == "null" &&
            $inputReleaseDates["endDate"] == "null" &&
            empty($inputCountryId) &&
            empty($inputLanguageId)
            )
        {
            // insert var_dump here
            return $results;
        }

What happens when you remove all releaseDate parts (the parameter, the check and the constrain etc)

I will be away to night

GeorgeFive commented 4 months ago

This may sound stupid but what browser are you using? I use Firefox (on Linux) and it works fine, but i never tested in Chrome

I do indeed use Chrome. Not sure how much difference that would make....?

What happens when you remove those 2 if statements:

Same, empty array.

What happens when you remove all releaseDate parts (the parameter, the check and the constrain etc)

Same. I've already tried removing chunks of code to see if one particular part was the problem, that doesn't seem to be the issue. It seems to have to do with the constraints portion of the search. I've tried removing them one at a time to see if one of them in particular was the problem, and that's not it. What the problem is, I don't have a fucking clue...

Is it possible that something in your local setup does not match up with the git repository? Maybe you forgot to commit a change somewhere?

duck7000 commented 4 months ago

Is it possible that something in your local setup does not match up with the git repository? Maybe you forgot to commit a change somewhere?

No i use the exact same file as the git version

So to conclude: with 2 parameters and 3 constrains it works Any more constrains it fails? Does it matter what those constrains are?

The complete nuts parts is that all is working fine in my test setup (i can use all constrains) This doesn't make any sense.. Here are the files i use in my test setup (Please compare the files one by one so you may find differences) testSetup.tar.gz

Chrome or Firefox should not make a difference so no i don't know if this will matter

duck7000 commented 4 months ago

if i call the function with this parameters

$imdb = new \Imdb\TitleSearchAdvanced();
$results = $imdb->advancedSearch("day of the dead", "Horror", "movie");

Results:

Array
(
    [0] => Array
        (
            [imdbid] => 0088993
            [originalTitle] => Day of the Dead
            [title] => Day of the Dead
            [year] => 1985
            [movietype] => Movie
            [rank] => 3971
            [rating] => 7.1
            [plot] => As the world is overrun by zombies, a group of scientists and military personnel sheltering in an underground bunker in Florida must determine how they should deal with the undead horde.
            [imgUrl] => https://m.media-amazon.com/images/M/MV5BNWVmMzlhZGYtMWRiOS00MGIwLTk5YTAtZGE4OTcyYjU3YzZmXkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_QL75_SY207_.jpg
        )

    [1] => Array
        (
            [imdbid] => 3053228
            [originalTitle] => Day of the Dead: Bloodline
            [title] => Day of the Dead: Bloodline
            [year] => 2017
            [movietype] => Movie
            [rank] => 
            [rating] => 3.4
            [plot] => A small group of military personnel and survivalists dwell in an underground bunker as they seek to find a cure in a world overrun by zombies.
            [imgUrl] => https://m.media-amazon.com/images/M/MV5BMjE2MTg1NDQ2MF5BMl5BanBnXkFtZTgwMDkxMzMzNDM@._V1_QL75_SY207_.jpg
        )

    [2] => Array
        (
            [imdbid] => 2366806
            [originalTitle] => The Day of the Living Dead
            [title] => The Day of the Living Dead
            [year] => 2014
            [movietype] => Movie
            [rank] => 
            [rating] => 2.3
            [plot] => For fans who love The Walking Dead, THE DAY OF THE LIVING DEAD is another great zombie origin story. Set in Hollywood 1957, a time of glitz and glamour, a time of brains and blood. This movie is full of action, suspense, gore and graphic violence. George A. Lazarus is an insurance investigator who disappears during a routine claim. His heartsick fiancee, Bethany, retraces George's steps and discovers that the employees George was investigating also all mysteriously disappeared. Now, as Beverly finds herself in the middle of a zombie apocalypse, this simple insurance fraud case may actually be the beginning of the end of the human race. The Day of the Living Dead revolves around the character of George A. Lazarus (Ray Capuana, Emerging Past), an insurance investigator who schedules routine interviews with twelve employees and owner Mammon Beelzebub (played by Churchill, writer/director The Emerging Past, Check Point) of the Deadly Sin Cigarette Company upon the receipt of a rather suspicious insurance claim. In the process, he learns that all twelve had recently been fired for being sick at the job, and then subsequently and without a trace, they disappeared. Two weeks later, with Lazarus now a missing person, his heart-sick fiancee Bethany Loomis (Natalie Victoria, Dead Head) and Chip (Kevin Eugene Franklin) undertake the task of finding him. While retracing his steps, they learn that what was initially regarded as a simple fraud investigation case may actually be the beginning of the end of the human race. Set in Hollywood in 1957.
            [imgUrl] => https://m.media-amazon.com/images/M/MV5BM2ZiZDNjOWUtNDA5NC00Y2Y5LWE5ZjItNWM3OTI3ZjM2MDhlXkEyXkFqcGdeQXVyMTQ2MDg0NA@@._V1_QL75_SY207_.jpg
        )

    [3] => Array
        (
            [imdbid] => 0475343
            [originalTitle] => Night of the Day of the Dawn of the Son of the Bride of the Return of the Revenge of the Terror of the Attack of the Evil, Mutant, Hellbound, Flesh-Eating Subhumanoid Zombified Living Dead, Part 3
            [title] => Night of the Day of the Dawn of the Son of the Bride of the Return of the Revenge of the Terror of the Attack of the Evil, Mutant, Hellbound, Flesh-Eating Subhumanoid Zombified Living Dead, Part 3
            [year] => 2005
            [movietype] => Movie
            [rank] => 
            [rating] => 4.4
            [plot] => The film makers take the movie The Brain Wouldn't Die (1962) and wiped the audio clean and dubbed it over with a new, comedic soundtrack.
            [imgUrl] => https://m.media-amazon.com/images/M/MV5BMWUyNTM5MTEtNWYwMy00YzFhLWI1N2QtYWRmMmQ4ZDU4NWE0XkEyXkFqcGdeQXVyMjE2MDU5MQ@@._V1_QL75_SY207_.jpg
        )

    [4] => Array
        (
            [imdbid] => 0923671
            [originalTitle] => The Day of the Dead
            [title] => The Day of the Dead
            [year] => 2007
            [movietype] => Movie
            [rank] => 
            [rating] => 4.3
            [plot] => Based on true facts, a gang of suburban kids is sport-killing home-less people just for fun in the streets of Chicago. One day, they decide to try a new excitement, by murdering a young Mexican working girl, assuming there would be no consequences since she was illegal. They were wrong.
            [imgUrl] => https://m.media-amazon.com/images/M/MV5BMGQxOTZlYWEtM2ZkMC00ZGMzLTk1ZmEtNDE3NDA1NTI3Mzg5XkEyXkFqcGdeQXVyMTAwMTUxNTM@._V1_QL75_SY207_.jpg
        )

    [5] => Array
        (
            [imdbid] => 2191822
            [originalTitle] => 2/11: Day of the Dead
            [title] => 2/11: Day of the Dead
            [year] => 2012
            [movietype] => Movie
            [rank] => 
            [rating] => 4.7
            [plot] => A young man is found wandering around the woods outside a town, naked and covered in blood. He turns out to be the local marshal's brother. A series of unexpected events start to happen that that'll shock the whole place.
            [imgUrl] => https://m.media-amazon.com/images/M/MV5BMTY5ODkzNTAxNl5BMl5BanBnXkFtZTgwMjc3MTkwNjE@._V1_QL75_SY207_.jpg
        )

    [6] => Array
        (
            [imdbid] => 6573718
            [originalTitle] => Day of the Dead
            [title] => Day of the Dead
            [year] => 
            [movietype] => Movie
            [rank] => 
            [rating] => 
            [plot] => 
            [imgUrl] => 
        )

)
/

Which is a exact match with the imdb advanced search page with the same parameters

So i really don't know why it in your setup don't work

duck7000 commented 4 months ago

I assume that you use the latest bootstrap.php which includes the TitleSearchAdvanced class? That must be the case otherwise you would have seen an error class not found

duck7000 commented 4 months ago

I tested the 2 comments up test case in Chromium, same result it works fine

Do you use adblockers or noscript in Chrome? php settings perhaps? memory limit, max upload size etc (i'm out of ideas so..)

GeorgeFive commented 4 months ago

I assume that you use the latest bootstrap.php

Yep. No issues with adblock or noscript, php settings are pretty standard, no memory limits.... I've tried in php 7.2 through 8.4 with no luck.

So to conclude: with 2 parameters and 3 constrains it works Any more constrains it fails? Does it matter what those constrains are?

Pretty much... I'll call with:

    $movies = new \Imdb\TitleSearchAdvanced();
    $results = $movies->advancedSearch("dawn of the dead", "Horror");

And

  titleTextConstraint: {searchTerm: $inputSearchTerm}
  genreConstraint: {allGenreIds: [$inputGenres]}
  titleTypeConstraint: {anyTitleTypeIds: [$inputTypes]}

  titleTextConstraint: {searchTerm: $inputSearchTerm}
  genreConstraint: {allGenreIds: [$inputGenres]}
  releaseDateConstraint: {releaseDateRange: {start: $inputReleaseDates[startDate] end: $inputReleaseDates[endDate]}}

  titleTextConstraint: {searchTerm: $inputSearchTerm}
  genreConstraint: {allGenreIds: [$inputGenres]}
  creditedNameConstraint: {anyNameIds: [$inputCreditId]}

  titleTextConstraint: {searchTerm: $inputSearchTerm}
  genreConstraint: {allGenreIds: [$inputGenres]}
  originCountryConstraint: {anyCountries: [$inputCountryId]}

  titleTextConstraint: {searchTerm: $inputSearchTerm}
  genreConstraint: {allGenreIds: [$inputGenres]}
  languageConstraint: {anyLanguages: [$inputLanguageId]}

  titleTextConstraint: {searchTerm: $inputSearchTerm}
  genreConstraint: {allGenreIds: [$inputGenres]}
  explicitContentConstraint: {explicitContentFilter: INCLUDE_ADULT}

Calling it as above, any of those three-constraint blocks will work. But if I add anything back to make it 4+, I get the empty array.

Your test files were pretty much the same. There was some different spacing in your titlesearchadvance, which gave me some hope, but it didn't change anything when I used it.

duck7000 commented 4 months ago

Okay so conclusion so far is that 3 constrains work, if you add a 4+ it fails Make sure there are NO spaces behind each constrain, possibly it will break the query.

That got me thinking of some sort of character limit for here doc (the part between <<<EOF and EOF) The thought would be a php version difference but you already tested that. I am using php 8.1 on Ubuntu server 22.04

https://www.phptutorial.net/php-tutorial/php-heredoc/

Try with a extra new line after EOF;

EOF;

        $data = $this->graphql->query($query, "advancedSearch");

It may not make any difference though

There are changes in behaviour prior to php 7.3 https://www.php.net/manual/en/language.types.string.php (just for info)

GeorgeFive commented 4 months ago

SOLVED! Ok, that extra line was already there, but something in that php docs got me thinking. I tried removing all extra spacing, and it now works! It doesn't look as pretty, but it now seems to be fully functional.

$query = <<<EOF query advancedSearch{ advancedTitleSearch( first: $amount, sort: {sortBy: $sortBy sortOrder: $sortOrder} constraints: { titleTextConstraint: {searchTerm: $inputSearchTerm} genreConstraint: {allGenreIds: [$inputGenres]} titleTypeConstraint: {anyTitleTypeIds: [$inputTypes]} releaseDateConstraint: {releaseDateRange: {start: $inputReleaseDates[startDate] end: $inputReleaseDates[endDate]}} creditedNameConstraint: {anyNameIds: [$inputCreditId]} originCountryConstraint: {anyCountries: [$inputCountryId]} languageConstraint: {anyLanguages: [$inputLanguageId]} explicitContentConstraint: {explicitContentFilter: INCLUDE_ADULT} } ) { edges { node{ title { id originalTitleText { text } titleText { text } titleType { text } releaseYear { year endYear } meterRanking { currentRank } ratingsSummary { aggregateRating } plot { plotText { plainText } } primaryImage { url } } } } } } EOF;

duck7000 commented 4 months ago

SOLVED! Ok, that extra line was already there

Mm that line already been there could also be the problem? Try to remove it, it might explain why it won't work (the weird part is that this extra line is NOT in the git source, neither in my files) so somehow you insert that?

Somehow in your setup the indents are interpreted as tabs (or 4 spaces) so the query breaks. Only the constrains parts seems to suffer from this, the rest has the same structure as all other methods so that can't be the problem.

But YESS we finally know why it fails, progress!!

GeorgeFive commented 4 months ago

I may indeed have entered that line break, I had been playing with this in so many different ways trying to figure out what the problem was.

I don't think it's a problem with tabs, I checked and everything is spaced (if I use tab, my text editor converts it to 8x spaces for me).

Funny, I tried removing spaces on just the constraints, and it didn't work... only when I removed spaces everywhere (as above) that it worked.

duck7000 commented 4 months ago

It almost looks like a character limit, with less characters it seems to work

And still the question remains why this is not a problem in my setup? And all other methods also work fine in your setup(and those includes the spaces as well, but not the constrains) So there is still something different in your setup, but i'm not sure what it could be.

So we got 2 choices We leaf it like it is and you have to remove the spaces by every new version? (I'm not planning to add more constrains) Or we try to investigate this problem deeper?

php.ini settings might be of influence or installed extensions ( i have mbstring installed, could be of interest??) Or rename the identifier from EOF to something completely different might help? (EOF might be wrongly interpreted as end of file?)

duck7000 commented 4 months ago

I don't think it's a problem with tabs, I checked and everything is spaced (if I use tab, my text editor converts it to 8x spaces for me).

I use 4 spaces in my editors, 8 can a problem?

Extra rules post PHP 7.3

In PHP 7.3 and later, the identifier is allowed to have whitespace before it, as long as it matches the whitespace indentation in the rest of the string. Spaces and tabs can't be mixed and the indentation of every line in the string must be identical. Extra horizontal whitespace of any type can appear immediately after the indentation whitespace except immediately before the closing identifier. I found this here, 3 answer https://stackoverflow.com/questions/7581315/php-heredoc-string-rules

duck7000 commented 4 months ago

The above could mean that the indentation is not correct in the query as there are parts that has 4 and 6 spaces? That could mean that the query as i made it is not working right, at least in your setup?

GeorgeFive commented 4 months ago

I'm actually leaning towards a character limit, for some reason. I've learned that the constraints portion is irrelevant to this, it's the chunk between edges and EOF that matter. If I remove the spacing on everything but about two of the pieces, it will work. Example, this works:

edges {
node{
title {
id
originalTitleText {
text
}
titleText {
text
}
titleType {
text
}
        releaseYear {
        year
        endYear
        }
meterRanking {
currentRank
}
          ratingsSummary {
            aggregateRating
          }
plot {
plotText {
plainText
}
}
primaryImage {
url
}
}
}
}
}
}

Now, if I put proper spacing back on, say, plot (or anything), it won't work... but then I remove the spacing on ratingssummary, it will work again. So, two things can have spacing, but nothing else. That seems to be the limit.

Why?! I have no idea... but it's not a solid "spaces are the issue" thing, I don't think.

duck7000 commented 4 months ago

Mm one step closer i guess

Try to remove primaryImage and pLot from the query (this are the largest number of characters i guess) To see if that is helping

It may be an indentation issue, take a look at this

  ) {
    edges {
      node{
        title {

edges has 4 spaces, all other have 2? So you may try to make indents equal with 2 spaces (or 4 i don't know)

GeorgeFive commented 4 months ago

Try to remove primaryImage and pLot from the query

Didn't work.

I just found that if I remove most spacing, it will work...

edges {
node{
title {
  id
  originalTitleText {
    text
  }
  titleText {
    text
  }
  titleType {
    text
  }
  releaseYear {
    year
    endYear
  }
  meterRanking {
    currentRank
  }
  ratingsSummary {
    aggregateRating
  }
  plot {
    plotText {
      plainText
    }
  }
  primaryImage {
    url
  }
}
}
}
}
}
EOF;
duck7000 commented 4 months ago

Mm total characters in query string is in this case about 1200 The longest in Title class is about 750 So a character limit of around 1000 could be?

duck7000 commented 4 months ago

What happens when you replace the query with this:

query advancedSearch{
  advancedTitleSearch(
    first: $amount, sort: {sortBy: $sortBy sortOrder: $sortOrder}
    constraints: {
      titleTextConstraint: {searchTerm: $inputSearchTerm}
      genreConstraint: {allGenreIds: [$inputGenres]}
      titleTypeConstraint: {anyTitleTypeIds: [$inputTypes]}
      releaseDateConstraint: {releaseDateRange: {start: $inputReleaseDates[startDate] end: $inputReleaseDates[endDate]}}
      creditedNameConstraint: {anyNameIds: [$inputCreditId]}
      originCountryConstraint: {anyCountries: [$inputCountryId]}
      languageConstraint: {anyLanguages: [$inputLanguageId]}
      explicitContentConstraint: {explicitContentFilter: INCLUDE_ADULT}
    }
  ) {
    edges {
      node{
        title {
          id
          originalTitleText {
            text
          }
        }
      }
    }
  }
}

Character count is 809 so below 1000, does this also work?

GeorgeFive commented 4 months ago

That does indeed work... I even got away with adding titleText back, and that worked as well.

duck7000 commented 4 months ago

Mmm character limit it is

https://stackoverflow.com/questions/812925/what-is-the-maximum-possible-length-of-a-query-string (second answer)

It might be possible that your web server (or hoster) adds that limit!

To ensure security and performance, it is recommended to set a maximum character limit of 1024 for query strings and 2048 for URLs. This helps prevent Slow HTTP Request DDOS/DOS attacks. https://www.measuringknowhow.com/understanding-the-max-length-of-a-query-string-explained/

I host my server at home and control everything myself, probably i don't have any form of limit?

Check (if you have access) the apache (or what webserver) log files if you can find anything

GeorgeFive commented 4 months ago

I do have full root access, but I'm not sure where I would even look to change this limit?

Nothing in the apache logs.

duck7000 commented 4 months ago

Then your webhoster (or the provider where your server is located) sets that limit, nothing you can do about it afaik But you may ask that provider to higher that limit? (i doubt they will as it is a security measure)

So lets check what needs to be in the query and what can be stripped out? I suggest that all constrains remain (otherwise what is the point of advanced search if there is only one or 2 options?) Inside edges we can remove what is not absolutely necessary like those

meterRanking ratingsSummary plot primaryImage

If that is not enough we begin to strip spaces until it does work How about this workflow?

GeorgeFive commented 4 months ago

Honestly, the only thing I really NEED is the imdb id. This works and looks pretty good for what I need...?

      id
      titleText {
        text
      }
      titleType {
        text
      }
      releaseYear {
        year
        endYear
      }
      primaryImage {
        url
      }
duck7000 commented 4 months ago

Okay fine I would like to add originalTitleText to your list as i added this to the normal search as well and i sometimes need this (for a dutch movie for example)

Can you test if (including my part) this works at your end? Or do we have to strip spaces as well?

GeorgeFive commented 4 months ago

Adding original back broke it, but I took out image and it now works...

    title {
      id
      originalTitleText {
        text
      }
      titleText {
        text
      }
      titleType {
        text
      }
      releaseYear {
        year
        endYear
      }
    }
duck7000 commented 4 months ago

Okay if you don't mind the image been gone it is fine by me. With image included character count is 1024, exactly the possible limit so best to keep it down al little bit With the latest adjustment at 974 so this is good but close..

We can gain some extra characters by removing spaces just to be sure, moving the whole edges to the left will do that without losing too much readability. Character count is in this case 894, perfect! And leave's some wiggle room to add another constrain (if anyone asks or needs this)

duck7000 commented 4 months ago

I'm glad we tackled this issue! I will add a comment in the wiki that this limit might occur.

One thing left: Is it better to use an array for all input parameters? Or leave it like it is?

GeorgeFive commented 4 months ago

Is it better to use an array for all input parameters

Honestly, I'd say leave it as is for simplicity sake. At this point, I'm scared to play with the code too much, haha. This has been a silly experience, I had no idea there was a character limit there. The thought never even crossed my mind, even when I was taking stuff out and seeing it work.

I don't really mind the image being gone, but I was wondering if we could build the query dynamically in case someone else wants it? We could put all of the query into a string (keeping spacing and readability). and then call it with something like...

$string = str_replace(' ', '', $string);

Removing all spacing for maximum character usage.