体育管项目脚本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.7 KiB

<?php
namespace task\tasks;
use task\module\Pass\Pass;
$Video = new Video();
echo $Video->run();
class Video
{
public function run()
{
include_once '../common.php';
include_once '../module/Pass/Pass.php';
$config = config('api_config');
$url = $config['host_url'] . "/api/resource/v1/cameras";
$token = get_access_token();
# 获取视频资源
try {
$dataArr = [
'pageNo' => 1,
'pageSize' => 100,
];
$json_data = json_encode($dataArr);
$result = post_token($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 = post_token($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
];
}
}
$requestRes = Pass::requestCreateData($requestData,'/api/pass.create/createVideo', $config['host_path']);
if (!$requestRes['status']) {
return $requestRes['msg'];
}
} catch (\Exception $e) {
return $e->getMessage();
}
return true;
}
}