Skip to content

Commit

Permalink
techdebt🍴: parse manga synopsis with line-breaks #320
Browse files Browse the repository at this point in the history
  • Loading branch information
irfan-dahir committed Sep 20, 2024
1 parent c6c6267 commit dcb4723
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Parser/Manga/MangaParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,17 @@ public function getMangaImageURL(): string
*/
public function getMangaSynopsis(): ?string
{
$synopsis = JString::cleanse(
$this->crawler->filterXPath('//meta[@property=\'og:description\']')->attr('content')
);
// #justMALThings: anime synopsis is wrapped in <p> whereas it's <span> for manga
$node = $this->crawler->filterXPath('//span[@itemprop=\'description\']');
if (!$node->count()) {
return null;
}
$synopsis = JString::cleanse($node->html());
return preg_match('~^Looking for information on the manga~', $synopsis) ? null : $synopsis;
// just in case
return str_starts_with($synopsis, 'No synopsis information has been added to this title.') ? null : $synopsis;
}
/**
Expand Down

0 comments on commit dcb4723

Please sign in to comment.