kbs 함수 추가, 스카이라이프 url 변경 사항 반영, 누락 epg 데이터 에러 수정
This commit is contained in:
parent
39000e05c2
commit
819c4d13d2
353
epg2xml.php
353
epg2xml.php
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
@date_default_timezone_set('Asia/Seoul');
|
@date_default_timezone_set('Asia/Seoul');
|
||||||
define("VERSION", "1.1.7");
|
define("VERSION", "1.1.8");
|
||||||
|
|
||||||
$debug = False;
|
$debug = False;
|
||||||
$ua = "User-Agent: 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36', accept: '*/*'";
|
$ua = "User-Agent: 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36', accept: '*/*'";
|
||||||
@ -304,22 +304,32 @@ function getEPG() {
|
|||||||
$ChannelSource = $Channeldata['Source'];
|
$ChannelSource = $Channeldata['Source'];
|
||||||
$ChannelServiceId = $Channeldata['ServiceId'];
|
$ChannelServiceId = $Channeldata['ServiceId'];
|
||||||
$ChannelIconUrl = htmlspecialchars($Channeldata['Icon_url'], ENT_XML1);
|
$ChannelIconUrl = htmlspecialchars($Channeldata['Icon_url'], ENT_XML1);
|
||||||
$ChannelInfos[] = array($ChannelId, $ChannelName, $ChannelSource, $ChannelServiceId);
|
|
||||||
fprintf($fp, " <channel id=\"%s\">\n", $ChannelId);
|
|
||||||
fprintf($fp, " <display-name>%s</display-name>\n", $ChannelName);
|
|
||||||
if($MyISP != "ALL" && $Channeldata[$MyISP.'Ch'] != Null):
|
if($MyISP != "ALL" && $Channeldata[$MyISP.'Ch'] != Null):
|
||||||
|
$ChannelInfos[] = array($ChannelId, $ChannelName, $ChannelSource, $ChannelServiceId);
|
||||||
$Channelnumber = $Channeldata[$MyISP.'Ch'];
|
$Channelnumber = $Channeldata[$MyISP.'Ch'];
|
||||||
$ChannelISPName = htmlspecialchars($Channeldata[$MyISP." Name"], ENT_XML1);
|
$ChannelISPName = htmlspecialchars($Channeldata[$MyISP." Name"], ENT_XML1);
|
||||||
|
fprintf($fp, " <channel id=\"%s\">\n", $ChannelId);
|
||||||
|
fprintf($fp, " <display-name>%s</display-name>\n", $ChannelName);
|
||||||
fprintf($fp, " <display-name>%s</display-name>\n", $ChannelISPName);
|
fprintf($fp, " <display-name>%s</display-name>\n", $ChannelISPName);
|
||||||
fprintf($fp, " <display-name>%s</display-name>\n", $Channelnumber);
|
fprintf($fp, " <display-name>%s</display-name>\n", $Channelnumber);
|
||||||
fprintf($fp, " <display-name>%s</display-name>\n", $Channelnumber." ".$ChannelISPName);
|
fprintf($fp, " <display-name>%s</display-name>\n", $Channelnumber." ".$ChannelISPName);
|
||||||
|
if($IconUrl) :
|
||||||
|
fprintf($fp, " <icon src=\"%s/%s.png\" />\n", $IconUrl, $ChannelId);
|
||||||
|
else :
|
||||||
|
fprintf($fp, " <icon src=\"%s\" />\n", $ChannelIconUrl);
|
||||||
|
endif;
|
||||||
|
fprintf($fp, " </channel>\n");
|
||||||
|
elseif($MyISP == "ALL"):
|
||||||
|
$ChannelInfos[] = array($ChannelId, $ChannelName, $ChannelSource, $ChannelServiceId);
|
||||||
|
fprintf($fp, " <channel id=\"%s\">\n", $ChannelId);
|
||||||
|
fprintf($fp, " <display-name>%s</display-name>\n", $ChannelName);
|
||||||
|
if($IconUrl) :
|
||||||
|
fprintf($fp, " <icon src=\"%s/%s.png\" />\n", $IconUrl, $ChannelId);
|
||||||
|
else :
|
||||||
|
fprintf($fp, " <icon src=\"%s\" />\n", $ChannelIconUrl);
|
||||||
|
endif;
|
||||||
|
fprintf($fp, " </channel>\n");
|
||||||
endif;
|
endif;
|
||||||
if($IconUrl) :
|
|
||||||
fprintf($fp, " <icon src=\"%s/%s.png\" />\n", $IconUrl, $ChannelId);
|
|
||||||
else :
|
|
||||||
fprintf($fp, " <icon src=\"%s\" />\n", $ChannelIconUrl);
|
|
||||||
endif;
|
|
||||||
fprintf($fp, " </channel>\n");
|
|
||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
# Print Program Information
|
# Print Program Information
|
||||||
@ -351,6 +361,8 @@ function getEPG() {
|
|||||||
GetEPGFromMil($ChannelInfo);
|
GetEPGFromMil($ChannelInfo);
|
||||||
elseif($ChannelSource == 'IFM'):
|
elseif($ChannelSource == 'IFM'):
|
||||||
GetEPGFromIfm($ChannelInfo);
|
GetEPGFromIfm($ChannelInfo);
|
||||||
|
elseif($ChannelSource == 'KBS'):
|
||||||
|
GetEPGFromKbs($ChannelInfo);
|
||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
fprintf($fp, "</tv>\n");
|
fprintf($fp, "</tv>\n");
|
||||||
@ -368,6 +380,7 @@ function GetEPGFromEPG($ChannelInfo) {
|
|||||||
'header'=> $GLOBALS['ua']
|
'header'=> $GLOBALS['ua']
|
||||||
));
|
));
|
||||||
$context = stream_context_create($options);
|
$context = stream_context_create($options);
|
||||||
|
$epginfo = array();
|
||||||
foreach(range(1, $GLOBALS['period']) as $k) :
|
foreach(range(1, $GLOBALS['period']) as $k) :
|
||||||
$url = "http://www.epg.co.kr/epg-cgi/extern/cnm_guide_type_v070530.cgi";
|
$url = "http://www.epg.co.kr/epg-cgi/extern/cnm_guide_type_v070530.cgi";
|
||||||
$day = date("Ymd", strtotime("+".($k - 1)." days"));
|
$day = date("Ymd", strtotime("+".($k - 1)." days"));
|
||||||
@ -379,10 +392,9 @@ 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 && $GLOBALS['debug']) :
|
||||||
printError($ChannelName.HTTP_ERROR);
|
printError($ChannelName.HTTP_ERROR);
|
||||||
else :
|
else :
|
||||||
$response = str_replace("charset=euc-kr", "charset=utf-8", $response);
|
$response = str_replace("charset=euc-kr", "charset=utf-8", $response);
|
||||||
@ -407,9 +419,9 @@ function GetEPGFromEPG($ChannelInfo) {
|
|||||||
$hour = $hour." PM";
|
$hour = $hour." PM";
|
||||||
break;
|
break;
|
||||||
case 4 :
|
case 4 :
|
||||||
if($hour > 5 ) :
|
if($hour > 5 && $hour < 12) :
|
||||||
$hour = $hour." PM";
|
$hour = $hour." PM";
|
||||||
else :
|
elseif($hour <5 || $hour == 12) :
|
||||||
$hour = $hour." AM";
|
$hour = $hour." AM";
|
||||||
$thisday = date("Ymd", strtotime($day." +1 days"));
|
$thisday = date("Ymd", strtotime($day." +1 days"));
|
||||||
endif;
|
endif;
|
||||||
@ -426,44 +438,44 @@ function GetEPGFromEPG($ChannelInfo) {
|
|||||||
$rating = 0;
|
$rating = 0;
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
#programName, startTime, rating, subprogramName, rebroadcast, episode
|
//programName, startTime, rating, subprogramName, rebroadcast, episode
|
||||||
$epginfo[] = array(trim($matches[2]), $startTime, $rating, trim($matches[4]), $matches[5], $matches[7]);
|
$epginfo[] = array(trim($matches[2]), $startTime, $rating, trim($matches[4]), $matches[5], $matches[7]);
|
||||||
endforeach;
|
endforeach;
|
||||||
endfor;
|
endfor;
|
||||||
$zipped = array_slice(array_map(NULL, $epginfo, array_slice($epginfo,1)),0,-1);
|
|
||||||
foreach($zipped as $epg) :
|
|
||||||
$programName = $epg[0][0] ?: "";
|
|
||||||
$subprogramName = $epg[0][3] ?: "";
|
|
||||||
$startTime = $epg[0][1] ?: "";
|
|
||||||
$endTime = $epg[1][1] ?: "";
|
|
||||||
$desc = "";
|
|
||||||
$actors = "";
|
|
||||||
$producers = "";
|
|
||||||
$category = "";
|
|
||||||
$rebroadcast = $epg[0][4] ? True : False;
|
|
||||||
$episode = $epg[0][5] ?: "";
|
|
||||||
$rating = $epg[0][2] ?: 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) {
|
} catch (Exception $e) {
|
||||||
if($GLOBALS['debug']) printError($e->getMessage());
|
if($GLOBALS['debug']) printError($e->getMessage());
|
||||||
}
|
}
|
||||||
endforeach;
|
endforeach;
|
||||||
|
$zipped = array_slice(array_map(NULL, $epginfo, array_slice($epginfo,1)),0,-1);
|
||||||
|
foreach($zipped as $epg) :
|
||||||
|
$programName = $epg[0][0] ?: "";
|
||||||
|
$subprogramName = $epg[0][3] ?: "";
|
||||||
|
$startTime = $epg[0][1] ?: "";
|
||||||
|
$endTime = $epg[1][1] ?: "";
|
||||||
|
$desc = "";
|
||||||
|
$actors = "";
|
||||||
|
$producers = "";
|
||||||
|
$category = "";
|
||||||
|
$rebroadcast = $epg[0][4] ? True : False;
|
||||||
|
$episode = $epg[0][5] ?: "";
|
||||||
|
$rating = $epg[0][2] ?: 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get EPG data from KT
|
// Get EPG data from KT
|
||||||
@ -478,6 +490,7 @@ function GetEPGFromKT($ChannelInfo) {
|
|||||||
'header'=> $GLOBALS['ua']
|
'header'=> $GLOBALS['ua']
|
||||||
));
|
));
|
||||||
$context = stream_context_create($options);
|
$context = stream_context_create($options);
|
||||||
|
$epginfo = array();
|
||||||
foreach(range(1, $GLOBALS['period']) as $k) :
|
foreach(range(1, $GLOBALS['period']) as $k) :
|
||||||
$url = "http://tv.olleh.com/renewal_sub/liveTv/pop_schedule_week.asp";
|
$url = "http://tv.olleh.com/renewal_sub/liveTv/pop_schedule_week.asp";
|
||||||
$day = date("Ymd", strtotime("+".($k - 1)." days"));
|
$day = date("Ymd", strtotime("+".($k - 1)." days"));
|
||||||
@ -490,10 +503,9 @@ 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 && $GLOBALS['debug']) :
|
||||||
printError($ChannelName.HTTP_ERROR);
|
printError($ChannelName.HTTP_ERROR);
|
||||||
else :
|
else :
|
||||||
$response = str_replace("charset=euc-kr", "charset=utf-8", $response);
|
$response = str_replace("charset=euc-kr", "charset=utf-8", $response);
|
||||||
@ -510,46 +522,45 @@ function GetEPGFromKT($ChannelInfo) {
|
|||||||
$rating = str_replace("all", 0, str_replace("세 이상", "", trim($cells->item(2)->nodeValue)));
|
$rating = str_replace("all", 0, str_replace("세 이상", "", trim($cells->item(2)->nodeValue)));
|
||||||
$epginfo[]= array(trim($cells->item(1)->nodeValue), $startTime, $rating, trim($cells->item(4)->nodeValue));
|
$epginfo[]= array(trim($cells->item(1)->nodeValue), $startTime, $rating, trim($cells->item(4)->nodeValue));
|
||||||
endforeach;
|
endforeach;
|
||||||
$zipped = array_slice(array_map(NULL, $epginfo, array_slice($epginfo,1)),0,-1);
|
|
||||||
foreach($zipped as $epg) :
|
|
||||||
$programName = "";
|
|
||||||
$subprogramName = "";
|
|
||||||
preg_match('/^(.*?)( <(.*)>)?$/', $epg[0][0], $matches);
|
|
||||||
if($matches) :
|
|
||||||
$programName = $matches[1] ?: "";
|
|
||||||
$subprogramName = $matches[3] ?: "";
|
|
||||||
endif;
|
|
||||||
$startTime = $epg[0][1] ?: "";
|
|
||||||
$endTime = $epg[1][1] ?: "";
|
|
||||||
$desc = "";
|
|
||||||
$actors = "";
|
|
||||||
$producers = "";
|
|
||||||
$category = $epg[0][3] ?: "";
|
|
||||||
$rebroadcast = False;
|
|
||||||
$episode = "";
|
|
||||||
$rating = $epg[0][2] ?: 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) {
|
} catch (Exception $e) {
|
||||||
if($GLOBALS['debug']) printError($e->getMessage());
|
if($GLOBALS['debug']) printError($e->getMessage());
|
||||||
}
|
}
|
||||||
endforeach;
|
endforeach;
|
||||||
|
$zipped = array_slice(array_map(NULL, $epginfo, array_slice($epginfo,1)),0,-1);
|
||||||
|
foreach($zipped as $epg) :
|
||||||
|
$programName = "";
|
||||||
|
$subprogramName = "";
|
||||||
|
preg_match('/^(.*?)( <(.*)>)?$/', $epg[0][0], $matches);
|
||||||
|
if($matches) :
|
||||||
|
$programName = $matches[1] ?: "";
|
||||||
|
$subprogramName = $matches[3] ?: "";
|
||||||
|
endif;
|
||||||
|
$startTime = $epg[0][1] ?: "";
|
||||||
|
$endTime = $epg[1][1] ?: "";
|
||||||
|
$desc = "";
|
||||||
|
$actors = "";
|
||||||
|
$producers = "";
|
||||||
|
$category = $epg[0][3] ?: "";
|
||||||
|
$rebroadcast = False;
|
||||||
|
$episode = "";
|
||||||
|
$rating = $epg[0][2] ?: 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get EPG data from LG
|
// Get EPG data from LG
|
||||||
@ -564,6 +575,7 @@ function GetEPGFromLG($ChannelInfo) {
|
|||||||
'header'=> $GLOBALS['ua']
|
'header'=> $GLOBALS['ua']
|
||||||
));
|
));
|
||||||
$context = stream_context_create($options);
|
$context = stream_context_create($options);
|
||||||
|
$epginfo = array();
|
||||||
foreach(range(1, $GLOBALS['period']) as $k) :
|
foreach(range(1, $GLOBALS['period']) as $k) :
|
||||||
$url = "http://www.uplus.co.kr/css/chgi/chgi/RetrieveTvSchedule.hpi";
|
$url = "http://www.uplus.co.kr/css/chgi/chgi/RetrieveTvSchedule.hpi";
|
||||||
$day = date("Ymd", strtotime("+".($k - 1)." days"));
|
$day = date("Ymd", strtotime("+".($k - 1)." days"));
|
||||||
@ -573,10 +585,9 @@ 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 && $GLOBALS['debug']) :
|
||||||
printError($ChannelName.HTTP_ERROR);
|
printError($ChannelName.HTTP_ERROR);
|
||||||
else :
|
else :
|
||||||
$response = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'.$response;
|
$response = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'.$response;
|
||||||
@ -594,44 +605,44 @@ function GetEPGFromLG($ChannelInfo) {
|
|||||||
$startTime = date("YmdHis", strtotime($day." ".trim($cells->item(0)->nodeValue)));
|
$startTime = date("YmdHis", strtotime($day." ".trim($cells->item(0)->nodeValue)));
|
||||||
$spans = $cells->item(1)->getElementsByTagName('span');
|
$spans = $cells->item(1)->getElementsByTagName('span');
|
||||||
$rating = trim($spans->item(1)->nodeValue)=="All" ? 0 : trim($spans->item(1)->nodeValue);
|
$rating = trim($spans->item(1)->nodeValue)=="All" ? 0 : trim($spans->item(1)->nodeValue);
|
||||||
#programName, startTime, rating, category
|
//programName, startTime, rating, category
|
||||||
$epginfo[]= array($programName, $startTime, $rating, trim($cells->item(2)->nodeValue));
|
$epginfo[]= array($programName, $startTime, $rating, trim($cells->item(2)->nodeValue));
|
||||||
endforeach;
|
endforeach;
|
||||||
$zipped = array_slice(array_map(NULL, $epginfo, array_slice($epginfo,1)),0,-1);
|
|
||||||
foreach($zipped as $epg) :
|
|
||||||
preg_match('/(<재>?)?(.*?)(\[(.*)\])?\s?(\(([\d,]+)회\))?$/', $epg[0][0], $matches);
|
|
||||||
$programName = trim($matches[2]) ?: "";
|
|
||||||
$subprogramName = trim($matches[4]) ?: "";
|
|
||||||
$startTime = $epg[0][1] ?: "";
|
|
||||||
$endTime = $epg[1][1] ?: "";
|
|
||||||
$desc = "";
|
|
||||||
$actors = "";
|
|
||||||
$producers = "";
|
|
||||||
$category = $epg[0][3] ?: "";
|
|
||||||
$rebroadcast = trim($matches[1]) ? True: False;
|
|
||||||
$episode = trim($matches[6]) ?: "";
|
|
||||||
$rating = $epg[0][2] ?: 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) {
|
} catch (Exception $e) {
|
||||||
if($GLOBALS['debug']) printError($e->getMessage());
|
if($GLOBALS['debug']) printError($e->getMessage());
|
||||||
}
|
}
|
||||||
endforeach;
|
endforeach;
|
||||||
|
$zipped = array_slice(array_map(NULL, $epginfo, array_slice($epginfo,1)),0,-1);
|
||||||
|
foreach($zipped as $epg) :
|
||||||
|
preg_match('/(<재>?)?(.*?)(\[(.*)\])?\s?(\(([\d,]+)회\))?$/', $epg[0][0], $matches);
|
||||||
|
$programName = trim($matches[2]) ?: "";
|
||||||
|
$subprogramName = trim($matches[4]) ?: "";
|
||||||
|
$startTime = $epg[0][1] ?: "";
|
||||||
|
$endTime = $epg[1][1] ?: "";
|
||||||
|
$desc = "";
|
||||||
|
$actors = "";
|
||||||
|
$producers = "";
|
||||||
|
$category = $epg[0][3] ?: "";
|
||||||
|
$rebroadcast = trim($matches[1]) ? True: False;
|
||||||
|
$episode = trim($matches[6]) ?: "";
|
||||||
|
$rating = $epg[0][2] ?: 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get EPG data from SK
|
// Get EPG data from SK
|
||||||
@ -656,7 +667,7 @@ function GetEPGFromSK($ChannelInfo) {
|
|||||||
$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 && $GLOBALS['debug']) :
|
||||||
printError($ChannelName.HTTP_ERROR);
|
printError($ChannelName.HTTP_ERROR);
|
||||||
else :
|
else :
|
||||||
try {
|
try {
|
||||||
@ -724,12 +735,12 @@ function GetEPGFromSKY($ChannelInfo) {
|
|||||||
$ServiceId = $ChannelInfo[3];
|
$ServiceId = $ChannelInfo[3];
|
||||||
$options = array(
|
$options = array(
|
||||||
'http' => array(
|
'http' => array(
|
||||||
'method' => 'GET',
|
'method' => 'POST',
|
||||||
'header'=> $GLOBALS['ua']
|
'header'=> $GLOBALS['ua']
|
||||||
));
|
));
|
||||||
$context = stream_context_create($options);
|
$context = stream_context_create($options);
|
||||||
foreach(range(1, $GLOBALS['period']) as $k) :
|
foreach(range(1, $GLOBALS['period']) as $k) :
|
||||||
$url = "http://www.skylife.co.kr/channel/epg/channelScheduleList.do";
|
$url = "http://www.skylife.co.kr/channel/epg/channelScheduleListJson.do";
|
||||||
$day = date("Y-m-d", strtotime("+".($k - 1)." days"));
|
$day = date("Y-m-d", strtotime("+".($k - 1)." days"));
|
||||||
$params = array(
|
$params = array(
|
||||||
'area' => 'in',
|
'area' => 'in',
|
||||||
@ -741,14 +752,14 @@ function GetEPGFromSKY($ChannelInfo) {
|
|||||||
$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 && $GLOBALS['debug']) :
|
||||||
printError($ChannelName.HTTP_ERROR);
|
printError($ChannelName.HTTP_ERROR);
|
||||||
else :
|
else :
|
||||||
try {
|
try {
|
||||||
$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(count($data['scheduleListIn']) == 0) :
|
if(count($data['scheduleListIn']) == 0) :
|
||||||
if($GLOBALS['debug']) :
|
if($GLOBALS['debug']) :
|
||||||
printError($ChannelName.CHANNEL_ERROR);
|
printError($ChannelName.CHANNEL_ERROR);
|
||||||
endif;
|
endif;
|
||||||
else :
|
else :
|
||||||
@ -808,6 +819,8 @@ function GetEPGFromNaver($ChannelInfo) {
|
|||||||
'header'=> $GLOBALS['ua']
|
'header'=> $GLOBALS['ua']
|
||||||
));
|
));
|
||||||
$context = stream_context_create($options);
|
$context = stream_context_create($options);
|
||||||
|
$epginfo = array();
|
||||||
|
$totaldate = array();
|
||||||
foreach(range(1, $GLOBALS['period']) as $k) :
|
foreach(range(1, $GLOBALS['period']) as $k) :
|
||||||
$url = "https://search.naver.com/p/csearch/content/batchrender_ssl.nhn";
|
$url = "https://search.naver.com/p/csearch/content/batchrender_ssl.nhn";
|
||||||
$day = date("Ymd", strtotime("+".($k - 1)." days"));
|
$day = date("Ymd", strtotime("+".($k - 1)." days"));
|
||||||
@ -831,7 +844,7 @@ function GetEPGFromNaver($ChannelInfo) {
|
|||||||
$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 && $GLOBALS['debug']) :
|
||||||
printError($ChannelName.HTTP_ERROR);
|
printError($ChannelName.HTTP_ERROR);
|
||||||
else :
|
else :
|
||||||
try {
|
try {
|
||||||
@ -848,7 +861,7 @@ function GetEPGFromNaver($ChannelInfo) {
|
|||||||
for($i = 0; $i < count($data['displayDates']); $i++) :
|
for($i = 0; $i < count($data['displayDates']); $i++) :
|
||||||
for($j = 0; $j < 24; $j++) :
|
for($j = 0; $j < 24; $j++) :
|
||||||
foreach($data['schedules'][$j][$i] as $program) :
|
foreach($data['schedules'][$j][$i] as $program) :
|
||||||
#programName, startTime, episode, rebroadcast, rating
|
//programName, startTime, episode, rebroadcast, rating
|
||||||
$startTime = date("YmdHis", strtotime($data['displayDates'][$i]['date']." ".$program['startTime']));
|
$startTime = date("YmdHis", strtotime($data['displayDates'][$i]['date']." ".$program['startTime']));
|
||||||
$epginfo[] = array($program['title'], $startTime, str_replace("회","", $program['episode']), $program['isRerun'], $program['grade']);
|
$epginfo[] = array($program['title'], $startTime, str_replace("회","", $program['episode']), $program['isRerun'], $program['grade']);
|
||||||
endforeach;
|
endforeach;
|
||||||
@ -930,7 +943,7 @@ function GetEPGFromMbc($ChannelInfo) {
|
|||||||
$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 && $GLOBALS['debug']) :
|
||||||
printError($ChannelName.HTTP_ERROR);
|
printError($ChannelName.HTTP_ERROR);
|
||||||
else :
|
else :
|
||||||
try {
|
try {
|
||||||
@ -977,7 +990,6 @@ function GetEPGFromMbc($ChannelInfo) {
|
|||||||
);
|
);
|
||||||
writeProgram($programdata);
|
writeProgram($programdata);
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
endforeach;
|
endforeach;
|
||||||
endif;
|
endif;
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
@ -1011,7 +1023,7 @@ function GetEPGFromMil($ChannelInfo) {
|
|||||||
$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 && $GLOBALS['debug']) :
|
||||||
printError($ChannelName.HTTP_ERROR);
|
printError($ChannelName.HTTP_ERROR);
|
||||||
else :
|
else :
|
||||||
try {
|
try {
|
||||||
@ -1092,7 +1104,7 @@ function GetEPGFromIfm($ChannelInfo) {
|
|||||||
$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 && $GLOBALS['debug']) :
|
||||||
printError($ChannelName.HTTP_ERROR);
|
printError($ChannelName.HTTP_ERROR);
|
||||||
else :
|
else :
|
||||||
try {
|
try {
|
||||||
@ -1144,7 +1156,96 @@ function GetEPGFromIfm($ChannelInfo) {
|
|||||||
}
|
}
|
||||||
endforeach;
|
endforeach;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get EPG data from KBS
|
||||||
|
function GetEPGFromKbs($ChannelInfo) {
|
||||||
|
$ChannelId = $ChannelInfo[0];
|
||||||
|
$ChannelName = $ChannelInfo[1];
|
||||||
|
$ServiceId = $ChannelInfo[3];
|
||||||
|
$options = array(
|
||||||
|
'http' => array(
|
||||||
|
'method' => 'GET',
|
||||||
|
'header'=> $GLOBALS['ua']
|
||||||
|
));
|
||||||
|
$context = stream_context_create($options);
|
||||||
|
$epginfo = array();
|
||||||
|
foreach(range(1, $GLOBALS['period']) as $k) :
|
||||||
|
$url = "http://world.kbs.co.kr/include/wink/_ajax_schedule.php";
|
||||||
|
$day = date("Y-m-d", strtotime("+".($k - 1)." days"));
|
||||||
|
$params = array(
|
||||||
|
'channel'=>'wink_11'
|
||||||
|
);
|
||||||
|
$params = http_build_query($params);
|
||||||
|
$url = $url."?".$params;
|
||||||
|
try {
|
||||||
|
$response = @file_get_contents($url, False, $context);
|
||||||
|
if ($response === False && $GLOBALS['debug']) :
|
||||||
|
printError($ChannelName.HTTP_ERROR);
|
||||||
|
else :
|
||||||
|
try {
|
||||||
|
$data = json_decode($response, TRUE);
|
||||||
|
if(json_last_error() != JSON_ERROR_NONE) throw new Exception(JSON_SYNTAX_ERROR);
|
||||||
|
if(count($data['schedule']) == 0) :
|
||||||
|
if($GLOBALS['debug']) :
|
||||||
|
printError($ChannelName.CHANNEL_ERROR);
|
||||||
|
endif;
|
||||||
|
else :
|
||||||
|
$dom = new DomDocument;
|
||||||
|
libxml_use_internal_errors(true);
|
||||||
|
$dom->loadHTML($data['schedule']);
|
||||||
|
$xpath = new DomXPath($dom);
|
||||||
|
$query = "//li";
|
||||||
|
$rows = $xpath->query($query);
|
||||||
|
foreach($rows as $row) :
|
||||||
|
$cells = $row->getElementsByTagName('span');
|
||||||
|
$programName = trim($cells->item(2)->childNodes->item(0)->nodeValue);
|
||||||
|
$programName = str_replace(array("[","]", " Broadcast"), array("", "", ""), $programName);
|
||||||
|
$startTime = $day." ".trim($cells->item(0)->childNodes->item(0)->nodeValue);
|
||||||
|
//programName, startTime, rating, category
|
||||||
|
$epginfo[]= array($programName, $startTime);
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
} catch(Exception $e) {
|
||||||
|
if($GLOBALS['debug']) printError($e->getMessage());
|
||||||
|
}
|
||||||
|
endif;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
if($GLOBALS['debug']) printError($e->getMessage());
|
||||||
|
}
|
||||||
|
endforeach;
|
||||||
|
$zipped = array_slice(array_map(NULL, $epginfo, array_slice($epginfo,1)),0,-1);
|
||||||
|
foreach($zipped as $epg) :
|
||||||
|
$programName = $epg[0][0] ?: "";
|
||||||
|
$subprogramName = "";
|
||||||
|
$startTime = $epg[0][1] ?: "";
|
||||||
|
$startTime = date("YmdHis", strtotime($startTime));
|
||||||
|
$endTime = $epg[1][1] ?: "";
|
||||||
|
$endTime = date("YmdHis", strtotime($endTime));
|
||||||
|
$desc = "";
|
||||||
|
$actors = "";
|
||||||
|
$producers = "";
|
||||||
|
$category = "";
|
||||||
|
$rebroadcast = False;
|
||||||
|
$episode = "";
|
||||||
|
$rating = 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;
|
||||||
|
}
|
||||||
|
|
||||||
function writeProgram($programdata) {
|
function writeProgram($programdata) {
|
||||||
$fp = $GLOBALS['fp'];
|
$fp = $GLOBALS['fp'];
|
||||||
$ChannelId = $programdata['channelId'];
|
$ChannelId = $programdata['channelId'];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user