SKB 함수 추가
가져오는 날짜 2일로 제한 타이틀 제목 1부, 2부 서브타이틀로 이동
This commit is contained in:
		
							parent
							
								
									6f7d794c6d
								
							
						
					
					
						commit
						e0027ab3a6
					
				@ -167,6 +167,7 @@ else :
 | 
				
			|||||||
                else :
 | 
					                else :
 | 
				
			||||||
                    if(in_array($default_fetch_limit, array(1, 2, 3, 4, 5, 6, 7))) :
 | 
					                    if(in_array($default_fetch_limit, array(1, 2, 3, 4, 5, 6, 7))) :
 | 
				
			||||||
                        $period = $default_fetch_limit;
 | 
					                        $period = $default_fetch_limit;
 | 
				
			||||||
 | 
					                        $period = $period > 2 ? 2 : $period;
 | 
				
			||||||
                    else :
 | 
					                    else :
 | 
				
			||||||
                        printError("default_fetch_limit는 1, 2, 3, 4, 5, 6, 7만 가능합니다.");
 | 
					                        printError("default_fetch_limit는 1, 2, 3, 4, 5, 6, 7만 가능합니다.");
 | 
				
			||||||
                        exit;
 | 
					                        exit;
 | 
				
			||||||
@ -358,6 +359,8 @@ function getEPG() {
 | 
				
			|||||||
            GetEPGFromLG($ChannelInfo);
 | 
					            GetEPGFromLG($ChannelInfo);
 | 
				
			||||||
        elseif($ChannelSource == 'SK') :
 | 
					        elseif($ChannelSource == 'SK') :
 | 
				
			||||||
            GetEPGFromSK($ChannelInfo);
 | 
					            GetEPGFromSK($ChannelInfo);
 | 
				
			||||||
 | 
					        elseif($ChannelSource == 'SKB') :
 | 
				
			||||||
 | 
					            GetEPGFromSKB($ChannelInfo);
 | 
				
			||||||
        elseif($ChannelSource == 'SKY') :
 | 
					        elseif($ChannelSource == 'SKY') :
 | 
				
			||||||
            GetEPGFromSKY($ChannelInfo);
 | 
					            GetEPGFromSKY($ChannelInfo);
 | 
				
			||||||
        elseif($ChannelSource == 'NAVER') :
 | 
					        elseif($ChannelSource == 'NAVER') :
 | 
				
			||||||
@ -726,6 +729,88 @@ function GetEPGFromSK($ChannelInfo) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Get EPG data from SKB
 | 
				
			||||||
 | 
					function GetEPGFromSKB($ChannelInfo) {
 | 
				
			||||||
 | 
					    $ChannelId = $ChannelInfo[0];
 | 
				
			||||||
 | 
					    $ChannelName = $ChannelInfo[1];
 | 
				
			||||||
 | 
					    $ServiceId =  $ChannelInfo[3];
 | 
				
			||||||
 | 
					    $epginfo = array();
 | 
				
			||||||
 | 
					    foreach(range(1, $GLOBALS['period']) as $k) :
 | 
				
			||||||
 | 
					        $url = "http://www.skbroadband.com/content/realtime/Channel_List.do";
 | 
				
			||||||
 | 
					        $day = date("Ymd", strtotime("+".($k - 1)." days"));
 | 
				
			||||||
 | 
					        $params = array(
 | 
				
			||||||
 | 
					            'key_depth2' => $ServiceId,
 | 
				
			||||||
 | 
					            'key_depth3' => $day,
 | 
				
			||||||
 | 
					            'tab_gubun'  => 'lst'
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        $params = http_build_query($params);
 | 
				
			||||||
 | 
					        $method = "POST";
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            $response = getWeb($url, $params, $method);
 | 
				
			||||||
 | 
					            if ($response === False && $GLOBALS['debug']) :
 | 
				
			||||||
 | 
					                printError($ChannelName.HTTP_ERROR);
 | 
				
			||||||
 | 
					            else :
 | 
				
			||||||
 | 
					                $response = str_replace('charset="euc-kr"', 'charset="utf-8"', $response);
 | 
				
			||||||
 | 
					                $dom = new DomDocument;
 | 
				
			||||||
 | 
					                libxml_use_internal_errors(True);
 | 
				
			||||||
 | 
					                $response = mb_convert_encoding($response, "UTF-8", "EUC-KR");
 | 
				
			||||||
 | 
					                $dom->loadHTML($response);
 | 
				
			||||||
 | 
					                $xpath = new DomXPath($dom);
 | 
				
			||||||
 | 
					                $query = "//tr[@class='".$day."']";
 | 
				
			||||||
 | 
					                $rows = $xpath->query($query);
 | 
				
			||||||
 | 
					                foreach($rows as $row) :
 | 
				
			||||||
 | 
					                    $cells = $row->getElementsByTagName('td');
 | 
				
			||||||
 | 
					                    $pattern = '/^(.*?)(\(([\d,]+)회\))?(<(.*)>)?(\((재)\))?$/';
 | 
				
			||||||
 | 
					                    preg_match($pattern, trim($cells->item(0)->nodeValue), $matches);
 | 
				
			||||||
 | 
					                    if ($matches != NULL) :
 | 
				
			||||||
 | 
					                        if(isset($matches[1])) $programName = trim($matches[1]) ?: "";
 | 
				
			||||||
 | 
					                        if(isset($matches[5])) $subprogramName = trim($matches[5]) ?: "";
 | 
				
			||||||
 | 
					                        if(isset($matches[3])) $episode = $matches[3] ?: "";
 | 
				
			||||||
 | 
					                        if(isset($matches[7])) $rebroadcast = $matches[7] ? True : False;
 | 
				
			||||||
 | 
					                    endif;
 | 
				
			||||||
 | 
					                    preg_match('/.*\s*([\d,]+)\s*.*/', $cells->item(1)->nodeValue, $rating);
 | 
				
			||||||
 | 
					                    $startTime = $row->getElementsByTagName('th')->item(0)->nodeValue;
 | 
				
			||||||
 | 
					                    $startTime = date("YmdHis", strtotime($day." ".$startTime));
 | 
				
			||||||
 | 
					                    $rating = $rating[1];
 | 
				
			||||||
 | 
					                    //programName, startTime, rating, subprogramName, rebroadcast, episode
 | 
				
			||||||
 | 
					                    $epginfo[]= array($programName, $startTime, $rating, $subprogramName, $rebroadcast, $episode);
 | 
				
			||||||
 | 
					                endforeach;
 | 
				
			||||||
 | 
					            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 = trim($epg[0][0]) ?: "";
 | 
				
			||||||
 | 
					        $subprogramName = trim($epg[0][3]) ?: "";
 | 
				
			||||||
 | 
					        $episode = $epg[0][5] ?: "";
 | 
				
			||||||
 | 
					        $rebroadcast = $epg[0][4] ? True: False;
 | 
				
			||||||
 | 
					        $startTime = $epg[0][1] ?: "";
 | 
				
			||||||
 | 
					        $endTime = $epg[1][1] ?: "";
 | 
				
			||||||
 | 
					        $desc = "";
 | 
				
			||||||
 | 
					        $actors = "";
 | 
				
			||||||
 | 
					        $producers = "";
 | 
				
			||||||
 | 
					        $category = "";
 | 
				
			||||||
 | 
					        $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 SKY
 | 
					// Get EPG data from SKY
 | 
				
			||||||
function GetEPGFromSKY($ChannelInfo) {
 | 
					function GetEPGFromSKY($ChannelInfo) {
 | 
				
			||||||
    $ChannelId = $ChannelInfo[0];
 | 
					    $ChannelId = $ChannelInfo[0];
 | 
				
			||||||
@ -1213,9 +1298,16 @@ function writeProgram($programdata) {
 | 
				
			|||||||
    $ChannelId = $programdata['channelId'];
 | 
					    $ChannelId = $programdata['channelId'];
 | 
				
			||||||
    $startTime = $programdata['startTime'];
 | 
					    $startTime = $programdata['startTime'];
 | 
				
			||||||
    $endTime = $programdata['endTime'];
 | 
					    $endTime = $programdata['endTime'];
 | 
				
			||||||
    $programName = htmlspecialchars($programdata['programName'], ENT_XML1);
 | 
					    $programName = trim(htmlspecialchars($programdata['programName'], ENT_XML1));
 | 
				
			||||||
    $subprogramName = htmlspecialchars($programdata['subprogramName'], ENT_XML1);
 | 
					    $subprogramName = trim(htmlspecialchars($programdata['subprogramName'], ENT_XML1));
 | 
				
			||||||
    $actors = htmlspecialchars($programdata['actors'], ENT_XML1);
 | 
					    preg_match('/(.*) \(?(\d+부)\)?/', $programName, $matches);
 | 
				
			||||||
 | 
					    if ($matches != NULL) :
 | 
				
			||||||
 | 
					        if(isset($matches[1])) $programName = trim($matches[1]) ?: "";
 | 
				
			||||||
 | 
					        if(isset($matches[2])) $subprogramName = trim($matches[2]." ".$subprogramName) ?: "";
 | 
				
			||||||
 | 
					    endif;
 | 
				
			||||||
 | 
					    if($programName == NULL):
 | 
				
			||||||
 | 
					        $programName = $subprogramName;
 | 
				
			||||||
 | 
					    endif;    $actors = htmlspecialchars($programdata['actors'], ENT_XML1);
 | 
				
			||||||
    $producers = htmlspecialchars($programdata['producers'], ENT_XML1);
 | 
					    $producers = htmlspecialchars($programdata['producers'], ENT_XML1);
 | 
				
			||||||
    $category = htmlspecialchars($programdata['category'], ENT_XML1);
 | 
					    $category = htmlspecialchars($programdata['category'], ENT_XML1);
 | 
				
			||||||
    $episode = $programdata['episode'];
 | 
					    $episode = $programdata['episode'];
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										118
									
								
								epg2xml.php
									
									
									
									
									
								
							
							
						
						
									
										118
									
								
								epg2xml.php
									
									
									
									
									
								
							@ -187,6 +187,8 @@ else :
 | 
				
			|||||||
                else :
 | 
					                else :
 | 
				
			||||||
                    if(in_array($default_fetch_limit, array(1, 2, 3, 4, 5, 6, 7))) :
 | 
					                    if(in_array($default_fetch_limit, array(1, 2, 3, 4, 5, 6, 7))) :
 | 
				
			||||||
                        $period = $default_fetch_limit;
 | 
					                        $period = $default_fetch_limit;
 | 
				
			||||||
 | 
					                        $period = $period > 2 ? 2 : $period;
 | 
				
			||||||
 | 
					                        
 | 
				
			||||||
                    else :
 | 
					                    else :
 | 
				
			||||||
                        printError("default_fetch_limit는 1, 2, 3, 4, 5, 6, 7만 가능합니다.");
 | 
					                        printError("default_fetch_limit는 1, 2, 3, 4, 5, 6, 7만 가능합니다.");
 | 
				
			||||||
                        exit;
 | 
					                        exit;
 | 
				
			||||||
@ -377,6 +379,8 @@ function getEPG() {
 | 
				
			|||||||
            GetEPGFromLG($ChannelInfo);
 | 
					            GetEPGFromLG($ChannelInfo);
 | 
				
			||||||
        elseif($ChannelSource == 'SK') :
 | 
					        elseif($ChannelSource == 'SK') :
 | 
				
			||||||
            GetEPGFromSK($ChannelInfo);
 | 
					            GetEPGFromSK($ChannelInfo);
 | 
				
			||||||
 | 
					        elseif($ChannelSource == 'SKB') :
 | 
				
			||||||
 | 
					            GetEPGFromSKB($ChannelInfo);
 | 
				
			||||||
        elseif($ChannelSource == 'SKY') :
 | 
					        elseif($ChannelSource == 'SKY') :
 | 
				
			||||||
            GetEPGFromSKY($ChannelInfo);
 | 
					            GetEPGFromSKY($ChannelInfo);
 | 
				
			||||||
        elseif($ChannelSource == 'NAVER') :
 | 
					        elseif($ChannelSource == 'NAVER') :
 | 
				
			||||||
@ -455,8 +459,9 @@ function GetEPGFromEPG($ChannelInfo) {
 | 
				
			|||||||
                        $subprogramName = "";
 | 
					                        $subprogramName = "";
 | 
				
			||||||
                        $rating = 0;
 | 
					                        $rating = 0;
 | 
				
			||||||
                        $episode = "";
 | 
					                        $episode = "";
 | 
				
			||||||
                        $rebroadcast = False;                        
 | 
					                        $rebroadcast = False;  
 | 
				
			||||||
                        preg_match('/<td height="25" valign="top">?(.*<a.*?">)?(.*?)\s*(<(.*)>)?\s*(\(재\))?\s*(\(([\d,]+)회\))?(<img.*?)?(<\/a>)?\s*<\/td>/', trim($dom->saveHTML($program)), $matches);
 | 
					                        $pattern = '/<td height="25" valign="top">?(.*<a.*?">)?(.*?)\s*(<(.*)>)?\s*(\(재\))?\s*(\(([\d,]+)회\))?(<img.*?)?(<\/a>)?\s*<\/td>/';
 | 
				
			||||||
 | 
					                        preg_match($pattern, trim($dom->saveHTML($program)), $matches);
 | 
				
			||||||
                        if ($matches != NULL) :
 | 
					                        if ($matches != NULL) :
 | 
				
			||||||
                            if(isset($matches[2])) $programName = trim($matches[2]) ?: "";
 | 
					                            if(isset($matches[2])) $programName = trim($matches[2]) ?: "";
 | 
				
			||||||
                            if(isset($matches[4])) $subprogramName = trim($matches[4]) ?: "";
 | 
					                            if(isset($matches[4])) $subprogramName = trim($matches[4]) ?: "";
 | 
				
			||||||
@ -554,7 +559,8 @@ function GetEPGFromKT($ChannelInfo) {
 | 
				
			|||||||
    foreach($zipped as $epg) :
 | 
					    foreach($zipped as $epg) :
 | 
				
			||||||
        $programName = "";
 | 
					        $programName = "";
 | 
				
			||||||
        $subprogramName = "";
 | 
					        $subprogramName = "";
 | 
				
			||||||
        preg_match('/^(.*?)( <(.*)>)?$/', $epg[0][0], $matches);
 | 
					        $pattern = '/^(.*?)( <(.*)>)?$/';
 | 
				
			||||||
 | 
					        preg_match($pattern, $epg[0][0], $matches);
 | 
				
			||||||
        if ($matches != NULL) :
 | 
					        if ($matches != NULL) :
 | 
				
			||||||
           if(isset($matches[1])) $programName = $matches[1] ?: "";
 | 
					           if(isset($matches[1])) $programName = $matches[1] ?: "";
 | 
				
			||||||
           if(isset($matches[3])) $subprogramName = $matches[3] ?: "";
 | 
					           if(isset($matches[3])) $subprogramName = $matches[3] ?: "";
 | 
				
			||||||
@ -631,7 +637,8 @@ function GetEPGFromLG($ChannelInfo) {
 | 
				
			|||||||
    endforeach;
 | 
					    endforeach;
 | 
				
			||||||
    $zipped = array_slice(array_map(NULL, $epginfo, array_slice($epginfo,1)),0,-1);
 | 
					    $zipped = array_slice(array_map(NULL, $epginfo, array_slice($epginfo,1)),0,-1);
 | 
				
			||||||
    foreach($zipped as $epg) :
 | 
					    foreach($zipped as $epg) :
 | 
				
			||||||
        preg_match('/(<재>?)?(.*?)(\[(.*)\])?\s?(\(([\d,]+)회\))?$/', $epg[0][0], $matches);
 | 
					        $pattern = '/(<재>?)?(.*?)(\[(.*)\])?\s?(\(([\d,]+)회\))?$/';
 | 
				
			||||||
 | 
					        preg_match($pattern, $epg[0][0], $matches);
 | 
				
			||||||
        $programName = "";
 | 
					        $programName = "";
 | 
				
			||||||
        $subprogramName = "";
 | 
					        $subprogramName = "";
 | 
				
			||||||
        $episode = "";
 | 
					        $episode = "";
 | 
				
			||||||
@ -701,7 +708,8 @@ function GetEPGFromSK($ChannelInfo) {
 | 
				
			|||||||
                        $subprogramName = "";
 | 
					                        $subprogramName = "";
 | 
				
			||||||
                        $episode = "";
 | 
					                        $episode = "";
 | 
				
			||||||
                        $rebroadcast = False;
 | 
					                        $rebroadcast = False;
 | 
				
			||||||
                        preg_match('/^(.*?)(?:\s*[\(<]([\d,회]+)[\)>])?(?:\s*<([^<]*?)>)?(\((재)\))?$/', str_replace('...', '>', $program['programName']), $matches);
 | 
					                        $pattern = '/^(.*?)(?:\s*[\(<]([\d,회]+)[\)>])?(?:\s*<([^<]*?)>)?(\((재)\))?$/';
 | 
				
			||||||
 | 
					                        preg_match($pattern, str_replace('...', '>', $program['programName']), $matches);
 | 
				
			||||||
                        if ($matches != NULL) :
 | 
					                        if ($matches != NULL) :
 | 
				
			||||||
                            if(isset($matches[1])) $programName = trim($matches[1]) ?: "";
 | 
					                            if(isset($matches[1])) $programName = trim($matches[1]) ?: "";
 | 
				
			||||||
                            if(isset($matches[3])) $subprogramName = trim($matches[3]) ?: "";
 | 
					                            if(isset($matches[3])) $subprogramName = trim($matches[3]) ?: "";
 | 
				
			||||||
@ -745,6 +753,88 @@ function GetEPGFromSK($ChannelInfo) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Get EPG data from SKB
 | 
				
			||||||
 | 
					function GetEPGFromSKB($ChannelInfo) {
 | 
				
			||||||
 | 
					    $ChannelId = $ChannelInfo[0];
 | 
				
			||||||
 | 
					    $ChannelName = $ChannelInfo[1];
 | 
				
			||||||
 | 
					    $ServiceId =  $ChannelInfo[3];
 | 
				
			||||||
 | 
					    $epginfo = array();
 | 
				
			||||||
 | 
					    foreach(range(1, $GLOBALS['period']) as $k) :
 | 
				
			||||||
 | 
					        $url = "http://www.skbroadband.com/content/realtime/Channel_List.do";
 | 
				
			||||||
 | 
					        $day = date("Ymd", strtotime("+".($k - 1)." days"));
 | 
				
			||||||
 | 
					        $params = array(
 | 
				
			||||||
 | 
					            'key_depth2' => $ServiceId,
 | 
				
			||||||
 | 
					            'key_depth3' => $day,
 | 
				
			||||||
 | 
					            'tab_gubun'  => 'lst'
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        $params = http_build_query($params);
 | 
				
			||||||
 | 
					        $method = "POST";
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            $response = getWeb($url, $params, $method);
 | 
				
			||||||
 | 
					            if ($response === False && $GLOBALS['debug']) :
 | 
				
			||||||
 | 
					                printError($ChannelName.HTTP_ERROR);
 | 
				
			||||||
 | 
					            else :
 | 
				
			||||||
 | 
					                $response = str_replace('charset="euc-kr"', 'charset="utf-8"', $response);
 | 
				
			||||||
 | 
					                $dom = new DomDocument;
 | 
				
			||||||
 | 
					                libxml_use_internal_errors(True);
 | 
				
			||||||
 | 
					                $response = mb_convert_encoding($response, "UTF-8", "EUC-KR");
 | 
				
			||||||
 | 
					                $dom->loadHTML($response);
 | 
				
			||||||
 | 
					                $xpath = new DomXPath($dom);
 | 
				
			||||||
 | 
					                $query = "//tr[@class='".$day."']";
 | 
				
			||||||
 | 
					                $rows = $xpath->query($query);
 | 
				
			||||||
 | 
					                foreach($rows as $row) :
 | 
				
			||||||
 | 
					                    $cells = $row->getElementsByTagName('td');
 | 
				
			||||||
 | 
					                    $pattern = '/^(.*?)(\(([\d,]+)회\))?(<(.*)>)?(\((재)\))?$/';
 | 
				
			||||||
 | 
					                    preg_match($pattern, trim($cells->item(0)->nodeValue), $matches);
 | 
				
			||||||
 | 
					                    if ($matches != NULL) :
 | 
				
			||||||
 | 
					                        if(isset($matches[1])) $programName = trim($matches[1]) ?: "";
 | 
				
			||||||
 | 
					                        if(isset($matches[5])) $subprogramName = trim($matches[5]) ?: "";
 | 
				
			||||||
 | 
					                        if(isset($matches[3])) $episode = $matches[3] ?: "";
 | 
				
			||||||
 | 
					                        if(isset($matches[7])) $rebroadcast = $matches[7] ? True : False;
 | 
				
			||||||
 | 
					                    endif;
 | 
				
			||||||
 | 
					                    preg_match('/.*\s*([\d,]+)\s*.*/', $cells->item(1)->nodeValue, $rating);
 | 
				
			||||||
 | 
					                    $startTime = $row->getElementsByTagName('th')->item(0)->nodeValue;
 | 
				
			||||||
 | 
					                    $startTime = date("YmdHis", strtotime($day." ".$startTime));
 | 
				
			||||||
 | 
					                    $rating = $rating[1];
 | 
				
			||||||
 | 
					                    //programName, startTime, rating, subprogramName, rebroadcast, episode
 | 
				
			||||||
 | 
					                    $epginfo[]= array($programName, $startTime, $rating, $subprogramName, $rebroadcast, $episode);
 | 
				
			||||||
 | 
					                endforeach;
 | 
				
			||||||
 | 
					            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 = trim($epg[0][0]) ?: "";
 | 
				
			||||||
 | 
					        $subprogramName = trim($epg[0][3]) ?: "";
 | 
				
			||||||
 | 
					        $episode = $epg[0][5] ?: "";
 | 
				
			||||||
 | 
					        $rebroadcast = $epg[0][4] ? True: False;
 | 
				
			||||||
 | 
					        $startTime = $epg[0][1] ?: "";
 | 
				
			||||||
 | 
					        $endTime = $epg[1][1] ?: "";
 | 
				
			||||||
 | 
					        $desc = "";
 | 
				
			||||||
 | 
					        $actors = "";
 | 
				
			||||||
 | 
					        $producers = "";
 | 
				
			||||||
 | 
					        $category = "";
 | 
				
			||||||
 | 
					        $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 SKY
 | 
					// Get EPG data from SKY
 | 
				
			||||||
function GetEPGFromSKY($ChannelInfo) {
 | 
					function GetEPGFromSKY($ChannelInfo) {
 | 
				
			||||||
    $ChannelId = $ChannelInfo[0];
 | 
					    $ChannelId = $ChannelInfo[0];
 | 
				
			||||||
@ -958,7 +1048,8 @@ function GetEPGFromMbc($ChannelInfo) {
 | 
				
			|||||||
                            if($program['Channel'] == "CHAM" && $program['LiveDays'] == $dayofweek[date("w", strtotime($day))]) :
 | 
					                            if($program['Channel'] == "CHAM" && $program['LiveDays'] == $dayofweek[date("w", strtotime($day))]) :
 | 
				
			||||||
                                $programName = "";
 | 
					                                $programName = "";
 | 
				
			||||||
                                $rebroadcast = False;
 | 
					                                $rebroadcast = False;
 | 
				
			||||||
                                preg_match('/^(.*?)(\(재\))?$/', htmlspecialchars_decode($program['ProgramTitle']), $matches);
 | 
					                                $pattern = '/^(.*?)(\(재\))?$/';
 | 
				
			||||||
 | 
					                                preg_match($pattern, htmlspecialchars_decode($program['ProgramTitle']), $matches);
 | 
				
			||||||
                                if ($matches != NULL) :
 | 
					                                if ($matches != NULL) :
 | 
				
			||||||
                                    $programName = $matches[1];
 | 
					                                    $programName = $matches[1];
 | 
				
			||||||
                                    $rebroadcast = $matches[2] ? True : False;
 | 
					                                    $rebroadcast = $matches[2] ? True : False;
 | 
				
			||||||
@ -1031,7 +1122,8 @@ function GetEPGFromMil($ChannelInfo) {
 | 
				
			|||||||
                        foreach($programs as $program) :
 | 
					                        foreach($programs as $program) :
 | 
				
			||||||
                            $programName = "";
 | 
					                            $programName = "";
 | 
				
			||||||
                            $rebroadcast = False;
 | 
					                            $rebroadcast = False;
 | 
				
			||||||
                            preg_match('/^(.*?)(\(재\))?$/', htmlspecialchars_decode($program['program_title']), $matches);
 | 
					                            $pattern = '/^(.*?)(\(재\))?$/';
 | 
				
			||||||
 | 
					                            preg_match($pattern, htmlspecialchars_decode($program['program_title']), $matches);
 | 
				
			||||||
                            if ($matches != NULL) :
 | 
					                            if ($matches != NULL) :
 | 
				
			||||||
                                $programName = $matches[1];
 | 
					                                $programName = $matches[1];
 | 
				
			||||||
                                $rebroadcast = $matches[2] ? True : False;
 | 
					                                $rebroadcast = $matches[2] ? True : False;
 | 
				
			||||||
@ -1232,8 +1324,16 @@ function writeProgram($programdata) {
 | 
				
			|||||||
    $ChannelId = $programdata['channelId'];
 | 
					    $ChannelId = $programdata['channelId'];
 | 
				
			||||||
    $startTime = $programdata['startTime'];
 | 
					    $startTime = $programdata['startTime'];
 | 
				
			||||||
    $endTime = $programdata['endTime'];
 | 
					    $endTime = $programdata['endTime'];
 | 
				
			||||||
    $programName = htmlspecialchars($programdata['programName'], ENT_XML1);
 | 
					    $programName = trim(htmlspecialchars($programdata['programName'], ENT_XML1));
 | 
				
			||||||
    $subprogramName = htmlspecialchars($programdata['subprogramName'], ENT_XML1);
 | 
					    $subprogramName = trim(htmlspecialchars($programdata['subprogramName'], ENT_XML1));
 | 
				
			||||||
 | 
					    preg_match('/(.*) \(?(\d+부)\)?/', $programName, $matches);
 | 
				
			||||||
 | 
					    if ($matches != NULL) :
 | 
				
			||||||
 | 
					        if(isset($matches[1])) $programName = trim($matches[1]) ?: "";
 | 
				
			||||||
 | 
					        if(isset($matches[2])) $subprogramName = trim($matches[2]." ".$subprogramName) ?: "";
 | 
				
			||||||
 | 
					    endif;
 | 
				
			||||||
 | 
					    if($programName == NULL):
 | 
				
			||||||
 | 
					        $programName = $subprogramName;
 | 
				
			||||||
 | 
					    endif;
 | 
				
			||||||
    $actors = htmlspecialchars($programdata['actors'], ENT_XML1);
 | 
					    $actors = htmlspecialchars($programdata['actors'], ENT_XML1);
 | 
				
			||||||
    $producers = htmlspecialchars($programdata['producers'], ENT_XML1);
 | 
					    $producers = htmlspecialchars($programdata['producers'], ENT_XML1);
 | 
				
			||||||
    $category = htmlspecialchars($programdata['category'], ENT_XML1);
 | 
					    $category = htmlspecialchars($programdata['category'], ENT_XML1);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										26
									
								
								epg2xml.py
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								epg2xml.py
									
									
									
									
									
								
							@ -157,8 +157,7 @@ def GetEPGFromEPG(ChannelInfo):
 | 
				
			|||||||
                thisday = day
 | 
					                thisday = day
 | 
				
			||||||
                row = tables[i].find_all('td', {'colspan':'2'})
 | 
					                row = tables[i].find_all('td', {'colspan':'2'})
 | 
				
			||||||
                for cell in row:
 | 
					                for cell in row:
 | 
				
			||||||
                    hour = int(cell.text.strip().strip('시'))
 | 
					                    hour = int(cell.text.strip().strip('시'))                  
 | 
				
			||||||
                  
 | 
					 | 
				
			||||||
                    if(i == 1) : hour = 'AM ' + str(hour)
 | 
					                    if(i == 1) : hour = 'AM ' + str(hour)
 | 
				
			||||||
                    elif(i == 2) : hour = 'PM ' + str(hour)
 | 
					                    elif(i == 2) : hour = 'PM ' + str(hour)
 | 
				
			||||||
                    elif(i == 3 and hour > 5 and hour < 12 ) : hour = 'PM ' + str(hour)
 | 
					                    elif(i == 3 and hour > 5 and hour < 12 ) : hour = 'PM ' + str(hour)
 | 
				
			||||||
@ -230,7 +229,8 @@ def GetEPGFromKT(ChannelInfo):
 | 
				
			|||||||
    for epg1, epg2 in zip(epginfo, epginfo[1:]):
 | 
					    for epg1, epg2 in zip(epginfo, epginfo[1:]):
 | 
				
			||||||
        programName = ''
 | 
					        programName = ''
 | 
				
			||||||
        subprogrmaName = ''
 | 
					        subprogrmaName = ''
 | 
				
			||||||
        matches = re.match('^(.*?)( <(.*)>)?$', epg1[0].decode('string_escape'))
 | 
					        pattern = '^(.*?)( <(.*)>)?$'
 | 
				
			||||||
 | 
					        matches = re.match(pattern, epg1[0].decode('string_escape'))
 | 
				
			||||||
        if not (matches is None):
 | 
					        if not (matches is None):
 | 
				
			||||||
            programName = matches.group(1) if matches.group(1) else ''
 | 
					            programName = matches.group(1) if matches.group(1) else ''
 | 
				
			||||||
            subprogramName = matches.group(3) if matches.group(3) else ''
 | 
					            subprogramName = matches.group(3) if matches.group(3) else ''
 | 
				
			||||||
@ -285,7 +285,8 @@ def GetEPGFromLG(ChannelInfo):
 | 
				
			|||||||
        programName = ''
 | 
					        programName = ''
 | 
				
			||||||
        subprogramName = ''
 | 
					        subprogramName = ''
 | 
				
			||||||
        episode = ''
 | 
					        episode = ''
 | 
				
			||||||
        matches = re.match('(<재>?)?(.*?)(\[(.*)\])?\s?(\(([\d,]+)회\))?$',  epg1[0].decode('string_escape'))
 | 
					        pattern = '(<재>?)?(.*?)(\[(.*)\])?\s?(\(([\d,]+)회\))?$'
 | 
				
			||||||
 | 
					        matches = re.match(pattern,  epg1[0].decode('string_escape'))
 | 
				
			||||||
        rebroadcast = False
 | 
					        rebroadcast = False
 | 
				
			||||||
        if not (matches is None):
 | 
					        if not (matches is None):
 | 
				
			||||||
            programName = matches.group(2) if matches.group(2) else ''
 | 
					            programName = matches.group(2) if matches.group(2) else ''
 | 
				
			||||||
@ -328,7 +329,8 @@ def GetEPGFromSK(ChannelInfo):
 | 
				
			|||||||
                    subprogramName = ''
 | 
					                    subprogramName = ''
 | 
				
			||||||
                    episode = ''
 | 
					                    episode = ''
 | 
				
			||||||
                    rebroadcast = False
 | 
					                    rebroadcast = False
 | 
				
			||||||
                    matches = re.match('^(.*?)(?:\s*[\(<]([\d,회]+)[\)>])?(?:\s*<([^<]*?)>)?(\((재)\))?$', program['programName'].replace('...', '>').encode('utf-8'))
 | 
					                    pattern = '^(.*?)(?:\s*[\(<]([\d,회]+)[\)>])?(?:\s*<([^<]*?)>)?(\((재)\))?$'
 | 
				
			||||||
 | 
					                    matches = re.match(pattern, program['programName'].replace('...', '>').encode('utf-8'))
 | 
				
			||||||
                    if not (matches is None):
 | 
					                    if not (matches is None):
 | 
				
			||||||
                        programName = matches.group(1).strip() if matches.group(1) else ''
 | 
					                        programName = matches.group(1).strip() if matches.group(1) else ''
 | 
				
			||||||
                        subprogramName = matches.group(3).strip() if matches.group(3) else ''
 | 
					                        subprogramName = matches.group(3).strip() if matches.group(3) else ''
 | 
				
			||||||
@ -378,7 +380,6 @@ def GetEPGFromSKB(ChannelInfo):
 | 
				
			|||||||
                for row in html:
 | 
					                for row in html:
 | 
				
			||||||
                    startTime = str(day) + ' ' + row.find('th').text
 | 
					                    startTime = str(day) + ' ' + row.find('th').text
 | 
				
			||||||
                    for cell in [row.find_all('td')]:
 | 
					                    for cell in [row.find_all('td')]:
 | 
				
			||||||
                        pattern = "(.*?)\s*(\(([\d,]+)회\))?\s*(<(.*)>)?\s*(\(재\)?)"
 | 
					 | 
				
			||||||
                        pattern = "^(.*?)(\(([\d,]+)회\))?(<(.*)>)?(\((재)\))?$"
 | 
					                        pattern = "^(.*?)(\(([\d,]+)회\))?(<(.*)>)?(\((재)\))?$"
 | 
				
			||||||
                        matches = re.match(pattern, cell[0].text.decode('string_escape'))
 | 
					                        matches = re.match(pattern, cell[0].text.decode('string_escape'))
 | 
				
			||||||
                        if not(matches is None) :
 | 
					                        if not(matches is None) :
 | 
				
			||||||
@ -538,7 +539,8 @@ def GetEPGFromMbc(ChannelInfo):
 | 
				
			|||||||
                    if program['Channel'] == "CHAM" and program['LiveDays'] == dayofweek[day.weekday()]:
 | 
					                    if program['Channel'] == "CHAM" and program['LiveDays'] == dayofweek[day.weekday()]:
 | 
				
			||||||
                        programName = ''
 | 
					                        programName = ''
 | 
				
			||||||
                        rebroadcast = True
 | 
					                        rebroadcast = True
 | 
				
			||||||
                        matches = re.match('^(.*?)(\(재\))?$', unescape(program['ProgramTitle'].encode('utf-8', 'ignore')))
 | 
					                        pattern = '^(.*?)(\(재\))?$'
 | 
				
			||||||
 | 
					                        matches = re.match(pattern, unescape(program['ProgramTitle'].encode('utf-8', 'ignore')))
 | 
				
			||||||
                        if not(matches is None):
 | 
					                        if not(matches is None):
 | 
				
			||||||
                            programName = matches.group(1)
 | 
					                            programName = matches.group(1)
 | 
				
			||||||
                            rebroadcast = True if matches.group(2) else False
 | 
					                            rebroadcast = True if matches.group(2) else False
 | 
				
			||||||
@ -581,7 +583,8 @@ def GetEPGFromMil(ChannelInfo):
 | 
				
			|||||||
                for program in data['resultList']:
 | 
					                for program in data['resultList']:
 | 
				
			||||||
                    programName = ''
 | 
					                    programName = ''
 | 
				
			||||||
                    rebroadcast = False
 | 
					                    rebroadcast = False
 | 
				
			||||||
                    matches = re.match('^(.*?)(\(재\))?$', unescape(program['program_title'].encode('utf-8', 'ignore')))
 | 
					                    pattern = '^(.*?)(\(재\))?$'
 | 
				
			||||||
 | 
					                    matches = re.match(pattern, unescape(program['program_title'].encode('utf-8', 'ignore')))
 | 
				
			||||||
                    if not(matches is None):
 | 
					                    if not(matches is None):
 | 
				
			||||||
                        programName = matches.group(1)
 | 
					                        programName = matches.group(1)
 | 
				
			||||||
                        rebroadcast = True if matches.group(2) else False
 | 
					                        rebroadcast = True if matches.group(2) else False
 | 
				
			||||||
@ -680,7 +683,8 @@ def GetEPGFromKbs(ChannelInfo):
 | 
				
			|||||||
                for row in soup.find_all('li'):
 | 
					                for row in soup.find_all('li'):
 | 
				
			||||||
                    programName = ''
 | 
					                    programName = ''
 | 
				
			||||||
                    startTime = ''
 | 
					                    startTime = ''
 | 
				
			||||||
                    matches = re.match('([0-2][0-9]:[0-5][0-9])[0-2][0-9]:[0-5][0-9]\[(.*)\] Broadcast', unescape(row.text.encode('utf-8', 'ignore')))
 | 
					                    pattern = '([0-2][0-9]:[0-5][0-9])[0-2][0-9]:[0-5][0-9]\[(.*)\] Broadcast'
 | 
				
			||||||
 | 
					                    matches = re.match(pattern, unescape(row.text.encode('utf-8', 'ignore')))
 | 
				
			||||||
                    if not(matches is None):
 | 
					                    if not(matches is None):
 | 
				
			||||||
                        programName = unescape(matches.group(2))
 | 
					                        programName = unescape(matches.group(2))
 | 
				
			||||||
                        startTime = str(day) + ' ' + matches.group(1)
 | 
					                        startTime = str(day) + ' ' + matches.group(1)
 | 
				
			||||||
@ -716,8 +720,8 @@ def writeProgram(programdata):
 | 
				
			|||||||
    ChannelId = programdata['channelId']
 | 
					    ChannelId = programdata['channelId']
 | 
				
			||||||
    startTime = programdata['startTime']
 | 
					    startTime = programdata['startTime']
 | 
				
			||||||
    endTime = programdata['endTime']
 | 
					    endTime = programdata['endTime']
 | 
				
			||||||
    programName = escape(programdata['programName'])
 | 
					    programName = escape(programdata['programName']).strip()
 | 
				
			||||||
    subprogramName = escape(programdata['subprogramName'])
 | 
					    subprogramName = escape(programdata['subprogramName']).strip()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    matches = re.match('(.*) \(?(\d+부)\)?', unescape(programName.encode('utf-8', 'ignore')))
 | 
					    matches = re.match('(.*) \(?(\d+부)\)?', unescape(programName.encode('utf-8', 'ignore')))
 | 
				
			||||||
    if not(matches is None):
 | 
					    if not(matches is None):
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user