} else { $is_conn = false; //action in connection failure } return $is_conn; } // Clean up files/images. array_map('unlink', glob($downloadPath . '/wallhaven-*')); if (isConnected()) { $wh = new Wallhaven($account["username"], $account["password"]); $result = []; $dt = new DateTime(); foreach ($time as $t) { $fromTime = new DateTime($t['from']); if ($dt > $fromTime) { $result = array_merge($default, $t); } else { break; } } $wallpapers = $wh->filter()->keywords($result['keywords'])->categories($result["categories"])->purity($result["purity"])->sorting($result["sorting"])->resolutions($result["resolutions"])->ratios($result["ratios"])->pages(1)->getWallpapers(); $id = $wallpapers[0]->getId(); $url = $wallpapers[0]->getImageUrl(); $fileName = trim(substr($url, strrpos($url, '/') + 1)); mkdir($downloadPath, 0700, true); $wh->wallpaper($id)->download($downloadPath); shell_exec("feh --bg-fill '" . escapeshellarg($downloadPath) . "/" . escapeshellarg($fileName) . "'"); } else { // @HACK Just quick and dirty hack :D shell_exec("feh --bg-fill --randomize --recursive '" . escapeshellarg($fallbackPath) . "'"); }
public function testThumbnailUrl() { $wh = new Wallhaven(); $thumbUrl = $wh->wallpaper(198320)->getThumbnailUrl(); $this->assertEquals('http://alpha.wallhaven.cc/wallpapers/thumb/small/th-198320.jpg', $thumbUrl); }