/** * 显示 */ function show() { include CUR_CONF_PATH . 'lib/tvie_api.php'; $tvie_api = new TVie_api($this->settings['tvie']['up_stream_server']); //create_channel_epg($channel_id, $start_time, $end_time, $uri, $uptodate = 1, $description = ''); $channel_id = 334; $start_time = time() + 250; $end_time = $start_time + 120; $uri = 'tvie://stream.dev.hogesoft.com/live/hoge/touch/sd/'; $ret1 = $tvie_api->create_channel_epg($channel_id, $start_time, $end_time, $uri, '安徽公共'); $ret1 = $tvie_api->get_channel_epg_by_id($ret1['result']['id']); $start_time = $end_time; $end_time = $start_time + 120; $uri = 'tvie://stream.dev.hogesoft.com/live/hoge/lizhi/cd/'; $ret2 = $tvie_api->create_channel_epg($channel_id, $start_time, $end_time, $uri, '安徽科教'); $ret2 = $tvie_api->get_channel_epg_by_id($ret2['result']['id']); $start_time = $end_time; $end_time = $start_time + 120; $uri = 'tvie://stream.dev.hogesoft.com/live/hoge/boluo/sd/'; $ret3 = $tvie_api->create_channel_epg($channel_id, $start_time, $end_time, $uri, '安徽经济'); $ret3 = $tvie_api->get_channel_epg_by_id($ret3['result']['id']); echo '<pre>'; print_r($ret1); print_r($ret2); print_r($ret3); }
/** * 计划任务执行 * @name show * @access public * @author lijiaying * @category hogesoft * @copyright hogesoft * @include tvie_api.php */ public function show() { if ($this->settings['tvie']['open']) { include CUR_CONF_PATH . 'lib/tvie_api.php'; $tvie_api = new TVie_api($this->settings['tvie']['up_stream_server']); } $tomorrow_date = date("Y-m-d", TIMENOW + 3600 * 24); $week = date("N", TIMENOW + 3600 * 24); $sql = "SELECT * FROM " . DB_PREFIX . "channel WHERE 1 "; $q = $this->db->query($sql); $all_channel_id = $chg_ids = array(); while ($r = $this->db->fetch_array($q)) { if ($r['is_live'] && $r['save_time'] >= 24) { $all_channel_id[$r['id']] = $r['id']; $chg_ids[$r['id']] = $r['chg_id']; } } if (!empty($all_channel)) { $channel_id = implode(',', $all_channel_id); $sql = "SELECT * FROM " . DB_PREFIX . "change_plan p left join " . DB_PREFIX . "change_plan_relation r on r.plan_id=p.id where 1 and p.channel_id IN (" . $channel_id . ") and r.week_num=" . $week; $q = $this->db->query($sql); $sql_extra = $space = ''; while ($r = $this->db->fetch_array($q)) { $week_days = $r['week_days']; $week_d = date('N', TIMENOW); $week = date('W', $r['program_start_time']); $this_week = date('W', TIMENOW); $offset_week = ($this_week - $week) * 24 * 3600 * 7; if ($week_days == $week_d) { $program_start_time = date('Y-m-d H:i:s', $r['program_start_time'] + $offset_week); } else { if ($week_days > $week_d) { $program_start_time = date('Y-m-d H:i:s', $r['program_start_time'] - 86400 * ($week_days - $week_d) + $offset_week); } else { if ($week_days < $week_d) { $program_start_time = date('Y-m-d H:i:s', $r['program_start_time'] + 86400 * ($week_d - $week_days) + $offset_week); } } } if ($r['program_start_time']) { $stream_uri = substr($r['stream_uri'], 0, -27) . strtotime($program_start_time) . '000,' . (strtotime($program_start_time) + $r['toff']) . '000'; } $start = strtotime($tomorrow_date . ' ' . date('H:i:s', $r['start_time'])); $end = strtotime($tomorrow_date . ' ' . date('H:i:s', $r['start_time'] + $r['toff'])); if ($tvie_api) { $epg = $tvie_api->create_channel_epg($chg_ids[$r['channel_id']], $start, $end, $stream_uri, '播放' . $r['channel2_name'] . '的节目'); } $epg_id = $epg['result']['id']; $sql_extra .= $space . "(" . $r['channel_id'] . "," . $r['channel2_id'] . ",'" . $r['channel2_name'] . "'," . $epg_id . ",'" . $stream_uri . "'," . strtotime($tomorrow_date . ' ' . date('H:i:s', $r['start_time'])) . "," . strtotime($program_start_time) . ",'" . $tomorrow_date . "'," . $r['toff'] . "," . $r['type'] . "," . TIMENOW . "," . TIMENOW . ",'" . hg_getip() . "','" . $r['admin_name'] . "'," . $r['admin_id'] . ")"; $space = ","; } $sql = "INSERT INTO " . DB_PREFIX . "channel_chg_plan(channel_id,channel2_id,channel2_name,epg_id,stream_uri,change_time,program_start_time,dates,toff,type,create_time,update_time,ip,admin_name,admin_id) values" . $sql_extra; $this->db->query($sql); } }
/** * 创建、更新 串联单 * @name create * @access public * @author lijiaying * @category hogesoft * @copyright hogesoft * @param $channel_id int 频道ID * @param $date string 日期 * @param $chg_plan_ids array 串联单ID * @param $start_time array 开始时间 * @param $end_time array 结束时间 * @param $type array 来源类型 * @param $channel2_id array 来源类型ID * @param $channel2_name array 来源类型名称 * @param $program_start_time array 时移开始时间 * @param $epg_id array 32接口返回串联单ID * @param $hidden_temp array 标记该条串联单是否被修改过 (1-是 0-否) * @param $toff array 时长 * @param $uri array 流地址 * @param $create_time array 创建时间 * @param $update_time array 更新时间 * @param $admin_id array 用户ID * @param $admin_name array 用户名 * @param $ip array 创建者IP * @return $ids array 创建成功串联单IDD * @include tvie_api.php */ function edit() { $channel_id = intval($this->input['channel_id']); if (!$channel_id) { $this->errorOutput('请选择频道'); } $date = urldecode($this->input['chg_date']); if ($date < date('Y-m-d')) { $this->errorOutput('此日期已过,无法设置串联单'); } $sql = "SELECT chg_id, is_live FROM " . DB_PREFIX . "channel WHERE id=" . $channel_id; $channel_info = $this->db->query_first($sql); if (!$channel_info['is_live']) { $this->errorOutput('该频道不支持播控或频道不存在'); } $chg_plan_ids = $this->input['ids']; $start_time = $this->input['start_times']; $end_time = $this->input['end_times']; $type = $this->input['type']; $channel2_id = $this->input['channel2_ids']; $channel2_name = $this->input['channel2_name']; $program_start_time = $this->input['program_start_time']; $epg_id = $this->input['epg_id']; $hidden_temp = $this->input['hidden_temp']; if (!$start_time) { $this->errorOutput('未设置任何串联单'); } if (!$this->verify_timeline($this->input['start_times'], $this->input['end_times'], $this->input['chg_date'])) { $this->errorOutput('时间设置存在重复'); } $this->set_chg_uris($channel2_id, $type); if ($this->settings['tvie']['open']) { include CUR_CONF_PATH . 'lib/tvie_api.php'; $tvie_api = new TVie_api($this->settings['tvie']['up_stream_server']); } $ids = array(); foreach ($chg_plan_ids as $i => $id) { if (strlen($id) >= 12) { $id = ''; } $uri = $this->mChgUris[$i]; if (!$uri) { continue; } $start = strtotime($date . ' ' . urldecode($start_time[$i])); $end = strtotime($date . ' ' . urldecode($end_time[$i])); $toff = $end - $start; if ($program_start_time[$i]) { $program_start = strtotime(urldecode($program_start_time[$i])); $uri .= $program_start . '000,' . ($program_start + $toff) . '000'; } $epg = array(); if ($tvie_api && $id) { if ($hidden_temp[$i]) { $epg = $tvie_api->update_channel_epg($channel_info['chg_id'], $epg_id[$i], $start, $end, $uri, '播放' . urldecode($channel2_name[$i]) . '的节目'); } } else { $epg = $tvie_api->create_channel_epg($channel_info['chg_id'], $start, $end, $uri, '播放' . urldecode($channel2_name[$i]) . '的节目'); } $data = array('channel_id' => $channel_id, 'channel2_id' => $channel2_id[$i], 'channel2_name' => urldecode($channel2_name[$i]), 'change_time' => $start, 'toff' => $toff, 'type' => $type[$i], 'stream_uri' => $uri, 'program_start_time' => $program_start); if ($id) { if ($hidden_temp[$i]) { $data['update_time'] = TIMENOW; $sql = "UPDATE " . DB_PREFIX . "channel_chg_plan SET "; $space = ""; $sql_extra = ""; foreach ($data as $key => $value) { if ($value) { $sql_extra .= $space . $key . "=" . "'" . $value . "'"; $space = ","; } } if ($sql_extra) { $sql .= $sql_extra . " WHERE id=" . $id; $this->db->query($sql); } $ids[] = $id; } } else { $data['epg_id'] = $epg['result']['id']; $data['dates'] = $date; $data['create_time'] = TIMENOW; $data['update_time'] = TIMENOW; $data['admin_name'] = $this->user['user_name']; $data['admin_id'] = $this->user['user_id']; $data['ip'] = hg_getip(); $createsql = "INSERT INTO " . DB_PREFIX . "channel_chg_plan SET "; $space = ""; foreach ($data as $key => $value) { $createsql .= $space . $key . "=" . "'" . $value . "'"; $space = ","; } $ret = array(); $this->db->query($createsql); $ret['id'] = $this->db->insert_id(); $ids[] = $ret['id']; } } return $ids; // $this->setXmlNode('channel_chg_plan' ,'data'); // $this->addItem($ids); // $this->output(); }
/** * 复制串联单 * @name copy_day * @access public * @author lijiaying * @category hogesoft * @copyright hogesoft * @param $channel_id int 频道ID * @param $dates string 日期 * @param $copy_dates string 要复制的日期 * @return $tip array 复制成功后返回 1 * @include tvie_api.php */ public function copy_day() { $channel_id = $this->input['channel_id']; if (!$channel_id) { $this->errorOutput("未传入频道ID"); } $dates = urldecode($this->input['dates']); //源日期 if (!$dates) { $this->errorOutput("未传入更新日期"); } $copy_dates = urldecode($this->input['copy_dates']); if (!$copy_dates) { $this->errorOutput("未传入要复制的日期"); } $sql = "SELECT * FROM " . DB_PREFIX . "channel_chg_plan WHERE channel_id=" . $channel_id . " AND dates='" . $dates . "'"; $q = $this->db->query($sql); $chg_info = array(); while ($row = $this->db->fetch_array($q)) { $chg_info[] = $row; } $diff = strtotime($copy_dates) - strtotime($dates); if ($this->settings['tvie']['open']) { include CUR_CONF_PATH . 'lib/tvie_api.php'; $tvie_api = new TVie_api($this->settings['tvie']['up_stream_server']); } $sql = "DELETE FROM " . DB_PREFIX . "channel_chg_plan WHERE channel_id=" . $channel_id . " AND dates='" . $copy_dates . "'"; $this->db->query($sql); if ($chg_info) { foreach ($chg_info as $k => $v) { $start = $v['change_time'] + $diff; $end = $v['change_time'] + $v['toff'] + $diff; if ($v['program_start_time']) { $program_start_time = $v['program_start_time'] + $diff; $stream_uri = substr($v['stream_uri'], 0, -27) . $program_start_time . '000,' . ($program_start_time + $v['toff']) . '000'; } else { $program_start_time = 0; $stream_uri = $v['stream_uri']; } if ($tvie_api) { $epg = $tvie_api->create_channel_epg($v['channel2_id'], $start, $end, $stream_uri, '播放' . $v['channel2_name'] . '的节目'); } $info = array('channel_id' => $v['channel_id'], 'channel2_id' => $v['channel2_id'], 'channel2_name' => $v['channel2_name'], 'epg_id' => $epg['result']['id'], 'stream_uri' => $stream_uri, 'change_time' => $start, 'program_start_time' => $program_start_time, 'dates' => $copy_dates, 'toff' => $v['toff'], 'type' => $v['type'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip(), 'admin_name' => $this->user['user_name'], 'admin_id' => $this->user['user_id']); $createsql = "INSERT INTO " . DB_PREFIX . "channel_chg_plan SET "; $space = ""; foreach ($info as $key => $value) { $createsql .= $space . $key . "=" . "'" . $value . "'"; $space = ","; } $this->db->query($createsql); } } $tip = array('ret' => 1); $this->addItem($tip); $this->output(); }