FanzaResolver追加 (#43)
FanzaのOGP画像は `ps.jpg` か `pr.jpg` で終わっている。 `pl.jpg` で高解像度なものが取得できる。
This commit is contained in:
parent
a33a0e542c
commit
4e1eec66be
app/MetadataResolver
21
app/MetadataResolver/FanzaResolver.php
Normal file
21
app/MetadataResolver/FanzaResolver.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\MetadataResolver;
|
||||
|
||||
class FanzaResolver 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 = preg_replace("~(pr|ps)\.jpg$~", "pl.jpg", $metadata->image);
|
||||
|
||||
return $metadata;
|
||||
} else {
|
||||
throw new \RuntimeException("{$res->getStatusCode()}: $url");
|
||||
}
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ class MetadataResolver implements Resolver
|
||||
'~www\.dlsite\.com/.*/work/=/product_id/..\d+\.html~' => DLsiteResolver::class,
|
||||
'~www\.pixiv\.net/member_illust\.php\?illust_id=\d+~' => PixivResolver::class,
|
||||
'~fantia\.jp/posts/\d+~' => FantiaResolver::class,
|
||||
'~dmm\.co\.jp/~' => FanzaResolver::class,
|
||||
'/.*/' => OGPResolver::class
|
||||
];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user