<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Obtain extends Api_Controller {
public function __construct(){
parent::__construct();
$this->load->library('curl');
}
public function request_test(){
$url = 'http://ag12.ott.bangtv.tv/v30/program/menulist?parentCatgId=teleplay';
$headers = array(
"versionId"=>"3001",
"mac"=>"b0:d5:9d:19:eb:b5",
"agentVendorId"=>"bingotv",
"did"=>"BC79F0F2924390E41506FDC5B6EF934F",
"token"=>"0ca1895871aa8a5f096dd391deb57bb2",
"uid"=>"100004",
);
$result=$this->curl->http_header($headers)->simple_get($url);
print_r($result);
}
public function get_menulist(){
$url = 'http://ag12.ott.bangtv.tv/v30/program/menulist';
$headers = array(
"versionId"=>"3001",
"mac"=>"b0:d5:9d:19:eb:b5",
"agentVendorId"=>"bingotv",
"did"=>"BC79F0F2924390E41506FDC5B6EF934F",
"token"=>"0ca1895871aa8a5f096dd391deb57bb2",
"uid"=>"100004",
);
$this->load->model('tv_type_model','tv_type');
$data['tv_type']=$this->tv_type
->select_all("tv_type.*",null,null,null,$page_no,"tv_type");
foreach (json_decode(json_encode($data['tv_type']))->list as $type) {
$url='http://ag12.ott.bangtv.tv/v30/program/menulist?parentCatgId='.$type->menu_name;
$result=$this->curl->http_header($headers)->simple_get($url);
if(sizeof(json_decode($result)->menuList)>0){
foreach (json_decode($result)->menuList as $menu) {
$tv_type['menu_id']=$menu->id;
$tv_type['menu_name']=$menu->name;
$tv_type['type_name']=$menu->name;
$tv_type['node_type']=$menu->nodeType;
$tv_type['action']=$menu->action;
$tv_type['parent_id']=$type->menu_name;
$where=" where menu_id='".$menu->id."'";
$sql="select * from `tv_type` ".$where;
$data['menu']=$this->tv_type->execute($sql,false,0);
if(json_encode($data['menu'])!='null'){
$i=$this->tv_type->update($tv_type, array('id='.json_decode(json_encode($data['menu']))->id));
}else{
$i=$this->tv_type->insert($tv_type);
}
};
};
}
}
public function get_movielist(){
$url = 'http://ag12.ott.bangtv.tv/v30/program/movielist';
$headers = array(
"versionId"=>"3001",
"mac"=>"b0:d5:9d:19:eb:b5",
"agentVendorId"=>"bingotv",
"did"=>"BC79F0F2924390E41506FDC5B6EF934F",
"token"=>"0ca1895871aa8a5f096dd391deb57bb2",
"uid"=>"100004",
);
$this->load->model('tv_type_model','tv_type');
$this->load->model('program_model','program');
$where=array();
array_push($where,"parent_id =0");
echo count($where);
if(count($where)>0)
$this->tv_type->where($where);
$data['tv_type']=$this->tv_type
->select_all("tv_type.*",null,null,null,$page_no,"tv_type");
foreach (json_decode(json_encode($data['tv_type']))->list as $type) {
echo 'menu_name'.$type->menu_name;
$url='http://ag12.ott.bangtv.tv/v30/program/movielist?parentCatgId='.$type->menu_name;
echo $url;
$result=$this->curl->http_header($headers)->simple_get($url);
echo 'programList'.sizeof(json_decode($result)->programList);
if(sizeof(json_decode($result)->programList)>0){
foreach (json_decode($result)->programList as $program) {
$programdetails['program_id']=$program->id;
$programdetails['e_name']=$program->name;
$programdetails['c_name']=$program->name;
$programdetails['menu_id']=$type->menu_name;
$programdetails['type_id']=$type->id;
$programdetails['image']=$program->image;
$programdetails['isNews']=$program->isNews;
$programdetails['cornerPrice']=$program->cornerPrice;
$programdetails['cornerType']=$program->cornerType;
$programdetails['currentNum']=$program->currentNum;
$where=" where program_id='".$program->id."'";
$sql="select * from `program` ".$where;
$data['program']=$this->program->execute($sql,false,0);
echo 'program'.json_encode($data['program']);
if(json_encode($data['program'])!='null'){
echo 'dd';
$i=$this->program->update($programdetails, array('id='.json_decode(json_encode($data['program']))->id));
}else{
echo 'ff';
$i=$this->program->insert($programdetails);
}
};
};
}
}
public function get_moviedetail(){
$url = 'http://ag12.ott.bangtv.tv/v30/program/moviedetail';
$headers = array(
"versionId"=>"3001",
"mac"=>"b0:d5:9d:19:eb:b5",
"agentVendorId"=>"bingotv",
"did"=>"BC79F0F2924390E41506FDC5B6EF934F",
"token"=>"0ca1895871aa8a5f096dd391deb57bb2",
"uid"=>"100004",
);
$this->load->model('program_details_model','program_details');
$this->load->model('program_model','program');
$this->load->model('video_source_model','video_source');
$data['program']=$this->program
->join("tv_type","tv_type.id=program.type_id")
->select_all("program.*",null,null,null,1,"program");
foreach (json_decode(json_encode($data['program']))->list as $program) {
$url='http://ag12.ott.bangtv.tv/v30/detail/moviedetail?programSeriesId='.$program->program_id;
$result=$this->curl->http_header($headers)->simple_get($url);
if(json_decode($result)!=''){
echo json_decode($result)->id;
$program_details['program_id']=json_decode($result)->id;
$program_details['parent_root_item_id']=json_decode($result)->parent_root_item_id;
$program_details['program_name']=json_decode($result)->name;
$program_details['showid']=json_decode($result)->showid;
$program_details['length']=json_decode($result)->length;
$program_details['type']=json_decode($result)->type;
$program_details['class']=json_decode($result)->class;
$program_details['zone']=json_decode($result)->zone;
$program_details['director']=json_decode($result)->director;
$program_details['actor']=json_decode($result)->actor;
$program_details['releaseDate']=json_decode($result)->releaseDate;
$program_details['grade']=json_decode($result)->grade;
$program_details['picurl']=json_decode($result)->picurl;
$program_details['information']=json_decode($result)->information;
$program_details['totalCount']=json_decode($result)->totalCount;
$program_details['price']=json_decode($result)->price;
$program_details['lastest']=json_decode($result)->lastest;
$program_details['serverbuy']=json_decode($result)->serverbuy;
$program_details['islogin']=json_decode($result)->islogin;
$program_details['isplay']=json_decode($result)->isplay;
foreach (json_decode($result)->sources as $sources) {
$video_source['source_id']=$sources->id;
$video_source['program_id']=$program->id;
$video_source['program_name']=$sources->name;
$video_source['program_sid']=$program->program_id;
$video_source['istry']=$sources->istry;
$video_source['length']=$sources->length;
$video_source['videoid']=$sources->videoid;
$video_source['volumncount']=$sources->volumncount;
foreach ($sources->playlist as $play) {
$video_source['relive']=$play->relive;
$video_source['type']=$play->type;
$video_source['source_url']=$play->playurl;
}
};
$where=" where program_id='".json_decode($result)->id."'";
$sql="select * from `program_details` ".$where;
$data['program_details']=$this->program_details->execute($sql,false,0);
if(json_encode($data['program_details'])!='null'){
echo 'dd';
$i=$this->program_details->update($program_details, array('id='.json_decode(json_encode($data['program_details']))->id));
}else{
echo 'ff';
$i=$this->program_details->insert($program_details);
}
};
}
}
public function getdd(){
echo "dd";
}
public function get_channellist(){
$url = 'http://ag12.ott.bangtv.tv/v30/live/channellist';
$headers = array(
"versionId"=>"3001",
"mac"=>"b0:d5:9d:19:eb:b5",
"agentVendorId"=>"bingotv",
"did"=>"BC79F0F2924390E41506FDC5B6EF934F",
"token"=>"0ca1895871aa8a5f096dd391deb57bb2",
"uid"=>"100004",
);
$this->load->model('channel_model','channel');
$result=$this->curl->http_header($headers)->simple_get($url);
if(sizeof(json_decode($result))>0){
foreach (json_decode($result) as $channel) {
$c['channelId']=$channel->channelId;
$c['channel_name']=$channel->channelName;
$c['logo']=$channel->logo;
$c['no']=$channel->no;
$c['urlType']=$channel->urlType;
$c['urlid']=$channel->urlid;
$c['groupid']=$channel->groupid;
$c['groupname']=$channel->groupname;
$c['onplay']=$channel->onplay;
$c['programId']=$channel->programId;
$c['isOpen']=$channel->isOpen;
$c['isVip']=$channel->isVip;
$c['isplay']=$channel->isplay;
$where=" where channelId='".$channel->channelId."'";
$sql="select * from `channel` ".$where;
$data['channel']=$this->channel->execute($sql,false,0);
if(json_encode($data['channel'])!='null'&&json_encode($data['channel'])!=null){
$i=$this->channel->update($c, array('id='.json_decode(json_encode($data['channel']))->id));
}else{
$i=$this->channel->insert($c);
}
};
};
}
}