From 2112087e896c84f7b7b93a16d4f29673def3869e Mon Sep 17 00:00:00 2001 From: eai04191 Date: Tue, 20 Aug 2019 01:34:36 +0900 Subject: [PATCH] =?UTF-8?q?nbsp=E3=82=92space=E3=81=AB=E7=BD=AE=E6=8F=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/DLsiteResolver.php | 3 ++- tests/Unit/MetadataResolver/DLsiteResolverTest.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/MetadataResolver/DLsiteResolver.php b/app/MetadataResolver/DLsiteResolver.php index 5969d57..951bee4 100644 --- a/app/MetadataResolver/DLsiteResolver.php +++ b/app/MetadataResolver/DLsiteResolver.php @@ -82,7 +82,8 @@ class DLsiteResolver implements Resolver // #work_makerから「makerを含むテキスト」を持つ要素を持つtdを探す // 作者名単体の場合もあるし、"作者A / 作者B"のようになることもある $makersNode = $xpath->query('//*[@id="work_maker"]//*[contains(text(), "' . $makers[0] . '")]/ancestor::td')->item(0); - $makers = trim($makersNode->textContent); + // nbspをspaceに置換 + $makers = trim(str_replace("\xc2\xa0", ' ', $makersNode->textContent)); // makersHaed // $makerNode(td)に対するthを探す diff --git a/tests/Unit/MetadataResolver/DLsiteResolverTest.php b/tests/Unit/MetadataResolver/DLsiteResolverTest.php index 7cac98b..07d7d0c 100644 --- a/tests/Unit/MetadataResolver/DLsiteResolverTest.php +++ b/tests/Unit/MetadataResolver/DLsiteResolverTest.php @@ -106,7 +106,7 @@ class DLsiteResolverTest extends TestCase $metadata = $this->resolver->resolve('https://www.dlsite.com/books/work/=/product_id/BJ191317.html'); $this->assertEquals('永遠娘 vol.6', $metadata->title); - $this->assertEquals('著者: あまがえる / 玉之けだま / びんせん / 甘露アメ / 源五郎 / すみやお / 宇宙烏賊 / 毒茸人 / あやね / ガロウド / ハードボイルドよし子 / 夜歌 / 黒青郎君' . PHP_EOL . '君の命はどんな味なのだろうな?', $metadata->description); + $this->assertEquals('著者: あまがえる / 玉之けだま / びんせん / 甘露アメ / 源五郎 / すみやお / 宇宙烏賊 / 毒茸人 / あやね / ガロウド / ハードボイルドよし子 / 夜歌 / 黒青郎君' . PHP_EOL . '君の命はどんな味なのだろうな?', $metadata->description); $this->assertEquals('https://img.dlsite.jp/modpub/images2/work/books/BJ192000/BJ191317_img_main.jpg', $metadata->image); $this->assertEquals(['ツンデレ', 'ロリ', '妖怪', '人外娘/モンスター娘', 'セーラー服', 'メイド', 'ストッキング', 'ファンタジー', 'ぶっかけ', '中出し', '近親相姦', 'アヘ顔', '口内射精'], $metadata->tags); if ($this->shouldUseMock()) {