Merge pull request #88 from wonipapa/devel

Devel
This commit is contained in:
wonipapa 2018-03-02 18:03:11 +09:00 committed by GitHub
commit 84bc5a16d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 13 deletions

View File

@ -118,8 +118,11 @@ https://github.com/wonipapa/epg2xml/wiki
https://github.com/wonipapa/epg2xml/wiki/FAQ
## 변경사항
### Version 1.2.5
- SKB 함수 수정
### Version 1.2.4
- ISCS 함수 수정
- SKB 함수 수정(p1)
### Version 1.2.3
- PHP 버전통합
- PYTHON 버전 html Parser 변수 추가(libxml지원안하는 기기 편의 지원)

View File

@ -3,7 +3,7 @@
@date_default_timezone_set('Asia/Seoul');
error_reporting(E_ALL ^ E_NOTICE);
@set_time_limit(0);
define("VERSION", "1.2.4p1");
define("VERSION", "1.2.5");
$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;
@ -752,30 +752,31 @@ function GetEPGFromSKB($ChannelInfo) {
printError($ChannelName.HTTP_ERROR);
else :
$response = str_replace('charset="euc-kr"', 'charset="utf-8"', $response);
$response = mb_convert_encoding($response, "UTF-8", "EUC-KR");
$response = preg_replace('/<!--(.*?)-->/is', '', $response);
$response = preg_replace('/<span><\/span>/is', '', $response);
//$response = preg_replace('/<strong class="hide">프로그램 안내<\/strong>/is', '', $response);
//$response = preg_replace('/<span.*\\/span>/is', '', $response);
$pattern = '/<span>(.*)<\/span>/';
$response = preg_replace_callback($pattern, function($matches) { return '<span class="title">'.htmlspecialchars($matches[1], ENT_NOQUOTES).'</span>';}, $response);
$dom = new DomDocument;
libxml_use_internal_errors(True);
if($dom->loadHTML('<?xml encoding="utf-8" ?>'.$response)):
$xpath = new DomXPath($dom);
$query = "//span[@class='caption' or @class='explan' or @class='fullHD' or @class='UHD' or @class='nowon']";
$query = "//span[@class='caption' or @class='explan' or @class='fullHD' or @class='UHD' or @class='nowon' or @class='flag_box']";
$spans = $xpath->query($query);
foreach($spans as $span) :
$span->parentNode->removeChild( $span);
endforeach;
$query = "//div[@id='dawn']/ul/li";
$query = "//div[@id='uiScheduleTabContent']/div/ol/li";
$rows = $xpath->query($query);
foreach($rows as $row) :
$startTime = $endTime = $programName = $subprogramName = $desc = $actors = $producers = $category = $episode = "";
$rebroadcast = False;
$rating = 0;
$cells = $row->getElementsByTagName('span');
$cells = $row->getElementsByTagName('p');
$startTime = $cells->item(0)->nodeValue ?: "";
$startTime = date("YmdHis", strtotime($day." ".$startTime));
$programName = trim($cells->item(2)->nodeValue) ?: "";
$programName = trim($cells->item(1)->nodeValue) ?: "";
$pattern = '/^(.*?)(\(([\d,]+)회\))?(<(.*)>)?(\((재)\))?$/';
preg_match($pattern, $programName, $matches);
if ($matches != NULL) :
@ -969,7 +970,7 @@ function GetEPGFromIscs($ChannelInfo) {
foreach(range(1, $GLOBALS['period']) as $k) :
$istomorrow = False;
$url = "https://www.iscs.co.kr/service/sub/ajax_channel_view.asp";
$day = date("Y-m-d", strtotime("+".($k - 2)." days"));
$day = date("Y-m-d", strtotime("+".($k - 1)." days"));
$params = array(
's_idx' => $ServiceId,
'c_date' => $day

View File

@ -44,7 +44,7 @@ if not sys.version_info[:2] == (2, 7):
sys.exit()
# Set variable
__version__ = '1.2.4p2'
__version__ = '1.2.5'
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': '*/*'}
@ -388,20 +388,22 @@ def GetEPGFromSKB(ChannelInfo):
data = re.sub('<span class="fullHD">Full HD</span>','',data)
data = re.sub('<span class="UHD">UHD</span>','',data)
data = re.sub('<span class="nowon">now on</span>','',data)
data = re.sub('<span class="flag_box">','',data)
data = re.sub('<strong class="hide">프로그램 안내</strong>', '',data)
pattern = '<span>(.*)<\/span>'
data = re.sub(pattern, partial(replacement, tag='span'), data)
strainer = SoupStrainer('div', {'id':'dawn'})
strainer = SoupStrainer('div', {'id':'uiScheduleTabContent'})
soup = BeautifulSoup(data, htmlparser, parse_only=strainer, from_encoding='utf-8')
html = soup.find_all('li') if soup.find_all('li') else ''
html = soup.find_all('li',{'class':'list'}) if soup.find_all('li') else ''
if(html):
for row in html:
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
rebroadcast = False
rating = 0
startTime = str(day) + ' ' + row.find('span', {'class':'time'}).text
startTime = str(day) + ' ' + row.find('p', {'class':'time'}).text
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %H:%M')
startTime = startTime.strftime('%Y%m%d%H%M%S')
cell = row.find('span', {'class':'title'})
cell = row.find('p', {'class':'cont'})
if(cell):
cell = cell.text.decode('string_escape').strip()
pattern = "^(.*?)(\(([\d,]+)회\))?(<(.*)>)?(\((재)\))?$"
@ -461,7 +463,7 @@ def GetEPGFromSKY(ChannelInfo):
desc = description if description else ''
if desc:
if summary : desc = desc + '\n' + summary
else:
else:
desc = summary
category = program['program_category1']
episode = program['episode_id'] if program['episode_id'] else ''