Skip to content

Commit dcb4723

Browse files
committed
techdebt🍴: parse manga synopsis with line-breaks #320
1 parent c6c6267 commit dcb4723

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Parser/Manga/MangaParser.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,17 @@ public function getMangaImageURL(): string
9191
*/
9292
public function getMangaSynopsis(): ?string
9393
{
94-
$synopsis = JString::cleanse(
95-
$this->crawler->filterXPath('//meta[@property=\'og:description\']')->attr('content')
96-
);
94+
// #justMALThings: anime synopsis is wrapped in <p> whereas it's <span> for manga
95+
$node = $this->crawler->filterXPath('//span[@itemprop=\'description\']');
96+
97+
if (!$node->count()) {
98+
return null;
99+
}
100+
101+
$synopsis = JString::cleanse($node->html());
97102

98-
return preg_match('~^Looking for information on the manga~', $synopsis) ? null : $synopsis;
103+
// just in case
104+
return str_starts_with($synopsis, 'No synopsis information has been added to this title.') ? null : $synopsis;
99105
}
100106

101107
/**

0 commit comments

Comments
 (0)