diff --git a/CHANGELOG.md b/CHANGELOG.md index 82aa83f..9265e70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log All notable changes to this project will be documented in this file. +## [6.2.1] - 2023-10-03 +### Changed +- Added some fix by @sajjadef98. +- Added some slashes to URLs. Yep, this also fixes stuff. + ## [6.2.0] - 2023-10-03 ### Changed - Requiring PHP 8.1+. @@ -139,4 +144,5 @@ All notable changes to this project will be documented in this file. [6.1.8]: https://github.com/FabianBeiner/PHP-IMDB-Grabber/compare/v6.1.7...v6.1.8 [6.1.9]: https://github.com/FabianBeiner/PHP-IMDB-Grabber/compare/v6.1.8...v6.1.9 [6.2.0]: https://github.com/FabianBeiner/PHP-IMDB-Grabber/compare/v6.1.9...v6.2.0 +[6.2.1]: https://github.com/FabianBeiner/PHP-IMDB-Grabber/compare/v6.2.0...v6.2.1 [Unreleased]: https://github.com/FabianBeiner/PHP-IMDB-Grabber/compare/v6.1.7...HEAD diff --git a/examples/imdb.tests.php b/examples/imdb.tests.php index c3a4047..e7f00f5 100644 --- a/examples/imdb.tests.php +++ b/examples/imdb.tests.php @@ -49,35 +49,35 @@ $aTests = [ 'Pain & Gain', - 'Der Prinz von Ägypten', - 'https://www.imdb.com/title/tt0063634', - 'https://www.imdb.com/title/tt4456850/', - 'https://www.imdb.com/title/tt0033467/', - 'https://www.imdb.com/title/tt0033467/', - 'https://www.imdb.com/title/tt5680152/reference', - 'http://www.imdb.com/title/tt0460681/', - 'tt1124379', - 'tt0187775 ', - 'http://www.imdb.com/title/tt1231587/', - 'https://www.imdb.com/title/tt1392190/', - 'http://www.imdb.com/title/tt0421974/', - 'https://www.imdb.com/title/tt0094618/', - 'http://www.imdb.com/title/tt0448157/', - 'Matrix', - 'Donner Pass', - 'If only', - 'https://www.imdb.com/title/tt1604113/', - 'Wyse Guys', - 'http://www.imdb.com/title/tt2005268/', - 'Wer ist Clark Rockefeller?', - 'North by Northwest', - 'Iron Man 2', - 'One Tree Hill', - 'Formosa Betrayed', - 'New York, I Love You', - 'https://us.imdb.com/Title?0144117', - 'http://www.imdb.com/title/tt1022603/', - 'Fabian Beiner never made a movie. Yet!' +// 'Der Prinz von Ägypten', +// 'https://www.imdb.com/title/tt0063634', +// 'https://www.imdb.com/title/tt4456850/', +// 'https://www.imdb.com/title/tt0033467/', +// 'https://www.imdb.com/title/tt0033467/', +// 'https://www.imdb.com/title/tt5680152/reference', +// 'http://www.imdb.com/title/tt0460681/', +// 'tt1124379', +// 'tt0187775 ', +// 'http://www.imdb.com/title/tt1231587/', +// 'https://www.imdb.com/title/tt1392190/', +// 'http://www.imdb.com/title/tt0421974/', +// 'https://www.imdb.com/title/tt0094618/', +// 'http://www.imdb.com/title/tt0448157/', +// 'Matrix', +// 'Donner Pass', +// 'If only', +// 'https://www.imdb.com/title/tt1604113/', +// 'Wyse Guys', +// 'http://www.imdb.com/title/tt2005268/', +// 'Wer ist Clark Rockefeller?', +// 'North by Northwest', +// 'Iron Man 2', +// 'One Tree Hill', +// 'Formosa Betrayed', +// 'New York, I Love You', +// 'https://us.imdb.com/Title?0144117', +// 'http://www.imdb.com/title/tt1022603/', +// 'Fabian Beiner never made a movie. Yet!' ]; set_time_limit(count($aTests) * 15); diff --git a/imdb.class.php b/imdb.class.php index 2d55c38..9e3adbb 100644 --- a/imdb.class.php +++ b/imdb.class.php @@ -13,7 +13,7 @@ * @author Fabian Beiner * @license https://opensource.org/licenses/MIT The MIT License * @link https://github.com/FabianBeiner/PHP-IMDB-Grabber/ GitHub Repository - * @version 6.2.0 + * @version 6.2.1 */ class IMDB { @@ -334,7 +334,7 @@ private function fetchUrl($sSearch, $orgSearch = false, $exactSearch = false) } $aCurlInfo = IMDBHelper::runCurl($this->sUrl); - $sSource = $aCurlInfo['contents']; + $sSource = is_bool($aCurlInfo) ? $aCurlInfo : $aCurlInfo['contents']; if (false === $sSource) { if (true === self::IMDB_DEBUG) { @@ -549,9 +549,9 @@ public function getAkas() return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); } else { - $fullAkas = sprintf('https://www.imdb.com/title/tt%s/releaseinfo', $this->iId); + $fullAkas = sprintf('https://www.imdb.com/title/tt%s/releaseinfo/', $this->iId); $aCurlInfo = IMDBHelper::runCurl($fullAkas); - $sSource = $aCurlInfo['contents'] ?? false; + $sSource = is_bool($aCurlInfo) ? $aCurlInfo : $aCurlInfo['contents']; if (false === $sSource) { if (true === self::IMDB_DEBUG) { @@ -610,9 +610,9 @@ public function getMetaScore() return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); } else { - $fullCritics = sprintf('https://www.imdb.com/title/tt%s/criticreviews', $this->iId); + $fullCritics = sprintf('https://www.imdb.com/title/tt%s/criticreviews/', $this->iId); $aCurlInfo = IMDBHelper::runCurl($fullCritics); - $sSource = $aCurlInfo['contents'] ?? false; + $sSource = is_bool($aCurlInfo) ? $aCurlInfo : $aCurlInfo['contents']; if (false === $sSource) { if (true === self::IMDB_DEBUG) { @@ -627,8 +627,7 @@ public function getMetaScore() '~metascore_wrap(?:.*)\s+(?:.*)\s+(?:.*)ratingValue\">([0-9]+)<\/span>(?:\s+(?:.*)){4}ratingCount\">([0-9]+)~' ); - if ($aReturned) { - $aReturn = []; + if (count($aReturned[1])) { $aReturn[] = [ 'metascore' => IMDBHelper::cleanString($aReturned[1][0]), 'reviews' => IMDBHelper::cleanString($aReturned[2][0]), @@ -674,9 +673,9 @@ public function getMetaCritics() return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); } else { - $fullCritics = sprintf('https://www.imdb.com/title/tt%s/criticreviews', $this->iId); + $fullCritics = sprintf('https://www.imdb.com/title/tt%s/criticreviews/', $this->iId); $aCurlInfo = IMDBHelper::runCurl($fullCritics); - $sSource = $aCurlInfo['contents'] ?? false; + $sSource = is_bool($aCurlInfo) ? $aCurlInfo : $aCurlInfo['contents']; if (false === $sSource) { if (true === self::IMDB_DEBUG) { @@ -1464,7 +1463,7 @@ public function getLocations() return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); } else { - $fullLocations = sprintf('https://www.imdb.com/title/tt%s/locations', $this->iId); + $fullLocations = sprintf('https://www.imdb.com/title/tt%s/locations/', $this->iId); $aCurlInfo = IMDBHelper::runCurl($fullLocations); $sSource = $aCurlInfo['contents'] ?? false; @@ -1610,7 +1609,7 @@ public function getPhotos($iLimit = 0, $bMore = true, $sSize = 'small') while ($isPage) { $fullPhotos = sprintf('https://www.imdb.com/title/tt%s/mediaindex?page=%d', $this->iId, $page); $aCurlInfo = IMDBHelper::runCurl($fullPhotos); - $sSource = $aCurlInfo['contents']; + $sSource = is_bool($aCurlInfo) ? $aCurlInfo : $aCurlInfo['contents']; if (false === $sSource) { if (true === self::IMDB_DEBUG) { @@ -1829,9 +1828,9 @@ public function getReleaseDates() return IMDBHelper::arrayOutput($this->bArrayOutput, $this->sSeparator, self::$sNotFound, $aReturn); } else { - $fullAkas = sprintf('https://www.imdb.com/title/tt%s/releaseinfo', $this->iId); + $fullAkas = sprintf('https://www.imdb.com/title/tt%s/releaseinfo/', $this->iId); $aCurlInfo = IMDBHelper::runCurl($fullAkas); - $sSource = $aCurlInfo['contents'] ?? false; + $sSource = is_bool($aCurlInfo) ? $aCurlInfo : $aCurlInfo['contents']; if (false === $sSource) { if (true === self::IMDB_DEBUG) { @@ -2064,7 +2063,7 @@ public function getTVInfo() $fullEpisodes = sprintf('https://www.imdb.com/title/tt%s/episodes/?season=%d', $this->iId, $page); $aCurlInfo = IMDBHelper::runCurl($fullEpisodes); - $sSource = $aCurlInfo['contents']; + $sSource = is_bool($aCurlInfo) ? $aCurlInfo : $aCurlInfo['contents']; if (false === $sSource) { if (true === self::IMDB_DEBUG) {