ニコニコ静画のタグを取得する
This commit is contained in:
parent
743272f8d6
commit
f3a4f682a8
@ -3,6 +3,7 @@
|
||||
namespace App\MetadataResolver;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
class NicoSeigaResolver implements Resolver
|
||||
{
|
||||
@ -25,7 +26,13 @@ class NicoSeigaResolver implements Resolver
|
||||
{
|
||||
$res = $this->client->get($url);
|
||||
if ($res->getStatusCode() === 200) {
|
||||
$metadata = $this->ogpResolver->parse($res->getBody());
|
||||
$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));
|
||||
|
||||
// ページURLからサムネイルURLに変換
|
||||
preg_match('~http://(?:(?:sp\\.)?seiga\\.nicovideo\\.jp/seiga(?:/#!)?|nico\\.ms)/im(\\d+)~', $url, $matches);
|
||||
|
Loading…
Reference in New Issue
Block a user