diff --git a/docker-compose.yml b/docker-compose.yml index b04d2e52..c3faacb5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.5" - services: app: build: diff --git a/src/Api/Imdb/ImdbWebScrapper.php b/src/Api/Imdb/ImdbWebScrapper.php index 377e4430..4da703c1 100644 --- a/src/Api/Imdb/ImdbWebScrapper.php +++ b/src/Api/Imdb/ImdbWebScrapper.php @@ -70,7 +70,7 @@ private function extractProductionStatus(string $imdbRatingPage) : ?string private function extractRatingAverage(string $imdbRatingPage, string $imdbId) : ?float { - preg_match('/cMEQkK">(\d([.,])\d)/', $imdbRatingPage, $averageRatingMatches); + preg_match('/cxhhrI">(\d([.,])\d)/', $imdbRatingPage, $averageRatingMatches); if (empty($averageRatingMatches[1]) === true) { $this->logger->warning('IMDb: Could not extract rating average.', ['url' => $this->urlGenerator->buildMovieUrl($imdbId)]); @@ -83,32 +83,32 @@ private function extractRatingAverage(string $imdbRatingPage, string $imdbId) : private function extractRatingVoteCount(string $imdbRatingPage, string $imdbId) : ?int { // Handle numbers without suffix - preg_match('/gPVQxL">([0-9]+)</', $imdbRatingPage, $voteCountMatches); + preg_match('/gUihYJ">([0-9]+)</', $imdbRatingPage, $voteCountMatches); if (empty($voteCountMatches[1]) === false) { return (int)$voteCountMatches[1]; } - preg_match('/gPVQxL">([0-9]{1,3}([.,]?[0-9]{3})+)/', $imdbRatingPage, $voteCountMatches); + preg_match('/gUihYJ">([0-9]{1,3}([.,]?[0-9]{3})+)/', $imdbRatingPage, $voteCountMatches); if (empty($voteCountMatches[1]) === false) { return (int)str_replace([',', '.'], '', $voteCountMatches[1]); } // Handle numbers with K suffix - preg_match('/gPVQxL">([0-9]+)K</', $imdbRatingPage, $voteCountMatches); + preg_match('/gUihYJ">([0-9]+)K</', $imdbRatingPage, $voteCountMatches); if (empty($voteCountMatches[1]) === false) { return (int)$voteCountMatches[1] * 1000; } - preg_match('/gPVQxL">([0-9]{1,3}[.,][0-9]{1,3})K</', $imdbRatingPage, $voteCountMatches); + preg_match('/gUihYJ">([0-9]{1,3}[.,][0-9]{1,3})K</', $imdbRatingPage, $voteCountMatches); if (empty($voteCountMatches[1]) === false) { return (int)((float)$voteCountMatches[1] * 1000); } // Handle simple numbers with M suffix - preg_match('/gPVQxL">([0-9]+)M</', $imdbRatingPage, $voteCountMatches); + preg_match('/gUihYJ">([0-9]+)M</', $imdbRatingPage, $voteCountMatches); if (empty($voteCountMatches[1]) === false) { return (int)$voteCountMatches[1] * 1000000; } // Handle simple numbers with K suffix - preg_match('/gPVQxL">([0-9]{1,3}[.,][0-9]{1,3})M</', $imdbRatingPage, $voteCountMatches); + preg_match('/gUihYJ">([0-9]{1,3}[.,][0-9]{1,3})M</', $imdbRatingPage, $voteCountMatches); if (empty($voteCountMatches[1]) === false) { return (int)((float)$voteCountMatches[1] * 1000000); } diff --git a/tests/unit/Api/Imdb/ImdbWebScrapperTest.php b/tests/unit/Api/Imdb/ImdbWebScrapperTest.php index ea20046d..705cf4ec 100644 --- a/tests/unit/Api/Imdb/ImdbWebScrapperTest.php +++ b/tests/unit/Api/Imdb/ImdbWebScrapperTest.php @@ -27,63 +27,63 @@ public function provideFindRatingData() : array { return [ [ - 'cMEQkK">7.9</span> - gPVQxL">229.240</div>', + 'cxhhrI">7.9</span> + gUihYJ">229.240</div>', ImdbRating::create(7.9, 229240) ], 'returns no rating if current production status is found' => [ 'hjAonB">Post-production - cMEQkK">7.9</span> - gPVQxL">229.240</div>', + cxhhrI">7.9</span> + gUihYJ">229.240</div>', null, ], [ - 'cMEQkK">7,9</span> - gPVQxL">229,240</div>', + 'cxhhrI">7,9</span> + gUihYJ">229,240</div>', ImdbRating::create(7.9, 229240) ], [ - 'cMEQkK">7,9</span> - gPVQxL">229240</div>', + 'cxhhrI">7,9</span> + gUihYJ">229240</div>', ImdbRating::create(7.9, 229240) ], [ - 'cMEQkK">7,9</span> - gPVQxL">1.229,240</div>', + 'cxhhrI">7,9</span> + gUihYJ">1.229,240</div>', ImdbRating::create(7.9, 1229240) ], [ - 'cMEQkK">7,9</span> - gPVQxL">40</div>', + 'cxhhrI">7,9</span> + gUihYJ">40</div>', ImdbRating::create(7.9, 40) ], [ - 'cMEQkK">7,9</span> - gPVQxL">40K</div>', + 'cxhhrI">7,9</span> + gUihYJ">40K</div>', ImdbRating::create(7.9, 40000) ], [ - 'cMEQkK">7,9</span> - gPVQxL">4.1K</div>', + 'cxhhrI">7,9</span> + gUihYJ">4.1K</div>', ImdbRating::create(7.9, 4100) ], [ - 'cMEQkK">7,9</span> - gPVQxL">14.12K</div>', + 'cxhhrI">7,9</span> + gUihYJ">14.12K</div>', ImdbRating::create(7.9, 14120) ], [ - 'cMEQkK">7,9</span> - gPVQxL">10M</div>', + 'cxhhrI">7,9</span> + gUihYJ">10M</div>', ImdbRating::create(7.9, 10000000) ], [ - 'cMEQkK">7,9</span> - gPVQxL">10.1M</div>', + 'cxhhrI">7,9</span> + gUihYJ">10.1M</div>', ImdbRating::create(7.9, 10100000) ], [ - 'cMEQkK">7,9</span>', + 'cxhhrI">7,9</span>', null ], [