Skip to content

Commit ef18237

Browse files
committed
fix: pattern for year
1 parent c1fd186 commit ef18237

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/HtmlPieces.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
*/
1111
class HtmlPieces
1212
{
13+
public ?string $filmId;
14+
15+
public function __construct(?string $filmId = null)
16+
{
17+
$this->filmId = $filmId;
18+
}
19+
20+
public function setFilmId(string $filmId = null)
21+
{
22+
$this->filmId = $filmId;
23+
}
1324

1425
/**
1526
* Attempts to find and return a specific element
@@ -47,7 +58,7 @@ public function get(object $page, string $element, string $url='')
4758
break;
4859

4960
case "year":
50-
$patterns = ["[data-testid=hero-title-block__metadata] > li > a", ".title_wrapper h1 #titleYear a", ".title_wrapper .subtext a[title='See more release dates']", "section section div div div ul li a"];
61+
$patterns = ["a[href='/title/{$this->filmId}/releaseinfo?ref_=tt_ov_rdat']", "[data-testid=hero-title-block__metadata] > li > a", ".title_wrapper h1 #titleYear a", ".title_wrapper .subtext a[title='See more release dates']", "section section div div div ul li a"];
5162
$year = $this->findMatchInPatterns($dom, $page, $patterns);
5263

5364
// Detect OLD IMDB + TV show

src/Imdb.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function film(string $filmId, array $options = []): array
9292

9393
// Load imdb film page and parse the dom
9494
$page = $dom->fetch("https://www.imdb.com/title/".$filmId."/", $options);
95+
$htmlPieces->setFilmId($filmId);
9596

9697
// Add all film data to response $store
9798
$response->add("id", $filmId);

0 commit comments

Comments
 (0)