DLsiteResolverを追加

This commit is contained in:
eai04191 2019-01-14 04:22:40 +09:00
parent 20799dd757
commit cb3f060ba6
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,22 @@
<?php
namespace App\MetadataResolver;
use Illuminate\Support\Facades\Log;
class DLsiteResolver implements Resolver
{
public function resolve(string $url): Metadata
{
$client = new \GuzzleHttp\Client();
$res = $client->get($url);
if ($res->getStatusCode() === 200) {
$ogpResolver = new OGPResolver();
$metadata = $ogpResolver->parse($res->getBody());
$metadata->image = str_replace("img_sam.jpg", "img_main.jpg", $metadata->image);
return $metadata;
} else {
throw new \RuntimeException("{$res->getStatusCode()}: $url");
}
}
}

View File

@ -11,6 +11,7 @@ class MetadataResolver implements Resolver
'~www\.melonbooks\.co\.jp/detail/detail\.php~' => MelonbooksResolver::class,
'~ec\.toranoana\.jp/tora_r/ec/item/.*~' => ToranoanaResolver::class,
'~iwara\.tv/videos/.*~' => IwaraResolver::class,
'~www\.dlsite\.com/.*/work/=/product_id/..\d+\.html~' => DLsiteResolver::class,
'/.*/' => OGPResolver::class
];