update 1.2.4 ISCS 함수 수정
This commit is contained in:
parent
a8f0ce75f0
commit
0fa73d38cc
@ -1,7 +1,6 @@
|
||||
# EPG2XML
|
||||
이 프로그램은 EPG(Electronic Program Guide)를 웹상의 여러 소스에서 가져와서 XML로 출력하는 프로그램으로 python2.7 및 php5.4.45 이상에서 사용 가능하도록 제작되었다.
|
||||
python3과 php 5.4.45 이하에서는 정상적인 작동을 보장하지 못한다.
|
||||
또한 외부의 소스를 분석하여 EPG 정보를 가공하여 보여주는 것이므로 외부 소스 사이트가 변경되거나 삭제되면 문제가 발생할 수 있다.
|
||||
python3과 php 5.4.45 이하에서는 정상적인 작동을 보장하지 못한다. 또한 외부의 소스를 분석하여 EPG 정보를 가공하여 보여주는 것이므로 외부 소스 사이트가 변경되거나 삭제되면 문제가 발생할 수 있다.
|
||||
|
||||
## 개발자 후원하기
|
||||
https://www.facebook.com/chericface
|
||||
@ -119,6 +118,8 @@ https://github.com/wonipapa/epg2xml/wiki
|
||||
https://github.com/wonipapa/epg2xml/wiki/FAQ
|
||||
|
||||
## 변경사항
|
||||
### Version 1.2.4
|
||||
- ISCS 함수 수정
|
||||
### Version 1.2.3
|
||||
- PHP 버전통합
|
||||
- PYTHON 버전 html Parser 변수 추가(libxml지원안하는 기기 편의 지원)
|
||||
|
@ -3,7 +3,7 @@
|
||||
@date_default_timezone_set('Asia/Seoul');
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
@set_time_limit(0);
|
||||
define("VERSION", "1.2.3p5");
|
||||
define("VERSION", "1.2.4");
|
||||
$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'";
|
||||
$timeout = 5;
|
||||
@ -968,12 +968,11 @@ function GetEPGFromIscs($ChannelInfo) {
|
||||
$epginfo2 = array();
|
||||
foreach(range(1, $GLOBALS['period']) as $k) :
|
||||
$istomorrow = False;
|
||||
$url = "http://m.iscs.co.kr/sub/02/data.asp";
|
||||
$url = "https://www.iscs.co.kr/service/sub/ajax_channel_view.asp";
|
||||
$day = date("Y-m-d", strtotime("+".($k - 1)." days"));
|
||||
$params = array(
|
||||
'Exec_Mode' => 'view',
|
||||
'Source_Id' => $ServiceId,
|
||||
'Ch_Day' => $day
|
||||
's_idx' => $ServiceId,
|
||||
'c_date' => $day
|
||||
);
|
||||
$params = http_build_query($params);
|
||||
$method = "POST";
|
||||
@ -985,12 +984,50 @@ function GetEPGFromIscs($ChannelInfo) {
|
||||
try {
|
||||
$data = json_decode($response, TRUE);
|
||||
if(json_last_error() != JSON_ERROR_NONE) throw new Exception(JSON_SYNTAX_ERROR);
|
||||
if(count($data['total']) == 0) :
|
||||
if($data['result'] == 0) :
|
||||
if($GLOBALS['debug']) :
|
||||
printError($ChannelName.CHANNEL_ERROR);
|
||||
endif;
|
||||
else :
|
||||
$programs = $data['list'];
|
||||
$response = $data['html'];
|
||||
$dom = new DomDocument;
|
||||
libxml_use_internal_errors(True);
|
||||
|
||||
if($dom->loadHTML('<?xml encoding="utf-8" ?>'.$response)):
|
||||
$xpath = new DomXPath($dom);
|
||||
$query = "//tbody/tr";
|
||||
$rows = $xpath->query($query);
|
||||
foreach($rows as $row) :
|
||||
$startTime = $endTime = $programName = $subprogramName = $desc = $actors = $producers = $category = $episode = "";
|
||||
$rebroadcast = False;
|
||||
$rating = 0;
|
||||
$cells = $row->getElementsByTagName('td');
|
||||
$startTime = $cells->item(0)->nodeValue ?: "";
|
||||
$startTime = date("YmdHis", strtotime($day." ".$startTime));
|
||||
$programName = trim($cells->item(1)->nodeValue) ?: "";
|
||||
$pattern = '/^(.*?)(\(([\d,]+)회\))?(<(.*)>)?(\((재)\))?$/';
|
||||
preg_match($pattern, $programName, $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;
|
||||
$rating = $cells->item(2)->nodeValue == '전체관람' ? 0 : str_replace("세이상","", $cells->item(2)->nodeValue);
|
||||
//ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating
|
||||
$epginfo[] = array($ChannelId, $startTime, $programName, $subprogramName, $desc, $actors, $producers, $category, $episode, $rebroadcast, $rating);
|
||||
usleep(1000);
|
||||
endforeach;
|
||||
else :
|
||||
if($GLOBALS['debug']) printError($ChannelName.CONTENT_ERROR);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
print_r($programs);
|
||||
foreach($programs as $program) :
|
||||
$startTime = $endTime = $programName = $subprogramName = $desc = $actors = $producers = $category = $episode = "";
|
||||
$rebroadcast = False;
|
||||
@ -1017,6 +1054,7 @@ function GetEPGFromIscs($ChannelInfo) {
|
||||
$epginfo[] = array($ChannelId, $startTime, $programName, $subprogramName, $desc, $actors, $producers, $category, $episode, $rebroadcast, $rating);
|
||||
usleep(1000);
|
||||
endforeach;
|
||||
*/
|
||||
endif;
|
||||
} catch(Exception $e) {
|
||||
if($GLOBALS['debug']) printError($e->getMessage());
|
||||
|
81
epg2xml.py
81
epg2xml.py
@ -44,7 +44,7 @@ if not sys.version_info[:2] == (2, 7):
|
||||
sys.exit()
|
||||
|
||||
# Set variable
|
||||
__version__ = '1.2.3p5'
|
||||
__version__ = '1.2.4'
|
||||
debug = False
|
||||
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': '*/*'}
|
||||
@ -140,16 +140,22 @@ def getEpg():
|
||||
GetEPGFromEveryon(ChannelInfo)
|
||||
elif ChannelSource == 'OKSUSU':
|
||||
GetEPGFromOksusu(ChannelInfo)
|
||||
elif ChannelSource == 'CCS':
|
||||
GetEPGFromCcs(ChannelInfo)
|
||||
elif ChannelSource == 'OLLEH':
|
||||
GetEPGFromOlleh(ChannelInfo)
|
||||
elif ChannelSource == 'MBC':
|
||||
GetEPGFromMbc(ChannelInfo)
|
||||
GetEPGFromMbcRadio(ChannelInfo)
|
||||
elif ChannelSource == 'MIL':
|
||||
GetEPGFromMil(ChannelInfo)
|
||||
GetEPGFromMilRadio(ChannelInfo)
|
||||
elif ChannelSource == 'IFM':
|
||||
GetEPGFromIfm(ChannelInfo)
|
||||
GetEPGFromIfmRadio(ChannelInfo)
|
||||
elif ChannelSource == 'KBS':
|
||||
GetEPGFromKbs(ChannelInfo)
|
||||
GetEPGFromKbsRadio(ChannelInfo)
|
||||
elif ChannelSource == 'ARIRANG':
|
||||
GetEPGFromArirang(ChannelInfo)
|
||||
GetEPGFromArirangRadio(ChannelInfo)
|
||||
elif ChannelSource == 'TBS':
|
||||
GetEPGFromTbsRadio(ChannelInfo)
|
||||
print('</tv>')
|
||||
|
||||
# Get EPG data from epg.co.kr
|
||||
@ -390,7 +396,6 @@ def GetEPGFromSKB(ChannelInfo):
|
||||
data = re.sub('<span class="nowon">now on</span>','',data)
|
||||
pattern = '<span>(.*)<\/span>'
|
||||
data = re.sub(pattern, partial(replacement, tag='span'), data)
|
||||
#print(data)
|
||||
strainer = SoupStrainer('div', {'id':'dawn'})
|
||||
soup = BeautifulSoup(data, htmlparser, parse_only=strainer, from_encoding='utf-8')
|
||||
html = soup.find_all('li') if soup.find_all('li') else ''
|
||||
@ -527,40 +532,38 @@ def GetEPGFromIscs(ChannelInfo):
|
||||
ServiceId = ChannelInfo[3]
|
||||
epginfo = []
|
||||
epginfo2 = []
|
||||
url='http://m.iscs.co.kr/sub/02/data.asp'
|
||||
url='https://www.iscs.co.kr/service/sub/ajax_channel_view.asp'
|
||||
for k in range(period):
|
||||
istomorrow = False
|
||||
day = today + datetime.timedelta(days=k)
|
||||
params = {'Exec_Mode': 'view', 'Source_Id': ServiceId, 'Ch_Day': day}
|
||||
params = {'s_idx': ServiceId, 'c_date': day}
|
||||
response = requests.post(url, data=params, headers=ua, timeout=timeout)
|
||||
response.raise_for_status()
|
||||
json_data = response.text
|
||||
try:
|
||||
data = json.loads(json_data, encoding='utf-8')
|
||||
if(data['total'] > 0 ):
|
||||
programs = data['list']
|
||||
for program in programs:
|
||||
if(data['result'] > 0 ):
|
||||
htmls = data['html']
|
||||
strainer = SoupStrainer('tbody')
|
||||
soup = BeautifulSoup(htmls, htmlparser, parse_only=strainer)
|
||||
html = soup.find_all('tr') if soup.find_all('tr') else ''
|
||||
for row in html:
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
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) + ' ' + row.find('td', {'class':'time'}).text
|
||||
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
pattern = '^(.*?)(?:\(([\d,]+)회\))?(?:\((재)\))?$';
|
||||
matches = re.match(pattern, program['Pg_Name'].decode('string_escape').strip())
|
||||
matches = re.match(pattern, row.find('td', {'class':'name'}).text.strip().encode('utf-8'))
|
||||
if not(matches is None) :
|
||||
programName = matches.group(1) if matches.group(1) else ''
|
||||
episode = matches.group(2) if matches.group(2) else ''
|
||||
rebroadcast = True if matches.group(3) else False
|
||||
if program['Rating'].decode('string_escape').strip() == '모든연령':
|
||||
if row.find('span', {'class':'ru5'}).text.strip() == '전체관람':
|
||||
rating = 0
|
||||
else:
|
||||
rating = program['Rating'].replace('세이상','')
|
||||
rating = row.find('span', {'class':'ru5'}).text.strip().replace('세이상','')
|
||||
#ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating
|
||||
epginfo.append([ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating])
|
||||
time.sleep(0.001)
|
||||
@ -652,7 +655,7 @@ def GetEPGFromPooq(ChannelInfo):
|
||||
startTime = program['startDate'] + ' ' + program['startTime']
|
||||
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
programName = program['programTitle'].replace("\r\n", "").encode('utf-8');
|
||||
programName = program['programTitle'].replace("\r\n", "").encode('utf-8')
|
||||
pattern = '^(.*?)(?:([\d,]+)회)?(?:\((재)\))?$'
|
||||
matches = re.match(pattern, programName)
|
||||
if not(matches is None) :
|
||||
@ -769,7 +772,19 @@ def GetEPGFromOksusu(ChannelInfo):
|
||||
if(debug): printError(ChannelName + str(e))
|
||||
else: pass
|
||||
|
||||
# Get EPG data from MBC
|
||||
#Get EPG data from CCS
|
||||
def GetEPGFromCcs(ChannelInfo):
|
||||
pass
|
||||
|
||||
#Get EPG data from OLLEH
|
||||
def GetEPGFromOlleh(ChannelInfo):
|
||||
pass
|
||||
|
||||
#Get EPG data from DLIVE
|
||||
def GetEPGFromDlive(ChannelInfo):
|
||||
pass
|
||||
|
||||
# Get EPG data from MBC Radio
|
||||
def GetEPGFromMbc(ChannelInfo):
|
||||
ChannelId = ChannelInfo[0]
|
||||
ChannelName = ChannelInfo[1]
|
||||
@ -811,8 +826,8 @@ def GetEPGFromMbc(ChannelInfo):
|
||||
if(debug): printError(ChannelName + str(e))
|
||||
else: pass
|
||||
|
||||
# Get EPG data from MIL
|
||||
def GetEPGFromMil(ChannelInfo):
|
||||
# Get EPG data from MIL Radio
|
||||
def GetEPGFromMilRadio(ChannelInfo):
|
||||
ChannelId = ChannelInfo[0]
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
@ -860,8 +875,8 @@ def GetEPGFromMil(ChannelInfo):
|
||||
if(debug): printError(ChannelName + str(e))
|
||||
else: pass
|
||||
|
||||
# Get EPG data from IFM
|
||||
def GetEPGFromIfm(ChannelInfo):
|
||||
# Get EPG data from IFM Radio
|
||||
def GetEPGFromIfmRadio(ChannelInfo):
|
||||
ChannelId = ChannelInfo[0]
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
@ -905,8 +920,8 @@ def GetEPGFromIfm(ChannelInfo):
|
||||
if(debug): printError(ChannelName + str(e))
|
||||
else: pass
|
||||
|
||||
# Get EPG data from KBS
|
||||
def GetEPGFromKbs(ChannelInfo):
|
||||
# Get EPG data from KBS Radio
|
||||
def GetEPGFromKbsRadio(ChannelInfo):
|
||||
ChannelId = ChannelInfo[0]
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
@ -945,8 +960,8 @@ def GetEPGFromKbs(ChannelInfo):
|
||||
if(epginfo) :
|
||||
epgzip(epginfo)
|
||||
|
||||
# Get EPG data from ARIRANG
|
||||
def GetEPGFromArirang(ChannelInfo):
|
||||
# Get EPG data from ARIRANG Radio
|
||||
def GetEPGFromArirangRadio(ChannelInfo):
|
||||
ChannelId = ChannelInfo[0]
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
@ -1002,6 +1017,10 @@ def GetEPGFromArirang(ChannelInfo):
|
||||
if(debug): printError(ChannelName + str(e))
|
||||
else: pass
|
||||
|
||||
#Get EPG data from TBS
|
||||
def GetEPGFromTbs(ChannelInfo):
|
||||
pass
|
||||
|
||||
# Zip epginfo
|
||||
def epgzip(epginfo):
|
||||
epginfo = iter(epginfo)
|
||||
|
Loading…
x
Reference in New Issue
Block a user