示例#1
0
 public function get_program()
 {
     if (!$this->input['channel_id']) {
         $this->errorOutput(NOID);
     }
     //根据频道id查询出该频道对应的节目单
     $program = new program();
     $program_data = $program->getTimeshift($this->input['channel_id']);
     if ($program_data) {
         $this->addItem($program_data);
         $this->output();
     }
 }
示例#2
0
 public function create()
 {
     $ret = array();
     $ret['channel_id'] = $this->input['channel_id'];
     if (!$ret['channel_id']) {
         $this->errorOutput('未传入频道ID');
     }
     //请求频道信息
     include_once ROOT_PATH . 'lib/program.class.php';
     $program = new program();
     $channel = $program->getTimeshift($ret['channel_id']);
     //		$live_channel = new curl($this->settings['App_live']['host'],$this->settings['App_live']['dir']);
     //		$live_channel->setSubmitType('post');
     //		$live_channel->setReturnFormat('json');
     //		$live_channel->initPostData();
     //		$live_channel->addRequestData('id',$ret['channel_id']);
     //		$channel_ret = $live_channel->request('admin/channel.php');
     //		$channel = $channel_ret[0];
     if (!$channel) {
         $this->errorOutput('该频道已经不存在!');
     }
     if (!$channel['open_ts']) {
         $this->errorOutput('该频道未启动手机流,无法获取时移数据!');
     }
     $channel_exists = 1;
     //视频信息入库
     $ret['title'] = urldecode($this->input['title']) ? urldecode($this->input['title']) : '精彩节目';
     $ret['starttime'] = strtotime(trim(urldecode($this->input['start_time'])));
     $ret['endtime'] = strtotime(trim(urldecode($this->input['end_time'])));
     $ret['duration'] = $ret['endtime'] - $ret['starttime'];
     if ($ret['starttime'] >= $ret['endtime']) {
         $this->errorOutput('时间设置不正确!');
     }
     $save_time = TIMENOW - ($channel['time_shift'] * 3600 - $channel['delay']);
     if ($ret['starttime'] < $save_time) {
         $this->errorOutput('此条录制已超过回看时间!');
     }
     if ($ret['endtime'] > TIMENOW) {
         $this->errorOutput('录制节目的结束时间必须小于当前时间!');
     }
     $data = array('title' => $ret['title'], 'user_id' => $this->user['user_id'], 'addperson' => $this->user['user_name'], 'subtitle' => $this->input['subtitle'], 'author' => $this->input['author'], 'keywords' => $this->input['keywords'], 'vod_sort_id' => $this->input['item'], 'delay_time' => $channel['delay_time'], 'starttime' => $ret['starttime'], 'channel_id' => $ret['channel_id'], 'duration' => $ret['duration'], 'column_id' => $this->input['column_id'], 'comment' => $this->input['comment'], 'create_time' => $ret['starttime'], 'update_time' => $ret['starttime']);
     $sql = 'INSERT INTO ' . DB_PREFIX . 'vodinfo SET ';
     $space = '';
     foreach ($data as $key => $value) {
         $sql .= $space . $key . '="' . $value . '"';
         $space = ',';
     }
     $this->db->query($sql);
     $insert_id = $this->db->insert_id();
     $sql = "UPDATE " . DB_PREFIX . "vodinfo SET video_order_id = " . $insert_id . " WHERE id = " . $insert_id;
     $this->db->query($sql);
     //请求转码服务器路径配置
     $record_config = new curl($this->settings['App_live']['host'], $this->settings['App_live']['dir']);
     $record_config->setSubmitType('post');
     $record_config->setReturnFormat('json');
     $record_config->initPostData();
     $record_config->addRequestData('open_ts', 1);
     $record_config = $record_config->request('admin/record_server_config.php');
     $record_config = $record_config[0]['mms']['record_server'];
     $this->curl = new curl($record_config['host'], $record_config['dir']);
     //向转码服务器提交数据
     $duration = $ret['duration'] . '000';
     $starttime = $ret['starttime'] . '000';
     $url = $channel['streams'][0]['m3u8_dvr'] . '?dvr&duration=' . $duration . '&starttime=' . $starttime;
     $callback = $this->settings['App_mediaserver']['protocol'] . $this->settings['App_mediaserver']['host'] . '/' . $this->settings['App_mediaserver']['dir'] . 'admin/record_callback.php';
     $data = array();
     $data = array('id' => $insert_id, 'time_shift' => 1, 'video_order_id' => $insert_id, 'action' => 'TIMESHIFT', 'url' => urlencode($url), 'callback' => urlencode($callback), 'uploadFile' => 0, 'title' => $ret['title'], 'program' => $ret['title'], 'appid' => $this->user['appid'], 'appkey' => $this->input['appkey'], 'access_token' => $this->user['token'], 'vod_sort_id' => $this->input['item'], 'comment' => $this->input['comment']);
     foreach ($data as $k => $v) {
         if (empty($v) && $v != 0) {
             continue;
         }
         $this->curl->addRequestData($k, $v);
     }
     $record_xml = $this->curl->request('');
     //返回视频信息
     $sql = "SELECT id,name as sort_name FROM " . DB_PREFIX . "vod_media_node WHERE id=" . $this->input['item'];
     $sort = $this->db->query_first($sql);
     $return = array('id' => $insert_id, 'row_id' => $insert_id, 'video_order_id' => $insert_id, 'title' => $ret['title'], 'bitrate' => 0, 'vod_sort_id' => $sort['sort_name'], 'status' => '转码中', 'bitrate' => 0, 'author' => '', 'addperson' => 'MCP网页版', 'comment' => '', 'starttime' => '(' . date('Y-m-d', $ret['starttime']) . ')', 'delay_time' => $ret['delay_time'], 'copyright' => '', 'subtitle' => '', 'height' => 0, 'start' => 0, 'duration' => time_format(intval($ret['endtime']) - intval($ret['starttime'])), 'width' => 0, 'keywords' => $this->input['keywords'], 'type' => '', 'transize' => '', 'totalsize' => '', 'audit' => '', 'flag' => '', 'collects' => '', 'create_time' => date("Y-m-d H:i:s", TIMENOW), 'update_time' => date("Y-m-d H:i:s", TIMENOW), 'ip' => hg_getip(), 'original_id' => 0, 'mark_count' => 0, 'mark_etime' => 0, 'isfile' => 0, 'audio' => '', 'audio_channels' => '', 'sampling_rate' => '', 'video' => '', 'frame_rate' => '', 'aspect' => '', 'trans_use_time' => '', 'sort_name' => $sort['sort_name'], 'vod_sort_color' => $sort['color'], 'bitrate_color' => '#2f4974', 'vodurl' => '', 'etime' => intval($ret['duration']) + intval($ret['start']), 'is_go' => $this->input['goon']);
     $this->addItem($return);
     $this->output();
 }