|
@@ -580,4 +580,142 @@ class Notify extends Api
|
|
|
echo 'wan bi';
|
|
|
die;
|
|
|
}
|
|
|
+
|
|
|
+ //视频转码
|
|
|
+ public function transcode() {
|
|
|
+ set_time_limit(0);
|
|
|
+
|
|
|
+ $where = array(
|
|
|
+ 'transcode_status' => 0
|
|
|
+ );
|
|
|
+
|
|
|
+ $hu_video = Db::name('video');
|
|
|
+ $list = $hu_video->where($where)->limit(50)->select();
|
|
|
+
|
|
|
+ if (!$list) {
|
|
|
+ echo 'mei shu ju';
|
|
|
+ die;
|
|
|
+ }
|
|
|
+
|
|
|
+ $url = 'http://api.trans.gitv.tv/upload';
|
|
|
+ $data['cp_id'] = config('cp_id');
|
|
|
+ $data['media_type'] = 'mp4';
|
|
|
+ foreach ($list as &$v) {
|
|
|
+ $data['uri'] = urlencode(config('upload.cdnurl') . $v['videofile']);
|
|
|
+ $data['file_name'] = urlencode($v['title']);
|
|
|
+
|
|
|
+ $request_url = $url . '?' . http_build_query($data);
|
|
|
+ $rs = file_get_contents($request_url);
|
|
|
+ if (!$rs) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $rs = json_decode($rs);
|
|
|
+ if ($rs['code'] == 'A000000') {
|
|
|
+ $hu_video->where(['id' => $v['id'], 'transcode_status' => 0])->setField(['transcode_status' => 1, 'task_id' => $rs['task_id']]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ echo 'wan bi';
|
|
|
+ die;
|
|
|
+ }
|
|
|
+
|
|
|
+ //视频转码回执
|
|
|
+ public function transcodecallback() {
|
|
|
+ $cp_id = input('cp_id', 0, 'intval');
|
|
|
+ $file_url = input('file_url', '', 'trim');
|
|
|
+ $task_id = input('task_id', '', 'trim');
|
|
|
+
|
|
|
+ if ($cp_id != config('cp_id')) {
|
|
|
+ $this->error('错误1');
|
|
|
+ }
|
|
|
+ $info = Db::name('video')->where(['task_id' => $task_id])->find();
|
|
|
+ if (!$info) {
|
|
|
+ $this->error('错误2');
|
|
|
+ }
|
|
|
+ if ($info['transcode_status'] != 1) {
|
|
|
+ $this->success('已完成');
|
|
|
+ }
|
|
|
+
|
|
|
+ $file_url = urldecode($file_url);
|
|
|
+ $rs = Db::name('video')->where(['id' => $info['id'], 'transcode_status' => 1])->setField(['transcode_status' => 2, 'file_url' => $file_url]);
|
|
|
+ if (!$rs) {
|
|
|
+ $this->error('失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ //视频注入
|
|
|
+ public function inject() {
|
|
|
+ set_time_limit(0);
|
|
|
+
|
|
|
+ $where = array(
|
|
|
+ 'transcode_status' => 2,
|
|
|
+ 'inject_status' => 0
|
|
|
+ );
|
|
|
+
|
|
|
+ $hu_video = Db::name('video');
|
|
|
+ $list = $hu_video->where($where)->limit(50)->select();
|
|
|
+
|
|
|
+ if (!$list) {
|
|
|
+ echo 'mei shu ju';
|
|
|
+ die;
|
|
|
+ }
|
|
|
+
|
|
|
+ $url = 'http://api.gs.gitv.tv/upload';
|
|
|
+ $data['cp_id'] = config('cp_id');
|
|
|
+ $data['bit_id'] = 5;
|
|
|
+ $data['file_type'] = 'm3u8';
|
|
|
+ foreach ($list as &$v) {
|
|
|
+ $data['album_id'] = (string)$v['id'];
|
|
|
+ $data['video_id'] = (string)$v['id'];
|
|
|
+ $data['uri'] = $v['file_url'];
|
|
|
+
|
|
|
+ $rs = httpRequest($url, 'POST', $data);
|
|
|
+ if (!$rs) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $rs = json_decode($rs);
|
|
|
+ if ($rs['code'] == 'A000000') {
|
|
|
+ $hu_video->where(['id' => $v['id'], 'inject_status' => 0])->setField(['inject_status' => 1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ echo 'wan bi';
|
|
|
+ die;
|
|
|
+ }
|
|
|
+
|
|
|
+ //视频注入回执
|
|
|
+ public function injectcallback() {
|
|
|
+ $cp_id = input('cp_id', 0, 'intval');
|
|
|
+ $album_id = input('album_id', '', 'trim'); //专辑 ID
|
|
|
+ $video_id = input('video_id', '', 'trim'); //剧集 ID
|
|
|
+ $code = input('code', '', 'trim'); //状态码
|
|
|
+
|
|
|
+ if ($cp_id != config('cp_id')) {
|
|
|
+ $this->error('错误1');
|
|
|
+ }
|
|
|
+ $info = Db::name('video')->where(['id' => $video_id])->find();
|
|
|
+ if (!$info) {
|
|
|
+ $this->error('错误2');
|
|
|
+ }
|
|
|
+ if ($info['inject_status'] != 1) {
|
|
|
+ $this->success('已完成');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($code == 'A000000') {
|
|
|
+ $inject_status = 2;
|
|
|
+ } else {
|
|
|
+ $inject_status = 3;
|
|
|
+ }
|
|
|
+
|
|
|
+ $rs = Db::name('video')->where(['id' => $info['id'], 'inject_status' => 1])->setField(['inject_status' => $inject_status]);
|
|
|
+ if (!$rs) {
|
|
|
+ $this->error('失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('成功');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|