commit
c883a57f19
@ -3,7 +3,7 @@
|
|||||||
@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.4");
|
define("VERSION", "1.2.4p1");
|
||||||
$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'";
|
||||||
$timeout = 5;
|
$timeout = 5;
|
||||||
@ -353,14 +353,14 @@ function getEPG() {
|
|||||||
fprintf($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
fprintf($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
||||||
fprintf($fp, "<!DOCTYPE tv SYSTEM \"xmltv.dtd\">\n\n");
|
fprintf($fp, "<!DOCTYPE tv SYSTEM \"xmltv.dtd\">\n\n");
|
||||||
fprintf($fp, "<tv generator-info-name=\"epg2xml %s\">\n", VERSION);
|
fprintf($fp, "<tv generator-info-name=\"epg2xml %s\">\n", VERSION);
|
||||||
|
|
||||||
foreach ($Channeldatajson as $Channeldata) : //Get Channel & Print Channel info
|
foreach ($Channeldatajson as $Channeldata) : //Get Channel & Print Channel info
|
||||||
if(in_array($Channeldata['Id'], $MyChannelInfo)) :
|
if(in_array($Channeldata['Id'], $MyChannelInfo)) :
|
||||||
$ChannelId = $Channeldata['Id'];
|
$ChannelId = $Channeldata['Id'];
|
||||||
$ChannelName = htmlspecialchars($Channeldata['Name'], ENT_XML1);
|
$ChannelName = htmlspecialchars($Channeldata['Name'], ENT_XML1);
|
||||||
$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);
|
||||||
if($MyISP != "ALL" && $Channeldata[$MyISP.'Ch'] != Null):
|
if($MyISP != "ALL" && $Channeldata[$MyISP.'Ch'] != Null):
|
||||||
$ChannelInfos[] = array($ChannelId, $ChannelName, $ChannelSource, $ChannelServiceId);
|
$ChannelInfos[] = array($ChannelId, $ChannelName, $ChannelSource, $ChannelServiceId);
|
||||||
$Channelnumber = $Channeldata[$MyISP.'Ch'];
|
$Channelnumber = $Channeldata[$MyISP.'Ch'];
|
||||||
@ -676,7 +676,7 @@ function GetEPGFromSK($ChannelInfo) {
|
|||||||
$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($data['channel'] == NULL) :
|
if($data['channel'] == NULL) :
|
||||||
if($GLOBALS['debug']) :
|
if($GLOBALS['debug']) :
|
||||||
printError($ChannelName.CHANNEL_ERROR);
|
printError($ChannelName.CHANNEL_ERROR);
|
||||||
endif;
|
endif;
|
||||||
else :
|
else :
|
||||||
@ -909,7 +909,7 @@ function GetEPGFromNaver($ChannelInfo) {
|
|||||||
'u4' => $GLOBALS['period'],
|
'u4' => $GLOBALS['period'],
|
||||||
'u5' => $ServiceId,
|
'u5' => $ServiceId,
|
||||||
'u6' => 1,
|
'u6' => 1,
|
||||||
'u7' => $ChannelName."편성표",
|
'u7' => $ChannelName."편성표",
|
||||||
'u8' => $ChannelName."편성표",
|
'u8' => $ChannelName."편성표",
|
||||||
'where' => 'nexearch'
|
'where' => 'nexearch'
|
||||||
);
|
);
|
||||||
@ -927,7 +927,7 @@ function GetEPGFromNaver($ChannelInfo) {
|
|||||||
$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($data['displayDates'][0]['count'] == 0) :
|
if($data['displayDates'][0]['count'] == 0) :
|
||||||
if($GLOBALS['debug']) :
|
if($GLOBALS['debug']) :
|
||||||
printError($ChannelName.CHANNEL_ERROR);
|
printError($ChannelName.CHANNEL_ERROR);
|
||||||
endif;
|
endif;
|
||||||
else :
|
else :
|
||||||
@ -969,7 +969,7 @@ function GetEPGFromIscs($ChannelInfo) {
|
|||||||
foreach(range(1, $GLOBALS['period']) as $k) :
|
foreach(range(1, $GLOBALS['period']) as $k) :
|
||||||
$istomorrow = False;
|
$istomorrow = False;
|
||||||
$url = "https://www.iscs.co.kr/service/sub/ajax_channel_view.asp";
|
$url = "https://www.iscs.co.kr/service/sub/ajax_channel_view.asp";
|
||||||
$day = date("Y-m-d", strtotime("+".($k - 1)." days"));
|
$day = date("Y-m-d", strtotime("+".($k - 2)." days"));
|
||||||
$params = array(
|
$params = array(
|
||||||
's_idx' => $ServiceId,
|
's_idx' => $ServiceId,
|
||||||
'c_date' => $day
|
'c_date' => $day
|
||||||
@ -1123,7 +1123,7 @@ function GetEPGFromPooq($ChannelInfo) {
|
|||||||
$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($data['result']['count'] == 0) :
|
if($data['result']['count'] == 0) :
|
||||||
if($GLOBALS['debug']) :
|
if($GLOBALS['debug']) :
|
||||||
printError($ChannelName.CHANNEL_ERROR);
|
printError($ChannelName.CHANNEL_ERROR);
|
||||||
endif;
|
endif;
|
||||||
else :
|
else :
|
||||||
@ -1229,7 +1229,7 @@ function GetEPGFromOksusu($ChannelInfo) {
|
|||||||
'end_time' => $lastday.'24',
|
'end_time' => $lastday.'24',
|
||||||
'tgroup' => 'oksusutest_02|null',
|
'tgroup' => 'oksusutest_02|null',
|
||||||
'IF' => 'IF-NSMEPG-003',
|
'IF' => 'IF-NSMEPG-003',
|
||||||
'response_format' => 'json',
|
'response_format' => 'json',
|
||||||
'm' => 'ch_epg',
|
'm' => 'ch_epg',
|
||||||
'ver' => '1.0'
|
'ver' => '1.0'
|
||||||
);
|
);
|
||||||
@ -1244,7 +1244,7 @@ function GetEPGFromOksusu($ChannelInfo) {
|
|||||||
$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($data['channel'] == NULL) :
|
if($data['channel'] == NULL) :
|
||||||
if($GLOBALS['debug']) :
|
if($GLOBALS['debug']) :
|
||||||
printError($ChannelName.CHANNEL_ERROR);
|
printError($ChannelName.CHANNEL_ERROR);
|
||||||
endif;
|
endif;
|
||||||
else :
|
else :
|
||||||
@ -1322,7 +1322,7 @@ function GetEPGFromMbc($ChannelInfo) {
|
|||||||
$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['Programs']) == 0) :
|
if(count($data['Programs']) == 0) :
|
||||||
if($GLOBALS['debug']) :
|
if($GLOBALS['debug']) :
|
||||||
printError($ChannelName.CHANNEL_ERROR);
|
printError($ChannelName.CHANNEL_ERROR);
|
||||||
endif;
|
endif;
|
||||||
else :
|
else :
|
||||||
@ -1393,7 +1393,7 @@ function GetEPGFromMil($ChannelInfo) {
|
|||||||
$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['resultList']) == 0) :
|
if(count($data['resultList']) == 0) :
|
||||||
if($GLOBALS['debug']) :
|
if($GLOBALS['debug']) :
|
||||||
printError($ChannelName.CHANNEL_ERROR);
|
printError($ChannelName.CHANNEL_ERROR);
|
||||||
endif;
|
endif;
|
||||||
else :
|
else :
|
||||||
@ -1467,7 +1467,7 @@ function GetEPGFromIfm($ChannelInfo) {
|
|||||||
$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['hybMusicInfoList']) == 0) :
|
if(count($data['hybMusicInfoList']) == 0) :
|
||||||
if($GLOBALS['debug']) :
|
if($GLOBALS['debug']) :
|
||||||
printError($ChannelName.CHANNEL_ERROR);
|
printError($ChannelName.CHANNEL_ERROR);
|
||||||
endif;
|
endif;
|
||||||
else :
|
else :
|
||||||
@ -1534,7 +1534,7 @@ function GetEPGFromKbs($ChannelInfo) {
|
|||||||
$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['schedule']) == 0) :
|
if(count($data['schedule']) == 0) :
|
||||||
if($GLOBALS['debug']) :
|
if($GLOBALS['debug']) :
|
||||||
printError($ChannelName.CHANNEL_ERROR);
|
printError($ChannelName.CHANNEL_ERROR);
|
||||||
endif;
|
endif;
|
||||||
else :
|
else :
|
||||||
@ -1675,7 +1675,7 @@ function epgzip($epginfo) {
|
|||||||
);
|
);
|
||||||
writeProgram($programdata);
|
writeProgram($programdata);
|
||||||
$epg1 = $epg2;
|
$epg1 = $epg2;
|
||||||
endforeach;
|
endforeach;
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeProgram($programdata) {
|
function writeProgram($programdata) {
|
||||||
|
26
epg2xml.py
26
epg2xml.py
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
@ -44,7 +44,7 @@ if not sys.version_info[:2] == (2, 7):
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
# Set variable
|
# Set variable
|
||||||
__version__ = '1.2.4'
|
__version__ = '1.2.4p1'
|
||||||
debug = False
|
debug = False
|
||||||
today = datetime.date.today()
|
today = datetime.date.today()
|
||||||
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': '*/*'}
|
||||||
@ -392,6 +392,7 @@ def GetEPGFromSKB(ChannelInfo):
|
|||||||
data = re.sub(pattern, partial(replacement, tag='span'), data)
|
data = re.sub(pattern, partial(replacement, tag='span'), data)
|
||||||
strainer = SoupStrainer('div', {'id':'dawn'})
|
strainer = SoupStrainer('div', {'id':'dawn'})
|
||||||
soup = BeautifulSoup(data, htmlparser, parse_only=strainer, from_encoding='utf-8')
|
soup = BeautifulSoup(data, htmlparser, parse_only=strainer, from_encoding='utf-8')
|
||||||
|
soup = soup.prettify()
|
||||||
html = soup.find_all('li') if soup.find_all('li') else ''
|
html = soup.find_all('li') if soup.find_all('li') else ''
|
||||||
if(html):
|
if(html):
|
||||||
for row in html:
|
for row in html:
|
||||||
@ -401,14 +402,17 @@ def GetEPGFromSKB(ChannelInfo):
|
|||||||
startTime = str(day) + ' ' + row.find('span', {'class':'time'}).text
|
startTime = str(day) + ' ' + row.find('span', {'class':'time'}).text
|
||||||
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')
|
||||||
cell = row.find('span', {'class':'title'}).text.decode('string_escape').strip()
|
cell = row.find('span', {'class':'title'})
|
||||||
pattern = "^(.*?)(\(([\d,]+)회\))?(<(.*)>)?(\((재)\))?$"
|
print(cell)
|
||||||
matches = re.match(pattern, cell)
|
if(cell):
|
||||||
if not(matches is None) :
|
cell = cell.text.decode('string_escape').strip()
|
||||||
programName = matches.group(1) if matches.group(1) else ''
|
pattern = "^(.*?)(\(([\d,]+)회\))?(<(.*)>)?(\((재)\))?$"
|
||||||
subprogramName = matches.group(5) if matches.group(5) else ''
|
matches = re.match(pattern, cell)
|
||||||
rebroadcast = True if matches.group(7) else False
|
if not(matches is None) :
|
||||||
episode = matches.group(3) if matches.group(3) else ''
|
programName = matches.group(1) if matches.group(1) else ''
|
||||||
|
subprogramName = matches.group(5) if matches.group(5) else ''
|
||||||
|
rebroadcast = True if matches.group(7) else False
|
||||||
|
episode = matches.group(3) if matches.group(3) else ''
|
||||||
rating = row.find('span', {'class':re.compile('^watch.*$')})
|
rating = row.find('span', {'class':re.compile('^watch.*$')})
|
||||||
if not(rating is None) :
|
if not(rating is None) :
|
||||||
rating = int(rating.text.decode('string_escape').replace('세','').strip())
|
rating = int(rating.text.decode('string_escape').replace('세','').strip())
|
||||||
@ -459,7 +463,7 @@ def GetEPGFromSKY(ChannelInfo):
|
|||||||
desc = description if description else ''
|
desc = description if description else ''
|
||||||
if desc:
|
if desc:
|
||||||
if summary : desc = desc + '\n' + summary
|
if summary : desc = desc + '\n' + summary
|
||||||
else:
|
else:
|
||||||
desc = summary
|
desc = summary
|
||||||
category = program['program_category1']
|
category = program['program_category1']
|
||||||
episode = program['episode_id'] if program['episode_id'] else ''
|
episode = program['episode_id'] if program['episode_id'] else ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user