From 98e933b833ef600436cc922674987dffb93c7432 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 18:34:33 +0900 Subject: [PATCH] =?UTF-8?q?=E5=A4=89=E6=95=B0=E5=90=8D=E3=82=92camelCase?= =?UTF-8?q?=20=E3=81=AB=E7=B5=B1=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/PixivResolver.php | 38 +++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/MetadataResolver/PixivResolver.php b/app/MetadataResolver/PixivResolver.php index ad82f48..c395892 100644 --- a/app/MetadataResolver/PixivResolver.php +++ b/app/MetadataResolver/PixivResolver.php @@ -8,32 +8,32 @@ class PixivResolver implements Resolver /** * サムネイル画像 URL から最大長辺 1200px の画像 URL に変換する * - * @param string $thumbnail_url サムネイル画像 URL + * @param string $thumbnailUrl サムネイル画像 URL * @return string 1200px の画像 URL */ - public function thumbnailToMasterUrl(string $thumbnail_url):string + public function thumbnailToMasterUrl(string $thumbnailUrl):string { - $temp = str_replace("/c/128x128", "", $thumbnail_url); - $large_url = str_replace("square1200.jpg", "master1200.jpg", $temp); - return $large_url; + $temp = str_replace("/c/128x128", "", $thumbnailUrl); + $largeUrl = str_replace("square1200.jpg", "master1200.jpg", $temp); + return $largeUrl; } /** * 直リン可能な pixiv.cat のプロキシ URL に変換する * HUGE THANKS TO PIXIV.CAT! * - * @param string $pixiv_url i.pximg URL + * @param string $pixivUrl i.pximg URL * @return string i.pixiv.cat URL */ - public function proxize(string $pixiv_url):string + public function proxize(string $pixivUrl):string { - return str_replace("i.pximg.net", "i.pixiv.cat", $pixiv_url); + return str_replace("i.pximg.net", "i.pixiv.cat", $pixivUrl); } public function resolve(string $url): Metadata { - preg_match("~illust_id=(\d+)~", parse_url($url)["query"], $illust_id); - $illust_id = $illust_id[1]; + preg_match("~illust_id=(\d+)~", parse_url($url)["query"], $match); + $illustId = $match[1]; // 漫画ページかつページ数あり if (strpos(parse_url($url)["query"], "mode=manga_big") && strpos(parse_url($url)["query"], "page=")) { @@ -49,15 +49,15 @@ class PixivResolver implements Resolver $ogpResolver = new OGPResolver(); $metadata = $ogpResolver->parse($res->getBody()); - preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illust_id}_p0_square1200\.jpg~", $res->getBody(), $match); - $illust_thumbnail_url = $match[0]; + preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illustId}_p0_square1200\.jpg~", $res->getBody(), $match); + $illustThumbnailUrl = $match[0]; - $illust_url = $this->thumbnailToMasterUrl($illust_thumbnail_url); + $illustUrl = $this->thumbnailToMasterUrl($illustThumbnailUrl); // 指定ページに変換 - $illust_url = str_replace("p0_master", "p{$page}_master", $illust_url); + $illustUrl = str_replace("p0_master", "p{$page}_master", $illustUrl); - $metadata->image = $this->proxize($illust_url); + $metadata->image = $this->proxize($illustUrl); ; return $metadata; @@ -76,12 +76,12 @@ class PixivResolver implements Resolver // 作品ページの場合のみ対応 if (strpos(parse_url($url)["query"], "mode=medium")) { - preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illust_id}(_p0)?_square1200\.jpg~", $res->getBody(), $match); - $illust_thumbnail_url = $match[0]; + preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illustId}(_p0)?_square1200\.jpg~", $res->getBody(), $match); + $illustThumbnailUrl = $match[0]; - $illust_url = $this->thumbnailToMasterUrl($illust_thumbnail_url); + $illustUrl = $this->thumbnailToMasterUrl($illustThumbnailUrl); - $metadata->image = $this->proxize($illust_url); + $metadata->image = $this->proxize($illustUrl); ; } }