tboothman / imdbphp

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

Undefined array key 1 in Title.php preg_match #289

Closed DariusIII closed 1 year ago

DariusIII commented 1 year ago

Description

I am receiving undefined array key 1 when fetching movie information. It started happening around a week ago.

Stack trace is below:

[2022-12-22 00:01:00] NNTmux.ERROR: Undefined array key 1 {"exception":"[object] (ErrorException(code: 0): Undefined array key 1 at vendor/imdbphp/imdbphp/src/Imdb/Title.php:2956)
[stacktrace]
#0 vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(268): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 vendor/imdbphp/imdbphp/src/Imdb/Title.php(2956): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}()
#2 vendor/imdbphp/imdbphp/src/Imdb/Title.php(305): Imdb\\Title->jsonLD()
#3 Imdb\\Title->orig_title()

Movies / TV-Shows / Person

Actual movie in question is American Heart (1992): tt0103670

Type

Bug

Code

Line 2956 in version 7.3.1:

$this->jsonLD = json_decode($matches[1]);

I see that there were changes since last release, in master branch the line is actually 2960 now.

Expected Results / What do you want to do?

It should return original movie title

Actual Results / What is happening?

Error exception is thrown

DariusIII commented 1 year ago

I can add a check in my code, that is not an issue, but i would like to have it fixed here too.

Edit: Now that i look in my code, i do have checks, issue is that phpimdb fails before my check.

tboothman commented 1 year ago

Closing this because I don't get this problem with the particular title. I get the expected null return. Other methods that take data from the json+ld work (e.g. keywords) on this title too.

If you're still having the problem take a look in your cached copy of the page (cache/title.tt0103670) and see if it has <script type="application/ld+json"> in it or not. You could also look at the html on https://www.imdb.com/title/tt0103670/ too for the same thing.