From 494169f959363bf71e4b0be005cb5542f6d2d871 Mon Sep 17 00:00:00 2001 From: teromene Date: Sat, 14 Apr 2018 16:19:35 +0100 Subject: [PATCH] Added bridge for Pixiv. This bridge is slow, as caching of images is required (REFERER header required to access the full size images) --- bridges/PixivBridge.php | 73 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 bridges/PixivBridge.php diff --git a/bridges/PixivBridge.php b/bridges/PixivBridge.php new file mode 100644 index 00000000..2f15b4b4 --- /dev/null +++ b/bridges/PixivBridge.php @@ -0,0 +1,73 @@ + array( + 'name' => 'Tag to search', + 'exampleValue' => 'example', + 'required' => true + ), + )); + + + public function collectData(){ + + $html = getContents(static::URI.'search.php?word=' . urlencode($this->getInput('tag'))) + or returnClientError('Unable to query pixiv.net'); + $regex = '/getTimestamp(); + + $item["content"] = ""; + $this->items[] = $item; + } + } + + public function cacheImage($url, $illustId) { + + $url = str_replace("_master1200", "", $url); + $url = str_replace("c/240x240/img-master/", "img-original/", $url); + $path = CACHE_DIR . '/pixiv_img'; + + if(!is_dir($path)) + mkdir($path, 0755, true); + + if(!is_file($path . '/' . $illustId . '.jpeg')) { + $headers = array("Referer: https://www.pixiv.net/member_illust.php?mode=medium&illust_id=" . $illustId); + $illust = getContents($url, $headers); + if(strpos($illust, "404 Not Found") !== false) { + $illust = getContents(str_replace("jpg", "png", $url), $headers); + } + file_put_contents($path . '/' . $illustId . '.jpeg', $illust); + } + + return 'cache/pixiv_img/' . $illustId . ".jpeg"; + + } + +}