200でなかったときのテストを削除
4xxや5xxの場合は`\GuzzleHttp\Exception\BadResponseException`が発生するので、今まであったelseのところには到達しなかった
This commit is contained in:
@@ -24,23 +24,19 @@ class XtubeResolver implements Resolver
|
||||
}
|
||||
|
||||
$res = $this->client->get($url);
|
||||
if ($res->getStatusCode() === 200) {
|
||||
$html = (string) $res->getBody();
|
||||
$metadata = new Metadata();
|
||||
$crawler = new Crawler($html);
|
||||
$html = (string) $res->getBody();
|
||||
$metadata = new Metadata();
|
||||
$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]);
|
||||
// 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->tags = $crawler->filter('.tagsCategories a')->extract('_text');
|
||||
$metadata->title = trim($crawler->filter('.underPlayerRateForm h1')->text(''));
|
||||
$metadata->description = trim($crawler->filter('.fullDescription ')->text(''));
|
||||
$metadata->tags = $crawler->filter('.tagsCategories a')->extract('_text');
|
||||
|
||||
return $metadata;
|
||||
} else {
|
||||
throw new \RuntimeException("{$res->getStatusCode()}: $url");
|
||||
}
|
||||
return $metadata;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user