通販サイトのメタデータ対応
This commit is contained in:
parent
9bd22d9f77
commit
9646f90ce3
22
app/MetadataResolver/MelonbooksResolver.php
Normal file
22
app/MetadataResolver/MelonbooksResolver.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\MetadataResolver;
|
||||
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
|
||||
class MelonbooksResolver implements Resolver
|
||||
{
|
||||
public function resolve(string $url): Metadata
|
||||
{
|
||||
$cookieJar = CookieJar::fromArray(['AUTH_ADULT' => '1'], 'www.melonbooks.co.jp');
|
||||
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$res = $client->get($url, ['cookies' => $cookieJar]);
|
||||
if ($res->getStatusCode() === 200) {
|
||||
$ogpResolver = new OGPResolver();
|
||||
return $ogpResolver->parse($res->getBody());
|
||||
} else {
|
||||
throw new \RuntimeException("{$res->getStatusCode()}: $url");
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,8 @@ class MetadataResolver implements Resolver
|
||||
'~(((sp\.)?seiga\.nicovideo\.jp/seiga(/#!)?|nico\.ms))/im~' => NicoSeigaResolver::class,
|
||||
'~nijie\.info/view\.php~' => NijieResolver::class,
|
||||
'~komiflo\.com(/#!)?/comics/(\\d+)~' => KomifloResolver::class,
|
||||
'~www\.melonbooks\.co\.jp/detail/detail\.php~' => MelonbooksResolver::class,
|
||||
'~ec\.toranoana\.jp/tora_r/ec/item/.*~' => ToranoanaResolver::class,
|
||||
'/.*/' => OGPResolver::class
|
||||
];
|
||||
|
||||
|
22
app/MetadataResolver/ToranoanaResolver.php
Normal file
22
app/MetadataResolver/ToranoanaResolver.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\MetadataResolver;
|
||||
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
|
||||
class ToranoanaResolver implements Resolver
|
||||
{
|
||||
public function resolve(string $url): Metadata
|
||||
{
|
||||
$cookieJar = CookieJar::fromArray(['adflg' => '0'], 'ec.toranoana.jp');
|
||||
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$res = $client->get($url, ['cookies' => $cookieJar]);
|
||||
if ($res->getStatusCode() === 200) {
|
||||
$ogpResolver = new OGPResolver();
|
||||
return $ogpResolver->parse($res->getBody());
|
||||
} else {
|
||||
throw new \RuntimeException("{$res->getStatusCode()}: $url");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user