commit
ff0d80c2cc
@ -636,7 +636,9 @@ function GetEPGFromIscs($ChannelInfo) {
|
|||||||
$ChannelName = $ChannelInfo[1];
|
$ChannelName = $ChannelInfo[1];
|
||||||
$ServiceId = $ChannelInfo[3];
|
$ServiceId = $ChannelInfo[3];
|
||||||
$epginfo = array();
|
$epginfo = array();
|
||||||
|
$epginfo2 = array();
|
||||||
foreach(range(1, $GLOBALS['period']) as $k) :
|
foreach(range(1, $GLOBALS['period']) as $k) :
|
||||||
|
$istomorrow = False;
|
||||||
$url = "http://m.iscs.co.kr/sub/02/data.asp";
|
$url = "http://m.iscs.co.kr/sub/02/data.asp";
|
||||||
$day = date("Y-m-d", strtotime("+".($k - 1)." days"));
|
$day = date("Y-m-d", strtotime("+".($k - 1)." days"));
|
||||||
$params = array(
|
$params = array(
|
||||||
@ -664,7 +666,13 @@ function GetEPGFromIscs($ChannelInfo) {
|
|||||||
$startTime = $endTime = $programName = $subprogramName = $desc = $actors = $producers = $category = $episode = "";
|
$startTime = $endTime = $programName = $subprogramName = $desc = $actors = $producers = $category = $episode = "";
|
||||||
$rebroadcast = False;
|
$rebroadcast = False;
|
||||||
$rating = 0;
|
$rating = 0;
|
||||||
|
if(startsWith($program['Time'], '1') || startsWith($program['Time'], '2')) $istomorrow = True;
|
||||||
|
if(startsWith($program['Time'], '0') && $istomorrow == True) :
|
||||||
|
// $thisday = date("Ymd", strtotime($day." +1 days"));
|
||||||
|
$startTime = date("YmdHis", strtotime($day." +1 days"." ".$program['Time']));
|
||||||
|
else :
|
||||||
$startTime = date("YmdHis", strtotime($day." ".$program['Time']));
|
$startTime = date("YmdHis", strtotime($day." ".$program['Time']));
|
||||||
|
endif;
|
||||||
$pattern = '/^(.*?)(?:\(([\d,]+)회\))?(?:\((재)\))?$/';
|
$pattern = '/^(.*?)(?:\(([\d,]+)회\))?(?:\((재)\))?$/';
|
||||||
preg_match($pattern, trim($program['Pg_Name']), $matches);
|
preg_match($pattern, trim($program['Pg_Name']), $matches);
|
||||||
if ($matches != NULL) :
|
if ($matches != NULL) :
|
||||||
@ -690,7 +698,9 @@ function GetEPGFromIscs($ChannelInfo) {
|
|||||||
if($GLOBALS['debug']) printError($e->getMessage());
|
if($GLOBALS['debug']) printError($e->getMessage());
|
||||||
}
|
}
|
||||||
endforeach;
|
endforeach;
|
||||||
epgzip($epginfo);
|
$epginfo2 = array_map("unserialize", array_unique(array_map("serialize", $epginfo)));
|
||||||
|
epgzip($epginfo2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get EPG data from Hcn
|
// Get EPG data from Hcn
|
||||||
@ -1111,8 +1121,6 @@ function GetEPGFromArirang($ChannelInfo) {
|
|||||||
else :
|
else :
|
||||||
$dom = new DomDocument;
|
$dom = new DomDocument;
|
||||||
libxml_use_internal_errors(True);
|
libxml_use_internal_errors(True);
|
||||||
//echo $response;
|
|
||||||
|
|
||||||
$response = mb_convert_encoding($response, "HTML-ENTITIES", "EUC-KR");
|
$response = mb_convert_encoding($response, "HTML-ENTITIES", "EUC-KR");
|
||||||
if($dom->loadHTML($response)):
|
if($dom->loadHTML($response)):
|
||||||
$xpath = new DomXPath($dom);
|
$xpath = new DomXPath($dom);
|
||||||
@ -1169,6 +1177,7 @@ function GetEPGFromArirang($ChannelInfo) {
|
|||||||
|
|
||||||
# Zip epginfo
|
# Zip epginfo
|
||||||
function epgzip($epginfo) {
|
function epgzip($epginfo) {
|
||||||
|
if($epginfo == NULL) $epginfo = array();
|
||||||
#ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating
|
#ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating
|
||||||
$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) :
|
||||||
@ -1347,4 +1356,8 @@ function _microtime() {
|
|||||||
list($usec, $sec) = explode(" ", microtime());
|
list($usec, $sec) = explode(" ", microtime());
|
||||||
return ($sec.(int)($usec*1000));
|
return ($sec.(int)($usec*1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function startsWith($haystack, $needle) {
|
||||||
|
return !strncmp($haystack, $needle, strlen($needle));
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -3,7 +3,7 @@ include __DIR__."/epg2xml-function.php";
|
|||||||
@date_default_timezone_set('Asia/Seoul');
|
@date_default_timezone_set('Asia/Seoul');
|
||||||
error_reporting(E_ALL ^ E_NOTICE);
|
error_reporting(E_ALL ^ E_NOTICE);
|
||||||
@set_time_limit(0);
|
@set_time_limit(0);
|
||||||
define("VERSION", "1.2.2p1");
|
define("VERSION", "1.2.2p2");
|
||||||
|
|
||||||
$debug = False;
|
$debug = False;
|
||||||
$ua = "'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36'";
|
$ua = "'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36'";
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
include __DIR__."/epg2xml-function.php";
|
include __DIR__."/epg2xml-function.php";
|
||||||
@date_default_timezone_set('Asia/Seoul');
|
@date_default_timezone_set('Asia/Seoul');
|
||||||
error_reporting(E_ALL ^ E_NOTICE);
|
error_reporting(E_ALL ^ E_NOTICE);
|
||||||
define("VERSION", "1.2.2p1");
|
define("VERSION", "1.2.2p2");
|
||||||
|
|
||||||
$debug = False;
|
$debug = False;
|
||||||
$ua = "'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36'";
|
$ua = "'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36'";
|
||||||
|
14
epg2xml.py
14
epg2xml.py
@ -38,7 +38,7 @@ except ImportError:
|
|||||||
reload(sys)
|
reload(sys)
|
||||||
sys.setdefaultencoding('utf-8')
|
sys.setdefaultencoding('utf-8')
|
||||||
|
|
||||||
__version__ = '1.2.2p1'
|
__version__ = '1.2.2p2'
|
||||||
|
|
||||||
if not sys.version_info[:2] == (2, 7):
|
if not sys.version_info[:2] == (2, 7):
|
||||||
print("Error : ", "python 2.7 버전이 필요합니다.", file=sys.stderr)
|
print("Error : ", "python 2.7 버전이 필요합니다.", file=sys.stderr)
|
||||||
@ -518,8 +518,10 @@ def GetEPGFromIscs(ChannelInfo):
|
|||||||
ChannelName = ChannelInfo[1]
|
ChannelName = ChannelInfo[1]
|
||||||
ServiceId = ChannelInfo[3]
|
ServiceId = ChannelInfo[3]
|
||||||
epginfo = []
|
epginfo = []
|
||||||
|
epginfo2 = []
|
||||||
url='http://m.iscs.co.kr/sub/02/data.asp'
|
url='http://m.iscs.co.kr/sub/02/data.asp'
|
||||||
for k in range(period):
|
for k in range(period):
|
||||||
|
istomorrow = False
|
||||||
day = today + datetime.timedelta(days=k)
|
day = today + datetime.timedelta(days=k)
|
||||||
params = {'Exec_Mode': 'view', 'Source_Id': ServiceId, 'Ch_Day': day}
|
params = {'Exec_Mode': 'view', 'Source_Id': ServiceId, 'Ch_Day': day}
|
||||||
response = requests.post(url, data=params, headers=ua, timeout=timeout)
|
response = requests.post(url, data=params, headers=ua, timeout=timeout)
|
||||||
@ -533,6 +535,11 @@ def GetEPGFromIscs(ChannelInfo):
|
|||||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||||
rebroadcast = False
|
rebroadcast = False
|
||||||
rating = 0
|
rating = 0
|
||||||
|
if program['Time'].startswith('1') or program['Time'].startswith('2'):
|
||||||
|
istomorrow = True
|
||||||
|
if program['Time'].startswith('0') and istomorrow == True:
|
||||||
|
startTime = str(day + datetime.timedelta(days=1)) + ' ' + program['Time']
|
||||||
|
else:
|
||||||
startTime = str(day) + ' ' + program['Time']
|
startTime = str(day) + ' ' + program['Time']
|
||||||
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %H:%M')
|
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %H:%M')
|
||||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||||
@ -555,7 +562,10 @@ def GetEPGFromIscs(ChannelInfo):
|
|||||||
except (requests.RequestException) as e:
|
except (requests.RequestException) as e:
|
||||||
if(debug): printError(ChannelName + str(e))
|
if(debug): printError(ChannelName + str(e))
|
||||||
else: pass
|
else: pass
|
||||||
epgzip(epginfo)
|
for i in epginfo:
|
||||||
|
if not i in epginfo2:
|
||||||
|
epginfo2.append(i)
|
||||||
|
epgzip(epginfo2)
|
||||||
|
|
||||||
# Get EPG data from HCN
|
# Get EPG data from HCN
|
||||||
def GetEPGFromHcn(ChannelInfo):
|
def GetEPGFromHcn(ChannelInfo):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user