urllib를 urllib2로 변경
User Agent 추가 채널 소스 변경
This commit is contained in:
parent
f9fcd760dd
commit
a4c8593ffe
116
epg2xml.py
116
epg2xml.py
@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import httplib
|
import urllib2
|
||||||
import urllib
|
|
||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
from bs4 import BeautifulSoup, SoupStrainer
|
from bs4 import BeautifulSoup, SoupStrainer
|
||||||
@ -16,7 +15,7 @@ import argparse
|
|||||||
reload(sys)
|
reload(sys)
|
||||||
sys.setdefaultencoding('utf-8')
|
sys.setdefaultencoding('utf-8')
|
||||||
|
|
||||||
__version__ = '1.0.5'
|
__version__ = '1.0.6'
|
||||||
|
|
||||||
# Set My Configuration
|
# Set My Configuration
|
||||||
default_icon_url = '' # TV channel icon url (ex : http://www.example.com/Channels)
|
default_icon_url = '' # TV channel icon url (ex : http://www.example.com/Channels)
|
||||||
@ -27,6 +26,7 @@ default_xml_socket = 'xmltv.sock' # External XMLTV 사용시 기본 소켓 이
|
|||||||
|
|
||||||
# Set date
|
# Set date
|
||||||
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': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'accept-language': 'en-US,en;q=0.8,ko;q=0.6'}
|
||||||
|
|
||||||
# Get epg data
|
# Get epg data
|
||||||
def getEpg():
|
def getEpg():
|
||||||
@ -35,27 +35,24 @@ def getEpg():
|
|||||||
SiteEPG = [] #For epg.co.kr
|
SiteEPG = [] #For epg.co.kr
|
||||||
with open(Channelfile) as f: # Read Channel Information file
|
with open(Channelfile) as f: # Read Channel Information file
|
||||||
Channeldata = json.load(f)
|
Channeldata = json.load(f)
|
||||||
for chinfo in Channeldata:
|
|
||||||
if chinfo['Enabled'] == 1 :
|
|
||||||
if MyISP == 'KT' and not( chinfo['KTCh'] is None) :
|
|
||||||
ChannelInfos.append([chinfo['Id'], chinfo['Name'], chinfo['Source'], chinfo['ServiceId']])
|
|
||||||
elif MyISP == 'LG' and not( chinfo['LGCh'] is None) :
|
|
||||||
ChannelInfos.append([chinfo['Id'], chinfo['Name'], chinfo['Source'], chinfo['ServiceId']])
|
|
||||||
elif MyISP == 'SK' and not( chinfo['SKCh'] is None) :
|
|
||||||
ChannelInfos.append([chinfo['Id'], chinfo['Name'], chinfo['Source'], chinfo['ServiceId']])
|
|
||||||
|
|
||||||
# Print Channel information
|
for ChannelInfo in Channeldata: #Get Channel & Print Channel info
|
||||||
for ChannelInfo in ChannelInfos:
|
if ChannelInfo['Enabled'] == 1:
|
||||||
ChannelId = ChannelInfo[0]
|
ChannelId = ChannelInfo['Id']
|
||||||
ChannelName = escape(ChannelInfo[1])
|
ChannelName = escape(ChannelInfo['Name'])
|
||||||
ChannelSource = ChannelInfo[2]
|
ChannelSource = ChannelInfo['Source']
|
||||||
ChannelServiceId = ChannelInfo[3]
|
ChannelServiceId = ChannelInfo['ServiceId']
|
||||||
|
ChannelNumber = ChannelInfo[MyISP+'Ch']
|
||||||
|
if not (ChannelInfo[MyISP+'Ch'] is None):
|
||||||
|
ChannelInfos.append([ChannelId, ChannelName, ChannelSource, ChannelServiceId])
|
||||||
writeXML(' <channel id="%s">' % (ChannelId))
|
writeXML(' <channel id="%s">' % (ChannelId))
|
||||||
writeXML(' <display-name>%s</display-name>' % (ChannelName))
|
writeXML(' <display-name>%s</display-name>' % (ChannelName))
|
||||||
|
writeXML(' <display-name>%s</display-name>' % (ChannelNumber))
|
||||||
if IconUrl:
|
if IconUrl:
|
||||||
writeXML(' <icon src="%s/%s.png" />' % (IconUrl, ChannelId))
|
writeXML(' <icon src="%s/%s.png" />' % (IconUrl, ChannelId))
|
||||||
writeXML(' </channel>')
|
writeXML(' </channel>')
|
||||||
|
|
||||||
|
# Print Program Information
|
||||||
# Print Program Information
|
# Print Program Information
|
||||||
for ChannelInfo in ChannelInfos:
|
for ChannelInfo in ChannelInfos:
|
||||||
ChannelId = ChannelInfo[0]
|
ChannelId = ChannelInfo[0]
|
||||||
@ -86,7 +83,8 @@ def GetEPGFromEPG(ChannelInfos):
|
|||||||
for k in range(period):
|
for k in range(period):
|
||||||
day = today + datetime.timedelta(days=k)
|
day = today + datetime.timedelta(days=k)
|
||||||
url = 'http://schedule.epg.co.kr/php/guide/schedule_day_on.php?%snext=&old_sub_channel_group=110&old_sub_channel_group=110&old_top_channel_group=2&search_sub_category=&search_sub_channel_group=110&search_top_category=&search_top_channel_group=2&selectday=%s&selectday2=%s&weekchannel=&ymd=%s' % (churl, day, day, day)
|
url = 'http://schedule.epg.co.kr/php/guide/schedule_day_on.php?%snext=&old_sub_channel_group=110&old_sub_channel_group=110&old_top_channel_group=2&search_sub_category=&search_sub_channel_group=110&search_top_category=&search_top_channel_group=2&selectday=%s&selectday2=%s&weekchannel=&ymd=%s' % (churl, day, day, day)
|
||||||
u = urllib.urlopen(url).read()
|
request = urllib2.Request(url,headers=ua)
|
||||||
|
u = urllib2.urlopen(request).read()
|
||||||
data = unicode(u, 'euc-kr', 'ignore').encode('utf-8', 'ignore')
|
data = unicode(u, 'euc-kr', 'ignore').encode('utf-8', 'ignore')
|
||||||
strainer = SoupStrainer('table', {"bgcolor" : "#D6D6D6"})
|
strainer = SoupStrainer('table', {"bgcolor" : "#D6D6D6"})
|
||||||
soup = BeautifulSoup(data, 'lxml', parse_only=strainer, from_encoding='utf-8')
|
soup = BeautifulSoup(data, 'lxml', parse_only=strainer, from_encoding='utf-8')
|
||||||
@ -105,20 +103,24 @@ def GetEPGFromEPG(ChannelInfos):
|
|||||||
endTime = str(today.year) + '/' + endTime
|
endTime = str(today.year) + '/' + endTime
|
||||||
endTime = datetime.datetime.strptime(endTime, '%Y/%m/%d %p %I:%M')
|
endTime = datetime.datetime.strptime(endTime, '%Y/%m/%d %p %I:%M')
|
||||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||||
|
desc = ''
|
||||||
category = epgdata[5].split('-')[0].strip()
|
category = epgdata[5].split('-')[0].strip()
|
||||||
actors = epgdata[6]
|
actors = epgdata[6]
|
||||||
producers = epgdata[7]
|
producers = epgdata[7]
|
||||||
|
category = epgdata[5].split('-')[0].strip()
|
||||||
matches = re.match('^(.*?)\s*(<(.*)>)?(\(([\d,]+)회\))?$', programName)
|
matches = re.match('^(.*?)\s*(<(.*)>)?(\(([\d,]+)회\))?$', programName)
|
||||||
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 ''
|
||||||
episode = matches.group(5) if matches.group(5) else ''
|
episode = matches.group(5) if matches.group(5) else ''
|
||||||
|
rebroadcast = False
|
||||||
rating = 0
|
rating = 0
|
||||||
for image in td.findAll('img'):
|
for image in td.findAll('img'):
|
||||||
if 'rebroadcast' in image.get('src') : programName = programName + ' (재방송)'
|
if 'rebroadcast' in image.get('src') :
|
||||||
|
programName = programName + ' (재방송)'
|
||||||
|
rebroadcast = True
|
||||||
if 'grade' in image.get('src') : rating = int(image.get('src')[22:].replace('.gif',''))
|
if 'grade' in image.get('src') : rating = int(image.get('src')[22:].replace('.gif',''))
|
||||||
desc = ''
|
programdata = {'channelId':channelId, 'startTime':startTime, 'endTime':endTime, 'programName':programName, 'subprogramName':subprogramName, 'desc':desc, 'actors':actors, 'producers':producers, 'category':category, 'episode':episode, 'rebroadcast':rebroadcast, 'rating':rating}
|
||||||
programdata = {'channelId':channelId, 'startTime':startTime, 'endTime':endTime, 'programName':programName, 'subprogramName':subprogramName, 'desc':desc, 'actors':actors, 'producers':producers, 'category':category, 'episode':episode, 'rating':rating}
|
|
||||||
writeProgram(programdata)
|
writeProgram(programdata)
|
||||||
|
|
||||||
# Get EPG data from KT
|
# Get EPG data from KT
|
||||||
@ -129,7 +131,8 @@ def GetEPGFromKT(ChannelInfo):
|
|||||||
for k in range(period):
|
for k in range(period):
|
||||||
day = today + datetime.timedelta(days=k)
|
day = today + datetime.timedelta(days=k)
|
||||||
url = 'http://tv.olleh.com/renewal_sub/liveTv/pop_schedule_week.asp?ch_name=&ch_no=%s&nowdate=%s&seldate=%s&tab_no=1' % (ServiceId, day, day)
|
url = 'http://tv.olleh.com/renewal_sub/liveTv/pop_schedule_week.asp?ch_name=&ch_no=%s&nowdate=%s&seldate=%s&tab_no=1' % (ServiceId, day, day)
|
||||||
u = urllib.urlopen(url).read()
|
request = urllib2.Request(url,headers=ua)
|
||||||
|
u = urllib2.urlopen(request).read()
|
||||||
data = unicode(u, 'euc-kr', 'ignore').encode('utf-8', 'ignore')
|
data = unicode(u, 'euc-kr', 'ignore').encode('utf-8', 'ignore')
|
||||||
strainer = SoupStrainer('table', {'id':'pop_day'})
|
strainer = SoupStrainer('table', {'id':'pop_day'})
|
||||||
soup = BeautifulSoup(data, 'lxml', parse_only=strainer, from_encoding='utf-8')
|
soup = BeautifulSoup(data, 'lxml', parse_only=strainer, from_encoding='utf-8')
|
||||||
@ -149,15 +152,18 @@ def GetEPGFromKT(ChannelInfo):
|
|||||||
endTime = datetime.datetime.strptime(epg2[1], '%Y-%m-%d %H:%M')
|
endTime = datetime.datetime.strptime(epg2[1], '%Y-%m-%d %H:%M')
|
||||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||||
category = epg1[2]
|
category = epg1[2]
|
||||||
rating = 0
|
|
||||||
matches = re.match('(\d+)', epg1[3])
|
|
||||||
if not(matches is None): rating = int(matches.group())
|
|
||||||
desc = ''
|
desc = ''
|
||||||
actors = ''
|
actors = ''
|
||||||
producers = ''
|
producers = ''
|
||||||
episode = ''
|
episode = ''
|
||||||
programdata = {'channelId':channelId, 'startTime':startTime, 'endTime':endTime, 'programName':programName, 'subprogramName':subprogramName, 'desc':desc, 'actors':actors, 'producers':producers, 'category':category, 'episode':episode, 'rating':rating}
|
rebroadcast = False
|
||||||
|
rating = 0
|
||||||
|
matches = re.match('(\d+)', epg1[3])
|
||||||
|
if not(matches is None): rating = int(matches.group())
|
||||||
|
programdata = {'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)
|
writeProgram(programdata)
|
||||||
|
|
||||||
|
|
||||||
# Get EPG data from LG
|
# Get EPG data from LG
|
||||||
def GetEPGFromLG(ChannelInfo):
|
def GetEPGFromLG(ChannelInfo):
|
||||||
channelId = ChannelInfo[0]
|
channelId = ChannelInfo[0]
|
||||||
@ -166,7 +172,8 @@ def GetEPGFromLG(ChannelInfo):
|
|||||||
for k in range(period):
|
for k in range(period):
|
||||||
day = today + datetime.timedelta(days=k)
|
day = today + datetime.timedelta(days=k)
|
||||||
url = 'http://www.uplus.co.kr/css/chgi/chgi/RetrieveTvSchedule.hpi?chnlCd=%s&evntCmpYmd=%s' % (ServiceId, day.strftime('%Y%m%d'))
|
url = 'http://www.uplus.co.kr/css/chgi/chgi/RetrieveTvSchedule.hpi?chnlCd=%s&evntCmpYmd=%s' % (ServiceId, day.strftime('%Y%m%d'))
|
||||||
u = urllib.urlopen(url).read()
|
request = urllib2.Request(url,headers=ua)
|
||||||
|
u = urllib2.urlopen(request).read()
|
||||||
data = unicode(u, 'euc-kr', 'ignore').encode('utf-8', 'ignore')
|
data = unicode(u, 'euc-kr', 'ignore').encode('utf-8', 'ignore')
|
||||||
strainer = SoupStrainer('table')
|
strainer = SoupStrainer('table')
|
||||||
soup = BeautifulSoup(data, 'lxml', parse_only=strainer, from_encoding='utf-8')
|
soup = BeautifulSoup(data, 'lxml', parse_only=strainer, from_encoding='utf-8')
|
||||||
@ -187,47 +194,53 @@ def GetEPGFromLG(ChannelInfo):
|
|||||||
endTime = datetime.datetime.strptime(epg2[1], "%Y-%m-%d %H:%M")
|
endTime = datetime.datetime.strptime(epg2[1], "%Y-%m-%d %H:%M")
|
||||||
endTime = endTime.strftime("%Y%m%d%H%M%S")
|
endTime = endTime.strftime("%Y%m%d%H%M%S")
|
||||||
category = epg1[2]
|
category = epg1[2]
|
||||||
rating = 0
|
|
||||||
matches = re.match('(\d+)세이상 관람가', epg1[3].encode('utf-8'))
|
|
||||||
if not(matches is None): rating = int(matches.group(1))
|
|
||||||
desc = ''
|
desc = ''
|
||||||
actors = ''
|
actors = ''
|
||||||
producers = ''
|
producers = ''
|
||||||
programdata = {'channelId':channelId, 'startTime':startTime, 'endTime':endTime, 'programName':programName, 'subprogramName':subprogramName, 'desc':desc, 'actors':actors, 'producers':producers, 'category':category, 'episode':episode, 'rating':rating}
|
category = epg1[2]
|
||||||
|
rebroadcast = False
|
||||||
|
category = epg1[2]
|
||||||
|
rating = 0
|
||||||
|
matches = re.match('(\d+)세이상 관람가', epg1[3].encode('utf-8'))
|
||||||
|
if not(matches is None): rating = int(matches.group(1))
|
||||||
|
programdata = {'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)
|
writeProgram(programdata)
|
||||||
|
|
||||||
|
|
||||||
# Get EPG data from SK
|
# Get EPG data from SK
|
||||||
def GetEPGFromSK(ChannelInfo):
|
def GetEPGFromSK(ChannelInfo):
|
||||||
channelId = ChannelInfo[0]
|
channelId = ChannelInfo[0]
|
||||||
ServiceId = ChannelInfo[3]
|
ServiceId = ChannelInfo[3]
|
||||||
lastday = today + datetime.timedelta(days=period-1)
|
lastday = today + datetime.timedelta(days=period-1)
|
||||||
url = 'http://m.btvplus.co.kr/Common/Inc/IFGetData.asp?variable=IF_LIVECHART_DETAIL&pcode=|^|start_time=%s00|^|end_time=%s24|^|svc_id=%s' % (today.strftime("%Y%m%d"), lastday.strftime("%Y%m%d"), ServiceId)
|
url = 'http://m.btvplus.co.kr/Common/Inc/IFGetData.asp?variable=IF_LIVECHART_DETAIL&pcode=|^|start_time=%s00|^|end_time=%s24|^|svc_id=%s' % (today.strftime("%Y%m%d"), lastday.strftime("%Y%m%d"), ServiceId)
|
||||||
u = urllib.urlopen(url).read()
|
request = urllib2.Request(url,headers=ua)
|
||||||
|
u = urllib2.urlopen(request).read()
|
||||||
data = json.loads(u, encoding='utf-8')
|
data = json.loads(u, encoding='utf-8')
|
||||||
programs = data['channel']['programs']
|
programs = data['channel']['programs']
|
||||||
for program in programs:
|
for program in programs:
|
||||||
programName = ''
|
programName = ''
|
||||||
subprogramName = ''
|
subprogramName = ''
|
||||||
episode = ''
|
episode = ''
|
||||||
rebroadcast = ''
|
rebroadcast = False
|
||||||
matches = re.match('^(.*?)(?:\s*[\(<]([\d,회]+)[\)>])?(?:\s*<([^<]*?)>)?(\((재)\))?$', program['programName'].replace('...', '>').encode('utf-8'))
|
matches = re.match('^(.*?)(?:\s*[\(<]([\d,회]+)[\)>])?(?:\s*<([^<]*?)>)?(\((재)\))?$', 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 ''
|
||||||
episode = matches.group(2).replace('회', '') if matches.group(2) else ''
|
episode = matches.group(2).replace('회', '') if matches.group(2) else ''
|
||||||
rebroadcast = 'Y' if matches.group(5) else 'N'
|
rebroadcast = True if matches.group(5) else False
|
||||||
if rebroadcast == 'Y': programName = programName + ' (재방송)'
|
if rebroadcast == True: programName = programName + ' (재방송)'
|
||||||
actors = program['actorName'].replace('...','').strip(', ') if program['actorName'] else ''
|
actors = program['actorName'].replace('...','').strip(', ') if program['actorName'] else ''
|
||||||
producers = program['directorName'].replace('...','').strip(', ') if program['directorName'] else ''
|
producers = program['directorName'].replace('...','').strip(', ') if program['directorName'] else ''
|
||||||
startTime = datetime.datetime.fromtimestamp(int(program['startTime'])/1000)
|
startTime = datetime.datetime.fromtimestamp(int(program['startTime'])/1000)
|
||||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||||
endTime = datetime.datetime.fromtimestamp(int(program['endTime'])/1000)
|
endTime = datetime.datetime.fromtimestamp(int(program['endTime'])/1000)
|
||||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||||
|
desc = program['synopsis'] if program['synopsis'] else ''
|
||||||
category = program['mainGenreName']
|
category = program['mainGenreName']
|
||||||
rating = int(program['ratingCd']) if program['programName'] else 0
|
rating = int(program['ratingCd']) if program['programName'] else 0
|
||||||
desc = ''
|
desc = ''
|
||||||
if program['synopsis'] : desc = program['synopsis']
|
if program['synopsis'] : desc = program['synopsis']
|
||||||
programdata = {'channelId':channelId, 'startTime':startTime, 'endTime':endTime, 'programName':programName, 'subprogramName':subprogramName, 'desc':desc, 'actors':actors, 'producers':producers, 'category':category, 'episode':episode, 'rating':rating}
|
programdata = {'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)
|
writeProgram(programdata)
|
||||||
|
|
||||||
# Get EPG data from SKY
|
# Get EPG data from SKY
|
||||||
@ -237,31 +250,32 @@ def GetEPGFromSKY(ChannelInfo):
|
|||||||
for k in range(period):
|
for k in range(period):
|
||||||
day = today + datetime.timedelta(days=k)
|
day = today + datetime.timedelta(days=k)
|
||||||
url = 'http://www.skylife.co.kr/channel/epg/channelScheduleList.do?area=in&inFd_channel_id=%s&inairdate=%s&indate_type=now' % (ServiceId, day)
|
url = 'http://www.skylife.co.kr/channel/epg/channelScheduleList.do?area=in&inFd_channel_id=%s&inairdate=%s&indate_type=now' % (ServiceId, day)
|
||||||
u = urllib.urlopen(url).read()
|
request = urllib2.Request(url,headers=ua)
|
||||||
|
u = urllib2.urlopen(request).read()
|
||||||
data = json.loads(u, encoding='utf-8')
|
data = json.loads(u, encoding='utf-8')
|
||||||
programs = data['scheduleListIn']
|
programs = data['scheduleListIn']
|
||||||
for program in {v['starttime']:v for v in programs}.values():
|
for program in {v['starttime']:v for v in programs}.values():
|
||||||
programName = unescape(program['program_name']).replace('lt;','<').replace('gt;','>').replace('amp;','&') if program['program_name'] else ''
|
programName = unescape(program['program_name']).replace('lt;','<').replace('gt;','>').replace('amp;','&') if program['program_name'] else ''
|
||||||
subprogramName = unescape(program['program_subname']).replace('lt;','<').replace('gt;','>').replace('amp;','&') if program['program_subname'] else ''
|
subprogramName = unescape(program['program_subname']).replace('lt;','<').replace('gt;','>').replace('amp;','&') if program['program_subname'] else ''
|
||||||
rebroadcast = program['rebroad'] if program['rebroad'] else ''
|
|
||||||
if rebroadcast == 'Y': programName = programName + ' (재방송)'
|
|
||||||
actors = program['cast'].replace('...','').strip(', ') if program['cast'] else ''
|
actors = program['cast'].replace('...','').strip(', ') if program['cast'] else ''
|
||||||
producers = program['dirt'].replace('...','').strip(', ') if program['dirt'] else ''
|
producers = program['dirt'].replace('...','').strip(', ') if program['dirt'] else ''
|
||||||
startTime = program['starttime']
|
startTime = program['starttime']
|
||||||
endTime = program['endtime']
|
endTime = program['endtime']
|
||||||
category = program['program_category1']
|
|
||||||
rating = int(program['grade']) if program['grade'] else ''
|
|
||||||
episode = program['episode_id'] if program['episode_id'] else ''
|
|
||||||
if episode : episode = int(episode)
|
|
||||||
description = unescape(program['description']).replace('lt;','<').replace('gt;','>').replace('amp;','&') if program['description'] else ''
|
description = unescape(program['description']).replace('lt;','<').replace('gt;','>').replace('amp;','&') if program['description'] else ''
|
||||||
if description: description = unescape(description).replace('lt;','<').replace('gt;','>').replace('amp;','&')
|
if description: description = unescape(description).replace('lt;','<').replace('gt;','>').replace('amp;','&')
|
||||||
summary = unescape(program['summary']).replace('lt;','<').replace('gt;','>').replace('amp;','&') if program['summary'] else ''
|
summary = unescape(program['summary']).replace('lt;','<').replace('gt;','>').replace('amp;','&') if program['summary'] else ''
|
||||||
desc = ''
|
desc = description if description else ''
|
||||||
if description: desc = description
|
|
||||||
if summary : desc = desc + '\n' + summary
|
if summary : desc = desc + '\n' + summary
|
||||||
programdata = {'channelId':channelId, 'startTime':startTime, 'endTime':endTime, 'programName':programName, 'subprogramName':subprogramName, 'desc':desc, 'actors':actors, 'producers':producers, 'category':category, 'episode':episode, 'rating':rating}
|
category = program['program_category1']
|
||||||
|
episode = program['episode_id'] if program['episode_id'] else ''
|
||||||
|
if episode : episode = int(episode)
|
||||||
|
rebroadcast = True if program['rebroad']== 'Y' else False
|
||||||
|
if rebroadcast == True: programName = programName + ' (재방송)'
|
||||||
|
rating = int(program['grade']) if program['grade'] else 0
|
||||||
|
programdata = {'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)
|
writeProgram(programdata)
|
||||||
|
|
||||||
|
|
||||||
# Write Program
|
# Write Program
|
||||||
def writeProgram(programdata):
|
def writeProgram(programdata):
|
||||||
channelId = programdata['channelId']
|
channelId = programdata['channelId']
|
||||||
@ -273,11 +287,11 @@ def writeProgram(programdata):
|
|||||||
producers = escape(programdata['producers'])
|
producers = escape(programdata['producers'])
|
||||||
category = escape(programdata['category'])
|
category = escape(programdata['category'])
|
||||||
episode = programdata['episode']
|
episode = programdata['episode']
|
||||||
|
rebroadcast = programdata['rebroadcast']
|
||||||
if programdata['rating'] == 0 :
|
if programdata['rating'] == 0 :
|
||||||
rating = '전체 관람가'
|
rating = '전체 관람가'
|
||||||
else :
|
else :
|
||||||
rating = '%s세 이상 관람가' % (programdata['rating'])
|
rating = '%s세 이상 관람가' % (programdata['rating'])
|
||||||
|
|
||||||
desc = programName
|
desc = programName
|
||||||
if subprogramName : desc = desc + '\n부제 : ' + subprogramName
|
if subprogramName : desc = desc + '\n부제 : ' + subprogramName
|
||||||
if episode : desc = desc + '\n회차 : ' + str(episode) + '회'
|
if episode : desc = desc + '\n회차 : ' + str(episode) + '회'
|
||||||
@ -286,6 +300,7 @@ def writeProgram(programdata):
|
|||||||
if producers : desc = desc + '\n제작 : ' + producers
|
if producers : desc = desc + '\n제작 : ' + producers
|
||||||
desc = desc + '\n등급 : ' + rating
|
desc = desc + '\n등급 : ' + rating
|
||||||
if programdata['desc'] : desc = desc + '\n' + escape(programdata['desc'])
|
if programdata['desc'] : desc = desc + '\n' + escape(programdata['desc'])
|
||||||
|
rebroadcast = programdata['rebroadcast']
|
||||||
contentTypeDict={'교양':'Arts / Culture (without music)', '만화':'Cartoons / Puppets', '교육':'Education / Science / Factual topics', '취미':'Leisure hobbies', '드라마':'Movie / Drama', '영화':'Movie / Drama', '음악':'Music / Ballet / Dance', '뉴스':'News / Current affairs', '다큐':'Documentary', '시사/다큐':'Documentary', '연예':'Show / Game show', '스포츠':'Sports', '홈쇼핑':'Advertisement / Shopping'}
|
contentTypeDict={'교양':'Arts / Culture (without music)', '만화':'Cartoons / Puppets', '교육':'Education / Science / Factual topics', '취미':'Leisure hobbies', '드라마':'Movie / Drama', '영화':'Movie / Drama', '음악':'Music / Ballet / Dance', '뉴스':'News / Current affairs', '다큐':'Documentary', '시사/다큐':'Documentary', '연예':'Show / Game show', '스포츠':'Sports', '홈쇼핑':'Advertisement / Shopping'}
|
||||||
contentType = ''
|
contentType = ''
|
||||||
for key, value in contentTypeDict.iteritems():
|
for key, value in contentTypeDict.iteritems():
|
||||||
@ -307,14 +322,15 @@ def writeProgram(programdata):
|
|||||||
print ' </credits>'
|
print ' </credits>'
|
||||||
if category: print ' <category lang="kr">%s</category>' % (category)
|
if category: print ' <category lang="kr">%s</category>' % (category)
|
||||||
if contentType: print ' <category lang="en">%s</category>' % (contentType)
|
if contentType: print ' <category lang="en">%s</category>' % (contentType)
|
||||||
if episode:
|
if episode: print ' <episode-num system="onscreen">%s</episode-num>' % (episode)
|
||||||
print ' <episode-num system="onscreen">%s</episode-num>' % (episode)
|
if rebroadcast: print ' <previously-shown />'
|
||||||
|
|
||||||
if rating:
|
if rating:
|
||||||
print ' <rating system="KMRB">'
|
print ' <rating system="KMRB">'
|
||||||
print ' <value>%s</value>' % (rating)
|
print ' <value>%s</value>' % (rating)
|
||||||
print ' </rating>'
|
print ' </rating>'
|
||||||
print ' </programme>'
|
print ' </programme>'
|
||||||
# Write XML
|
|
||||||
def writeXML(data):
|
def writeXML(data):
|
||||||
print data
|
print data
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user