7 changed files with 167 additions and 121 deletions
@ -0,0 +1,77 @@ |
|||
<?php |
|||
|
|||
namespace app\task\controller; |
|||
|
|||
use think\Db; |
|||
|
|||
class Video |
|||
{ |
|||
public function run() |
|||
{ |
|||
$config = config('api_config'); |
|||
$url = $config['host_url'] . "/api/resource/v1/cameras"; |
|||
$token = getAccessToken(); |
|||
|
|||
# 获取视频资源 |
|||
try { |
|||
|
|||
$dataArr = [ |
|||
'pageNo' => 1, |
|||
'pageSize' => 100, |
|||
]; |
|||
$json_data = json_encode($dataArr); |
|||
$result = postToken($url,$json_data,false,[],$token); |
|||
|
|||
$res_data = json_decode($result,true); |
|||
if ($res_data['code'] != 0) throw new \Exception('请求失败'); |
|||
$list = (array)$res_data['data']['list']; |
|||
|
|||
$requestData = []; |
|||
foreach ($list as $row) { |
|||
|
|||
# 获取监控点视频链接 |
|||
$cameraIndexCode = $row['cameraIndexCode']; |
|||
$url2 = $config['host_url'] . "/api/video/v2/cameras/previewURLs"; |
|||
$dataArr2 = [ |
|||
'cameraIndexCode' => $cameraIndexCode, |
|||
'streamType' => 0, |
|||
'transmode' => $row['transType'], |
|||
'expand' => 'transcode=0', |
|||
'protocol' => 'rtmp', |
|||
'streamform' => 'ps' |
|||
]; |
|||
$json_data2 = json_encode($dataArr2); |
|||
$result2 = postToken($url2,$json_data2,false,[],$token); |
|||
$res_data2 = json_decode($result2,true); |
|||
if ($res_data2['code'] != 0) throw new \Exception('请求失败'); |
|||
$list2 = (array)$res_data2['data']; |
|||
foreach ($list2 as $row2) { |
|||
|
|||
$requestData[] = $insert = [ |
|||
'cameraIndexCode' => $cameraIndexCode, |
|||
'cameraName' => $row['cameraName'], |
|||
'cameraType' => $row['cameraType'], |
|||
'cameraTypeName' => $row['cameraTypeName'], |
|||
'regionIndexCode' => $row['regionIndexCode'], |
|||
'transTypeName' => $row['transTypeName'], |
|||
'transType' => $row['transType'], |
|||
'createTime' => $row['createTime'], |
|||
'url' => $row2 |
|||
]; |
|||
|
|||
Db::table('bt_video')->insert($insert); |
|||
} |
|||
} |
|||
$requestRes = \app\common\model\Pass::requestCreateData($requestData,'/api/pass.create/createVideo', $config['host_path']); |
|||
|
|||
if (!$requestRes['status']) { |
|||
return $requestRes['msg']; |
|||
} |
|||
|
|||
} catch (\Exception $e) { |
|||
return $e->getMessage(); |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
<?php |
|||
|
|||
// [ 支付通知入口文件 ] |
|||
|
|||
// 手动定义路由 |
|||
$_GET['s'] = '/task/video/run'; |
|||
|
|||
// 定义运行目录 |
|||
define('WEB_PATH', __DIR__ . 'video.php/'); |
|||
|
|||
// 定义应用目录 |
|||
define('APP_PATH', WEB_PATH . '../source/application/'); |
|||
|
|||
// 加载框架引导文件 |
|||
require APP_PATH . '../thinkphp/start.php'; |
|||
Loading…
Reference in new issue