Update epg2xml.php
This commit is contained in:
parent
a422a6f8a1
commit
09aa603d93
159
epg2xml.php
159
epg2xml.php
@ -368,6 +368,7 @@ function GetEPGFromEPG($ChannelInfo) {
|
|||||||
);
|
);
|
||||||
$params = http_build_query($params);
|
$params = http_build_query($params);
|
||||||
$url = $url."?".$params;
|
$url = $url."?".$params;
|
||||||
|
$epginfo = array();
|
||||||
try {
|
try {
|
||||||
$response = @file_get_contents($url, False, $context);
|
$response = @file_get_contents($url, False, $context);
|
||||||
if ($response === False) :
|
if ($response === False) :
|
||||||
@ -476,6 +477,7 @@ function GetEPGFromKT($ChannelInfo) {
|
|||||||
);
|
);
|
||||||
$params = http_build_query($params);
|
$params = http_build_query($params);
|
||||||
$url = $url."?".$params;
|
$url = $url."?".$params;
|
||||||
|
$epginfo = array();
|
||||||
try {
|
try {
|
||||||
$response = @file_get_contents($url, False, $context);
|
$response = @file_get_contents($url, False, $context);
|
||||||
if ($response === False) :
|
if ($response === False) :
|
||||||
@ -527,6 +529,7 @@ function GetEPGFromKT($ChannelInfo) {
|
|||||||
'rebroadcast' => $rebroadcast,
|
'rebroadcast' => $rebroadcast,
|
||||||
'rating' => $rating
|
'rating' => $rating
|
||||||
);
|
);
|
||||||
|
|
||||||
writeProgram($programdata);
|
writeProgram($programdata);
|
||||||
endforeach;
|
endforeach;
|
||||||
endif;
|
endif;
|
||||||
@ -555,7 +558,7 @@ function GetEPGFromLG($ChannelInfo) {
|
|||||||
);
|
);
|
||||||
$params = http_build_query($params);
|
$params = http_build_query($params);
|
||||||
$url = $url."?".$params;
|
$url = $url."?".$params;
|
||||||
|
$epginfo = array();
|
||||||
try {
|
try {
|
||||||
$response = @file_get_contents($url, False, $context);
|
$response = @file_get_contents($url, False, $context);
|
||||||
if ($response === False) :
|
if ($response === False) :
|
||||||
@ -803,85 +806,85 @@ function GetEPGFromNaver($ChannelInfo) {
|
|||||||
$day = date("Ymd", strtotime("+".($k - 1)." days"));
|
$day = date("Ymd", strtotime("+".($k - 1)." days"));
|
||||||
$totaldate[] = $day;
|
$totaldate[] = $day;
|
||||||
endforeach;
|
endforeach;
|
||||||
$params = array(
|
$params = array(
|
||||||
'_callback' => 'epg',
|
'_callback' => 'epg',
|
||||||
'fileKey' => 'single_schedule_channel_day',
|
'fileKey' => 'single_schedule_channel_day',
|
||||||
'pkid' => '66',
|
'pkid' => '66',
|
||||||
'u1' => 'single_schedule_channel_day',
|
'u1' => 'single_schedule_channel_day',
|
||||||
'u2' => join(",", $totaldate),
|
'u2' => join(",", $totaldate),
|
||||||
'u3' => $day,
|
'u3' => $day,
|
||||||
'u4' => $GLOBALS['period'],
|
'u4' => $GLOBALS['period'],
|
||||||
'u5' => $ServiceId,
|
'u5' => $ServiceId,
|
||||||
'u6' => 1,
|
'u6' => 1,
|
||||||
'u7' => $ChannelName."편성표",
|
'u7' => $ChannelName."편성표",
|
||||||
'u8' => $ChannelName."편성표",
|
'u8' => $ChannelName."편성표",
|
||||||
'where' => 'nexearch'
|
'where' => 'nexearch'
|
||||||
);
|
);
|
||||||
|
|
||||||
$params = http_build_query($params);
|
$params = http_build_query($params);
|
||||||
$url = $url."?".$params;
|
$url = $url."?".$params;
|
||||||
try {
|
try {
|
||||||
$response = @file_get_contents($url, False, $context);
|
$response = @file_get_contents($url, False, $context);
|
||||||
if ($response === False) :
|
if ($response === False) :
|
||||||
printError($ChannelName.HTTP_ERROR);
|
printError($ChannelName.HTTP_ERROR);
|
||||||
else :
|
else :
|
||||||
try {
|
try {
|
||||||
$response = str_replace('epg( ', '', $response );
|
$response = str_replace('epg( ', '', $response );
|
||||||
$response = substr($response, 0, strlen($response)-2);
|
$response = substr($response, 0, strlen($response)-2);
|
||||||
$response = preg_replace("/\/\*.*?\*\//","",$response);
|
$response = preg_replace("/\/\*.*?\*\//","",$response);
|
||||||
$data = json_decode($response, TRUE);
|
$data = json_decode($response, TRUE);
|
||||||
if(json_last_error() != JSON_ERROR_NONE) throw new Exception(JSON_SYNTAX_ERROR);
|
if(json_last_error() != JSON_ERROR_NONE) throw new Exception(JSON_SYNTAX_ERROR);
|
||||||
if($data['displayDates'][0]['count'] == 0) :
|
if($data['displayDates'][0]['count'] == 0) :
|
||||||
if($GLOBALS['debug']) :
|
if($GLOBALS['debug']) :
|
||||||
printError($ChannelName.CHANNEL_ERROR);
|
printError($ChannelName.CHANNEL_ERROR);
|
||||||
endif;
|
|
||||||
else :
|
|
||||||
for($i = 0; $i < count($data['displayDates']); $i++) :
|
|
||||||
for($j = 0; $j < 24; $j++) :
|
|
||||||
foreach($data['schedules'][$j][$i] as $program) :
|
|
||||||
#programName, startTime, episode, rebroadcast, rating
|
|
||||||
$startTime = date("YmdHis", strtotime($data['displayDates'][$i]['date']." ".$program['startTime']));
|
|
||||||
$epginfo[] = array($program['title'], $startTime, str_replace("회","", $program['episode']), $program['isRerun'], $program['grade']);
|
|
||||||
endforeach;
|
|
||||||
endfor;
|
|
||||||
endfor;
|
|
||||||
$zipped = array_slice(array_map(NULL, $epginfo, array_slice($epginfo,1)),0,-1);
|
|
||||||
foreach($zipped as $epg) :
|
|
||||||
$programName = htmlspecialchars_decode($epg[0][0], ENT_XML1) ?: "";
|
|
||||||
$subprogramName = "";
|
|
||||||
$startTime = $epg[0][1] ?: "";
|
|
||||||
$endTime = $epg[1][1] ?: "";
|
|
||||||
$desc = "";
|
|
||||||
$actors = "";
|
|
||||||
$producers = "";
|
|
||||||
$category = "";
|
|
||||||
$rebroadcast = $epg[0][3] ? True: False;
|
|
||||||
$episode = $epg[0][2] ?: "";
|
|
||||||
$rating = $epg[0][4] ?: 0;
|
|
||||||
$programdata = array(
|
|
||||||
'channelId'=> $ChannelId,
|
|
||||||
'startTime' => $startTime,
|
|
||||||
'endTime' => $endTime,
|
|
||||||
'programName' => $programName,
|
|
||||||
'subprogramName'=> $subprogramName,
|
|
||||||
'desc' => $desc,
|
|
||||||
'actors' => $actors,
|
|
||||||
'producers' => $producers,
|
|
||||||
'category' => $category,
|
|
||||||
'episode' => $episode,
|
|
||||||
'rebroadcast' => $rebroadcast,
|
|
||||||
'rating' => $rating
|
|
||||||
);
|
|
||||||
writeProgram($programdata);
|
|
||||||
endforeach;
|
|
||||||
endif;
|
endif;
|
||||||
} catch(Exception $e) {
|
else :
|
||||||
if($GLOBALS['debug']) printError($e->getMessage());
|
for($i = 0; $i < count($data['displayDates']); $i++) :
|
||||||
}
|
for($j = 0; $j < 24; $j++) :
|
||||||
endif;
|
foreach($data['schedules'][$j][$i] as $program) :
|
||||||
} catch (Exception $e) {
|
#programName, startTime, episode, rebroadcast, rating
|
||||||
if($GLOBALS['debug']) printError($e->getMessage());
|
$startTime = date("YmdHis", strtotime($data['displayDates'][$i]['date']." ".$program['startTime']));
|
||||||
}
|
$epginfo[] = array($program['title'], $startTime, str_replace("회","", $program['episode']), $program['isRerun'], $program['grade']);
|
||||||
|
endforeach;
|
||||||
|
endfor;
|
||||||
|
endfor;
|
||||||
|
$zipped = array_slice(array_map(NULL, $epginfo, array_slice($epginfo,1)),0,-1);
|
||||||
|
foreach($zipped as $epg) :
|
||||||
|
$programName = htmlspecialchars_decode($epg[0][0], ENT_XML1) ?: "";
|
||||||
|
$subprogramName = "";
|
||||||
|
$startTime = $epg[0][1] ?: "";
|
||||||
|
$endTime = $epg[1][1] ?: "";
|
||||||
|
$desc = "";
|
||||||
|
$actors = "";
|
||||||
|
$producers = "";
|
||||||
|
$category = "";
|
||||||
|
$rebroadcast = $epg[0][3] ? True: False;
|
||||||
|
$episode = $epg[0][2] ?: "";
|
||||||
|
$rating = $epg[0][4] ?: 0;
|
||||||
|
$programdata = array(
|
||||||
|
'channelId'=> $ChannelId,
|
||||||
|
'startTime' => $startTime,
|
||||||
|
'endTime' => $endTime,
|
||||||
|
'programName' => $programName,
|
||||||
|
'subprogramName'=> $subprogramName,
|
||||||
|
'desc' => $desc,
|
||||||
|
'actors' => $actors,
|
||||||
|
'producers' => $producers,
|
||||||
|
'category' => $category,
|
||||||
|
'episode' => $episode,
|
||||||
|
'rebroadcast' => $rebroadcast,
|
||||||
|
'rating' => $rating
|
||||||
|
);
|
||||||
|
writeProgram($programdata);
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
} catch(Exception $e) {
|
||||||
|
if($GLOBALS['debug']) printError($e->getMessage());
|
||||||
|
}
|
||||||
|
endif;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
if($GLOBALS['debug']) printError($e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function writeProgram($programdata) {
|
function writeProgram($programdata) {
|
||||||
$fp = $GLOBALS['fp'];
|
$fp = $GLOBALS['fp'];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user