From 59aec2c038f5079912e353d579263eb61ec4c335 Mon Sep 17 00:00:00 2001 From: shibafu Date: Tue, 10 Sep 2019 01:01:47 +0900 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E6=88=90=E5=90=A6?= =?UTF-8?q?=E5=88=A4=E5=AE=9A=E3=82=92=E3=82=84=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/NicoSeigaResolver.php | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/app/MetadataResolver/NicoSeigaResolver.php b/app/MetadataResolver/NicoSeigaResolver.php index 721872e..de1a8ab 100644 --- a/app/MetadataResolver/NicoSeigaResolver.php +++ b/app/MetadataResolver/NicoSeigaResolver.php @@ -25,22 +25,18 @@ class NicoSeigaResolver implements Resolver public function resolve(string $url): Metadata { $res = $this->client->get($url); - if ($res->getStatusCode() === 200) { - $html = (string)$res->getBody(); - $metadata = $this->ogpResolver->parse($html); - $crawler = new Crawler($html); + $html = (string)$res->getBody(); + $metadata = $this->ogpResolver->parse($html); + $crawler = new Crawler($html); - // タグ - $excludeTags = ['R-15']; - $metadata->tags = array_values(array_diff($crawler->filter('.tag')->extract(['_text']), $excludeTags)); + // タグ + $excludeTags = ['R-15']; + $metadata->tags = array_values(array_diff($crawler->filter('.tag')->extract(['_text']), $excludeTags)); - // ページURLからサムネイルURLに変換 - preg_match('~https?://(?:(?:sp\\.)?seiga\\.nicovideo\\.jp/seiga(?:/#!)?|nico\\.ms)/im(\\d+)~', $url, $matches); - $metadata->image = "https://lohas.nicoseiga.jp/thumb/${matches[1]}l?"; + // ページURLからサムネイルURLに変換 + preg_match('~https?://(?:(?:sp\\.)?seiga\\.nicovideo\\.jp/seiga(?:/#!)?|nico\\.ms)/im(\\d+)~', $url, $matches); + $metadata->image = "https://lohas.nicoseiga.jp/thumb/${matches[1]}l?"; - return $metadata; - } else { - throw new \RuntimeException("{$res->getStatusCode()}: $url"); - } + return $metadata; } }