Skip to content

Commit ec60fd5

Browse files
committed
fix: search patterns
1 parent 3ede8c9 commit ec60fd5

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/HtmlPieces.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,29 +313,30 @@ public function get(object $page, string $element, string $url='')
313313

314314
case "titles":
315315
case "names":
316+
case "people":
316317
case "companies":
317318
$response = [];
318-
$sections = $dom->find($page, ".findSection");
319+
$sections = $dom->find($page, ".ipc-page-section");
319320
if ($this->count($sections) > 0)
320321
{
321322
foreach ($sections as $section)
322323
{
323-
$sectionName = @strtolower($section->find(".findSectionHeader")->text);
324+
$sectionName = @strtolower($dom->find($section, ".ipc-title__text")->text);
324325
if ($sectionName === $element) {
325-
$sectionRows = $section->find(".findList tr");
326+
$sectionRows = $section->find("ul li");
326327
if ($this->count($sectionRows) > 0)
327328
{
328329
foreach ($sectionRows as $sectionRow)
329330
{
330331
$row = [];
331332

332-
$link = $dom->find($sectionRow, 'td.result_text a');
333+
$link = $dom->find($sectionRow, 'a');
333334
$row["title"] = $link->text;
334335
if ($row["title"] == "") {
335336
continue;
336337
}
337338

338-
$row["image"] = $dom->find($sectionRow, 'td.primary_photo img')->src;
339+
$row["image"] = $dom->find($sectionRow, '.ipc-image')->src;
339340
if (preg_match('/@/', $row["image"]))
340341
{
341342
$row["image"] = preg_split('~@(?=[^@]*$)~', $row["image"])[0] . "@.jpg";

src/Imdb.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function search(string $search, array $options = []): array
168168

169169
// Add all search data to response $store
170170
$response->add("titles", $htmlPieces->get($page, "titles"));
171-
$response->add("names", $htmlPieces->get($page, "names"));
171+
$response->add("names", $htmlPieces->get($page, "people"));
172172
$response->add("companies", $htmlPieces->get($page, "companies"));
173173

174174
return $response->return();

tests/ImdbTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testFilmCache()
7171
{
7272
$imdb = new Imdb;
7373
$cache = new Cache;
74-
$film = $imdb->film('tt0816692', [ 'techSpecs' => false ]);
74+
$film = $imdb->film('tt0816692', [ 'cache' => true, 'techSpecs' => false ]);
7575
$cache_film = $cache->get('tt0816692')->film;
7676

7777
$this->assertEquals(true, $cache->has('tt0816692'));

0 commit comments

Comments
 (0)