public function get_sp_video($spid, Request $request) { try { $type = $request->get('type', 0); $request_array = ['spid' => $spid, 'type' => $type]; $back = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . '/spvideo?' . http_build_query($request_array)); return response()->json($back); } catch (\Exception $e) { return $this->returnError($e->getMessage()); } }
use App\Utils\BiliBiliHelper; use App\Utils\RequestUtil; use Illuminate\Support\Facades\Cache; $app = (require __DIR__ . '/bootstrap/app.php'); date_default_timezone_set('PRC'); try { $sort_list = []; foreach (BiliBiliHelper::getSorts() as $key => $value) { $request_array = ['tid' => $key, 'order' => 'hot', 'page' => '1', 'pagesize' => '20']; $back = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . '/sort?' . http_build_query($request_array)); $sort_list[$key] = $back['content']; } $index = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . '/index'); $refresh_time = date('H:i:s'); $bangumi = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . '/bangumi?type=2'); $bangumi_result = []; for ($i = 0; $i < 7; $i++) { $day_bangumi = []; $bangumi_result[$i] = $day_bangumi; } foreach ($bangumi['content']['list'] as $animation) { if (isset($animation['cover'])) { array_push($bangumi_result[$animation['weekday']], $animation); } } Cache::forever('index_cache', $index['content']); Cache::forever('sort_cache', $sort_list); Cache::forever('bangumi_cache', $bangumi_result); Cache::forever('refresh_time', $refresh_time); dd('ok');
public function searchPage($content, Request $request) { try { $page = $request->get('page', 2); //页码非法检测 if ($page < 2) { $page = 2; } $request_array = ['keyword' => $content, 'page' => $page, 'pagesize' => 8]; $back = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . '/search?' . http_build_query($request_array)); $return_array = ['code' => 'success', 'content' => $back['content']]; return response()->json($return_array); } catch (\Exception $e) { $return_array = ['code' => 'error', 'content' => $e->getMessage()]; return response()->json($return_array); } }
while (true) { if ($startId >= $maxId) { $newMaxId = $startId + 1000; $back = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . "/view/{$newMaxId}"); if ($back['code'] == 200) { $maxId = $newMaxId; } else { echo 'sleep-1-20s \\n'; sleep(20); $startId++; } echo 'sleep-2-10s \\n'; sleep(10); continue; } $back = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . "/view/{$startId}"); if ($back['code'] != 200) { echo 'sleep-3-10s \\n'; sleep(10); $startId++; continue; } echo strval($startId) . '\\n'; $content = $back['content']; $content['aid'] = $startId; $content["_id"] = $startId; $collVideos->save($content); $collection->save(array("_id" => 1, "startId" => $startId)); $startId++; sleep(8); }
public function get_sp_video($spid, Request $request) { try { $type = $request->get('type', 0); $back = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . "/spvideos/{$spid}?bangumi={$type}"); if ($back['code'] != 200) { throw new Exception(); } return response()->json(['code' => 'success', 'content' => $back['content']]); } catch (\Exception $e) { return response()->json(['code' => 'error', 'message' => $e->getMessage()]); } }
public function test() { try { $sort_list = []; foreach (BiliBiliHelper::getSorts() as $key => $value) { $request_array = ['tid' => $key, 'order' => 'hot', 'page' => '1', 'pagesize' => '20']; $back = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . '/sort?' . http_build_query($request_array)); $sort_list[$key] = $back['content']; } $index = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . '/index'); $refresh_time = date('H:i:s'); $bangumi = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . '/bangumi?type=2'); $bangumi_result = []; for ($i = 0; $i < 7; $i++) { $day_bangumi = []; $bangumi_result[$i] = $day_bangumi; } foreach ($bangumi['content']['list'] as $animation) { if (isset($animation['cover'])) { array_push($bangumi_result[$animation['weekday']], $animation); } } Cache::forever('index_cache', $index['content']); Cache::forever('sort_cache', $sort_list); Cache::forever('refresh_time', $refresh_time); Cache::forever('bangumi_cache', $bangumi_result); dd('ok'); } catch (\Exception $e) { dd($e); } }