OGPを吐くようになっていたのでOGPResolverでimageを取得するように変更
This commit is contained in:
parent
57a847baf5
commit
16ed4482f4
@ -11,10 +11,15 @@ class XtubeResolver implements Resolver
|
||||
* @var Client
|
||||
*/
|
||||
private $client;
|
||||
/**
|
||||
* @var OGPResolver
|
||||
*/
|
||||
private $ogpResolver;
|
||||
|
||||
public function __construct(Client $client)
|
||||
public function __construct(Client $client, OGPResolver $ogpResolver)
|
||||
{
|
||||
$this->client = $client;
|
||||
$this->ogpResolver = $ogpResolver;
|
||||
}
|
||||
|
||||
public function resolve(string $url): Metadata
|
||||
@ -25,16 +30,13 @@ class XtubeResolver implements Resolver
|
||||
|
||||
$res = $this->client->get($url);
|
||||
$html = (string) $res->getBody();
|
||||
$metadata = new Metadata();
|
||||
$metadata = $this->ogpResolver->parse($html);
|
||||
$crawler = new Crawler($html);
|
||||
|
||||
// poster URL抽出
|
||||
$playerConfig = explode("\n", trim($crawler->filter('#playerWrapper script')->last()->text()));
|
||||
preg_match('~https:\\\/\\\/cdn\d+-s-hw-e5\.xtube\.com\\\/m=(?P<size>.{8})\\\/videos\\\/\d{6}\\\/\d{2}\\\/.{5}-.{4}-\\\/original\\\/\d+\.jpg~', $playerConfig[0], $matches);
|
||||
$metadata->image = str_replace('\/', '/', $matches[0]);
|
||||
|
||||
$metadata->title = trim($crawler->filter('.underPlayerRateForm h1')->text(''));
|
||||
$metadata->description = trim($crawler->filter('.fullDescription ')->text(''));
|
||||
$metadata->image = str_replace('m=eSuQ8f', 'm=eaAaaEFb', $metadata->image);
|
||||
$metadata->image = str_replace('240X180', 'original', $metadata->image);
|
||||
$metadata->tags = $crawler->filter('.tagsCategories a')->extract('_text');
|
||||
|
||||
return $metadata;
|
||||
|
Loading…
Reference in New Issue
Block a user