Selaa lähdekoodia

转码 注入

15954078560 2 vuotta sitten
vanhempi
commit
57930f872e
2 muutettua tiedostoa jossa 142 lisäystä ja 0 poistoa
  1. 138 0
      application/api/controller/Notify.php
  2. 4 0
      public/assets/js/backend/video.js

+ 138 - 0
application/api/controller/Notify.php

@@ -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('成功');
+    }
+
+
 }

+ 4 - 0
public/assets/js/backend/video.js

@@ -40,6 +40,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
+                        {field: 'transcode_status', title: __('转码状态'), searchList: {"0":__('待转码'),"1":__('转码中'),"2":__('转码完成'),"3":__('转码失败')}, formatter: Table.api.formatter.status},
+                        {field: 'task_id', title: __('转码任务ID'), operate: false},
+                        {field: 'file_url', title: __('文件银河转码后地址'), operate: false},
+                        {field: 'inject_status', title: __('注入状态'), searchList: {"0":__('待注入'),"1":__('注入中'),"2":__('注入成功'),"3":__('注入失败')}, formatter: Table.api.formatter.status},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]