diff --git a/epg2xml.php b/epg2xml.php
index 6e58f95..827cf14 100644
--- a/epg2xml.php
+++ b/epg2xml.php
@@ -1,10 +1,8 @@
#!/usr/bin/env php
getMessage());
exit;
}
- endif;
+endif;
if($output == "display") :
$fp = fopen('php://output', 'w+');
@@ -275,6 +283,7 @@ function getEPG() {
$fp = $GLOBALS['fp'];
$MyISP = $GLOBALS['MyISP'];
$Channelfile = __DIR__."/Channel.json";
+ $IconUrl = "";
try {
$f = @file_get_contents($Channelfile);
if($f === False) :
@@ -430,18 +439,25 @@ function GetEPGFromEPG($ChannelInfo) {
break;
endswitch;
$startTime = date("YmdHis", strtotime($thisday." ".$hour));
+ $programName = "";
+ $subprogramName = "";
+ $rating = 0;
+ $episode = "";
+ $rebroadcast = False;
preg_match('/
?(.*)?(.*?)\s*(<(.*)>)?\s*(\(재\))?\s*(\(([\d,]+)회\))?()?\s*<\/td>/', trim($dom->saveHTML($program)), $matches);
if ($matches != NULL) :
- $image = $matches[8] ? $matches[8] : "";
- preg_match('/.*schedule_([\d,]+)?.*/', $image, $grade);
- if($grade != NULL) :
- $rating = $grade[1];
- else :
- $rating = 0;
+ if(isset($matches[2])) $programName = trim($matches[2]) ?: "";
+ if(isset($matches[4])) $subprogramName = trim($matches[4]) ?: "";
+ if(isset($matches[5])) $rebroadcast = $matches[5] ? True : False;
+ if(isset($matches[7])) $episode = $matches[7] ?: "";
+ if(isset($matches[8])) :
+ $image = $matches[8] ? $matches[8] : "";
+ preg_match('/.*schedule_([\d,]+)?.*/', $image, $grade);
+ if($grade != NULL) $rating = $grade[1];
endif;
endif;
//programName, startTime, rating, subprogramName, rebroadcast, episode
- $epginfo[] = array(trim($matches[2]), $startTime, $rating, trim($matches[4]), $matches[5], $matches[7]);
+ $epginfo[] = array($programName, $startTime, $rating, $subprogramName, $rebroadcast, $episode );
endforeach;
endfor;
endif;
@@ -459,7 +475,7 @@ function GetEPGFromEPG($ChannelInfo) {
$actors = "";
$producers = "";
$category = "";
- $rebroadcast = $epg[0][4] ? True : False;
+ $rebroadcast = $epg[0][4];
$episode = $epg[0][5] ?: "";
$rating = $epg[0][2] ?: 0;
$programdata = array(
@@ -534,9 +550,9 @@ function GetEPGFromKT($ChannelInfo) {
$programName = "";
$subprogramName = "";
preg_match('/^(.*?)( <(.*)>)?$/', $epg[0][0], $matches);
- if($matches) :
- $programName = $matches[1] ?: "";
- $subprogramName = $matches[3] ?: "";
+ if ($matches != NULL) :
+ if(isset($matches[1])) $programName = $matches[1] ?: "";
+ if(isset($matches[3])) $subprogramName = $matches[3] ?: "";
endif;
$startTime = $epg[0][1] ?: "";
$endTime = $epg[1][1] ?: "";
@@ -618,16 +634,23 @@ function GetEPGFromLG($ChannelInfo) {
$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]) ?: "";
+ $programName = "";
+ $subprogramName = "";
+ $episode = "";
+ $rebroadcast = False;
+ if ($matches != NULL) :
+ if(isset($matches[2])) $programName = trim($matches[2]) ?: "";
+ if(isset($matches[4])) $subprogramName = trim($matches[4]) ?: "";
+ if(isset($matches[6])) $episode = trim($matches[6]) ?: "";
+ if(isset($matches[1])) $rebroadcast = trim($matches[1]) ? True: False;
+ endif;
$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,
@@ -688,10 +711,10 @@ function GetEPGFromSK($ChannelInfo) {
$rebroadcast = False;
preg_match('/^(.*?)(?:\s*[\(<]([\d,회]+)[\)>])?(?:\s*<([^<]*?)>)?(\((재)\))?$/', str_replace('...', '>', $program['programName']), $matches);
if ($matches != NULL) :
- $programName = trim($matches[1]) ?: "";
- $subprogramName = trim($matches[3]) ?: "";
- $episode = str_replace("회", "", $matches[2]) ?: "";
- $rebroadcast = $matches[5] ? True : False;
+ if(isset($matches[1])) $programName = trim($matches[1]) ?: "";
+ if(isset($matches[3])) $subprogramName = trim($matches[3]) ?: "";
+ if(isset($matches[2])) $episode = str_replace("회", "", $matches[2]) ?: "";
+ if(isset($matches[5])) $rebroadcast = $matches[5] ? True : False;
endif;
$startTime = date("YmdHis",$program['startTime']/1000);
$endTime = date("YmdHis",$program['endTime']/1000);
|