tissue/app/MetadataResolver/DLsiteResolver.php

22 lines
606 B
PHP
Raw Normal View History

2019-01-14 04:22:40 +09:00
<?php
namespace App\MetadataResolver;
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);
2019-01-15 00:05:01 +09:00
2019-01-14 04:22:40 +09:00
return $metadata;
} else {
throw new \RuntimeException("{$res->getStatusCode()}: $url");
}
}
2019-01-15 00:05:01 +09:00
}