From 6610777c5d237adbe78b5cd92823e7ebcc756c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=8B=BE=E5=B9=B4?= <211154860@qq.com> Date: Fri, 18 Dec 2020 18:42:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=BA=9B=E5=B0=8F?= =?UTF-8?q?=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/index.php | 3 +-- extend/teambition.php | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controller/index.php b/app/controller/index.php index e415579..667a5b6 100644 --- a/app/controller/index.php +++ b/app/controller/index.php @@ -12,7 +12,7 @@ public function __init(){ public function index($url,$dirid=false){ $project = teambition::get_project($this->projectId,$this->cookie); - if($project){ + if($project && $project['_id']){ if(!$dirid){ $dirid = $project['_rootCollectionId']; $root = true; @@ -42,7 +42,6 @@ public function getDownload($url,$id){ $type = authstr($_GET['type']) ?: 302; $result = teambition::get_download_url($id,$this->cookie); if($result){ - $result = json_decode($result,true); if($result['fileType'] == 'mp4' and $_SERVER['HTTP_RANGE'] == NULL){ assign('item',$result); view('index/_play'); diff --git a/extend/teambition.php b/extend/teambition.php index 9ff00b1..59c10a1 100644 --- a/extend/teambition.php +++ b/extend/teambition.php @@ -151,8 +151,8 @@ public static function get_files($projectId,$dirId,$cookie,$page=1){ public static function get_download_url($parentId,$cookie){ $result = self::get('https://www.teambition.com/api/works/'.$parentId,$cookie); if($result){ - $resultArray = json_decode($result,true); - if($resultArray['downloadUrl']){ + $result = json_decode($result,true); + if($result['downloadUrl']){ return $result; }else{ return false; @@ -179,6 +179,7 @@ protected static function get($url,$cookie=false,$post=false,$header=false){ curl_setopt($ch, CURLOPT_POSTFIELDS,$post); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); } + curl_setopt($ch, CURLOPT_TIMEOUT,10); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);