Skip to content

Commit

Permalink
Detect tv-shows to return correct year
Browse files Browse the repository at this point in the history
  • Loading branch information
hmerritt committed Jun 3, 2021
1 parent fb24190 commit 39e54f7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/HtmlPieces.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,19 @@ public function get(object $page, string $element)
break;

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

// Detect OLD IMDB + TV show
if ($this->count($year) > 4) {
// Extract year from text
// \d{4}.\d{4}
$matchYear = preg_replace("/[^\d{4}-–\d{4}]/", "", $year);
if ($this->count($matchYear) > 0) {
$year = $matchYear;
}
}

return $this->strClean($year);
break;

Expand Down

0 comments on commit 39e54f7

Please sign in to comment.