DLsiteResolverを追加
This commit is contained in:
parent
20799dd757
commit
cb3f060ba6
22
app/MetadataResolver/DLsiteResolver.php
Normal file
22
app/MetadataResolver/DLsiteResolver.php
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user