From 881eb65493c5b698e29126dca2205525de6cfc2a Mon Sep 17 00:00:00 2001 From: wonipapa Date: Fri, 12 May 2017 17:45:05 +0900 Subject: [PATCH] =?UTF-8?q?Notice=20Error=20=EC=B6=9C=EB=A0=A5=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20PHP=20=EB=B2=84=EC=A0=84=20=ED=99=95=EC=9D=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20PHP=20=EB=AA=A8=EB=93=88=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epg2xml.php | 85 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 31 deletions(-) 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);