Skip to content

Commit 39e54f7

Browse files
committed
Detect tv-shows to return correct year
1 parent fb24190 commit 39e54f7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/HtmlPieces.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,19 @@ public function get(object $page, string $element)
3434
break;
3535

3636
case "year":
37-
$patterns = ["section section div div div ul li a", ".title_wrapper h1 #titleYear a"];
37+
$patterns = ["section section div div div ul li a", ".title_wrapper h1 #titleYear a", ".title_wrapper .subtext a[title='See more release dates']"];
3838
$year = $this->findMatchInPatterns($dom, $page, $patterns);
3939

40+
// Detect OLD IMDB + TV show
41+
if ($this->count($year) > 4) {
42+
// Extract year from text
43+
// \d{4}.\d{4}
44+
$matchYear = preg_replace("/[^\d{4}-–\d{4}]/", "", $year);
45+
if ($this->count($matchYear) > 0) {
46+
$year = $matchYear;
47+
}
48+
}
49+
4050
return $this->strClean($year);
4151
break;
4252

0 commit comments

Comments
 (0)