Skip to content

Commit

Permalink
fix: search patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
hmerritt committed Dec 18, 2022
1 parent 3ede8c9 commit ec60fd5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/HtmlPieces.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,29 +313,30 @@ public function get(object $page, string $element, string $url='')

case "titles":
case "names":
case "people":
case "companies":
$response = [];
$sections = $dom->find($page, ".findSection");
$sections = $dom->find($page, ".ipc-page-section");
if ($this->count($sections) > 0)
{
foreach ($sections as $section)
{
$sectionName = @strtolower($section->find(".findSectionHeader")->text);
$sectionName = @strtolower($dom->find($section, ".ipc-title__text")->text);
if ($sectionName === $element) {
$sectionRows = $section->find(".findList tr");
$sectionRows = $section->find("ul li");
if ($this->count($sectionRows) > 0)
{
foreach ($sectionRows as $sectionRow)
{
$row = [];

$link = $dom->find($sectionRow, 'td.result_text a');
$link = $dom->find($sectionRow, 'a');
$row["title"] = $link->text;
if ($row["title"] == "") {
continue;
}

$row["image"] = $dom->find($sectionRow, 'td.primary_photo img')->src;
$row["image"] = $dom->find($sectionRow, '.ipc-image')->src;
if (preg_match('/@/', $row["image"]))
{
$row["image"] = preg_split('~@(?=[^@]*$)~', $row["image"])[0] . "@.jpg";
Expand Down
2 changes: 1 addition & 1 deletion src/Imdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function search(string $search, array $options = []): array

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

return $response->return();
Expand Down
2 changes: 1 addition & 1 deletion tests/ImdbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testFilmCache()
{
$imdb = new Imdb;
$cache = new Cache;
$film = $imdb->film('tt0816692', [ 'techSpecs' => false ]);
$film = $imdb->film('tt0816692', [ 'cache' => true, 'techSpecs' => false ]);
$cache_film = $cache->get('tt0816692')->film;

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

0 comments on commit ec60fd5

Please sign in to comment.