strip_tags追加

This commit is contained in:
eai04191 2019-08-20 00:52:00 +09:00
parent f7c9e83b12
commit c93ccb43c8
3 changed files with 2344 additions and 2 deletions

View File

@ -97,10 +97,11 @@ class DLsiteResolver implements Resolver
// OGP説明文から定型文を消す // OGP説明文から定型文を消す
if (strpos($url, 'dlsite.com/eng/') || strpos($url, 'dlsite.com/ecchi-eng/')) { if (strpos($url, 'dlsite.com/eng/') || strpos($url, 'dlsite.com/ecchi-eng/')) {
$metadata->description = trim(preg_replace('~DLsite.+ is a download shop for .+With a huge selection of products, we\'re sure you\'ll find whatever tickles your fancy\. DLsite is one of the greatest indie contents download shops in Japan\.$~', '', $metadata->description)); $metadata->description = preg_replace('~DLsite.+ is a download shop for .+With a huge selection of products, we\'re sure you\'ll find whatever tickles your fancy\. DLsite is one of the greatest indie contents download shops in Japan\.$~', '', $metadata->description);
} else { } else {
$metadata->description = trim(preg_replace('~「DLsite.+」は.+のダウンロードショップ。お気に入りの作品をすぐダウンロードできてすぐ楽しめる毎日更新しているのであなたが探している作品にきっと出会えます。国内最大級の二次元総合ダウンロードショップ「DLsite」$~', '', $metadata->description)); $metadata->description = preg_replace('~「DLsite.+」は.+のダウンロードショップ。お気に入りの作品をすぐダウンロードできてすぐ楽しめる毎日更新しているのであなたが探している作品にきっと出会えます。国内最大級の二次元総合ダウンロードショップ「DLsite」$~', '', $metadata->description);
} }
$metadata->description = trim(strip_tags($metadata->description));
// 整形 // 整形
$metadata->description = $makersHead . ': ' . $makers . PHP_EOL . $metadata->description; $metadata->description = $makersHead . ': ' . $makers . PHP_EOL . $metadata->description;

View File

@ -226,4 +226,20 @@ class DLsiteResolverTest extends TestCase
$this->assertSame('https://dlsite.jp/howtw/RJ221761.html', (string) $this->handler->getLastRequest()->getUri()); $this->assertSame('https://dlsite.jp/howtw/RJ221761.html', (string) $this->handler->getLastRequest()->getUri());
} }
} }
public function testHTMLdescription()
{
$responseText = file_get_contents(__DIR__ . '/../../fixture/DLsite/testHTMLdescription.html');
$this->createResolver(DLsiteResolver::class, $responseText);
$metadata = $this->resolver->resolve('https://www.dlsite.com/books/work/=/product_id/BJ123822.html');
$this->assertEquals('獣○彼女カタログ', $metadata->title);
$this->assertEquals('著者: チキコ / MUJIN編集部' . PHP_EOL . '【DLsite.com独占販売】 エロ漫画界騒然、1冊まるごと獣○オンリー単行本! 人間チ×ポは出てきませんっ!!', $metadata->description);
$this->assertEquals('https://img.dlsite.jp/modpub/images2/work/books/BJ124000/BJ123822_img_main.jpg', $metadata->image);
$this->assertEquals(['断面図', '制服', '水着', 'メイド', '巫女', '軍服', '中出し', 'フェラチオ', '複数プレイ/乱交', '異種姦', '巨乳/爆乳', '処女', '褐色/日焼け'], $metadata->tags);
if ($this->shouldUseMock()) {
$this->assertSame('https://www.dlsite.com/books/work/=/product_id/BJ123822.html', (string) $this->handler->getLastRequest()->getUri());
}
}
} }

File diff suppressed because it is too large Load Diff