iscs, hcn, pooq 함수 추가
함수 최적화
This commit is contained in:
parent
94cc149103
commit
11b0bea1d9
404
epg2xml.py
404
epg2xml.py
@ -113,32 +113,30 @@ def getEpg():
|
||||
if(debug) : printLog(ChannelName + ' 채널 EPG 데이터를 가져오고 있습니다')
|
||||
if ChannelSource == 'EPG':
|
||||
GetEPGFromEPG(ChannelInfo)
|
||||
#elif ChannelSource == 'KT':
|
||||
# GetEPGFromKT(ChannelInfo)
|
||||
#elif ChannelSource == 'LG':
|
||||
# GetEPGFromLG(ChannelInfo)
|
||||
#elif ChannelSource == 'SK':
|
||||
# GetEPGFromSK(ChannelInfo)
|
||||
#elif ChannelSource == 'SKB':
|
||||
# GetEPGFromSKB(ChannelInfo)
|
||||
#elif ChannelSource == 'SKY':
|
||||
# GetEPGFromSKY(ChannelInfo)
|
||||
#elif ChannelSource == 'NAVER':
|
||||
# GetEPGFromNaver(ChannelInfo)
|
||||
#elif ChannelSource == 'TBROAD':
|
||||
# GetEPGFromTbroad(ChannelInfo)
|
||||
#elif ChannelSource == 'ISCS':
|
||||
# GetEPGFromIscs(ChannelInfo)
|
||||
#elif ChannelSource == 'HCN':
|
||||
# GetEPGFromHcn(ChannelInfo)
|
||||
elif ChannelSource == 'KT':
|
||||
GetEPGFromKT(ChannelInfo)
|
||||
elif ChannelSource == 'LG':
|
||||
GetEPGFromLG(ChannelInfo)
|
||||
elif ChannelSource == 'SK':
|
||||
GetEPGFromSK(ChannelInfo)
|
||||
elif ChannelSource == 'SKB':
|
||||
GetEPGFromSKB(ChannelInfo)
|
||||
elif ChannelSource == 'SKY':
|
||||
GetEPGFromSKY(ChannelInfo)
|
||||
elif ChannelSource == 'NAVER':
|
||||
GetEPGFromNaver(ChannelInfo)
|
||||
elif ChannelSource == 'ISCS':
|
||||
GetEPGFromIscs(ChannelInfo)
|
||||
elif ChannelSource == 'HCN':
|
||||
GetEPGFromHcn(ChannelInfo)
|
||||
elif ChannelSource == 'POOQ':
|
||||
GetEPGFromPooq(ChannelInfo)
|
||||
#elif ChannelSource == 'MBC':
|
||||
# GetEPGFromMbc(ChannelInfo)
|
||||
#elif ChannelSource == 'MIL':
|
||||
# GetEPGFromMil(ChannelInfo)
|
||||
#elif ChannelSource == 'IFM':
|
||||
# GetEPGFromIfm(ChannelInfo)
|
||||
elif ChannelSource == 'MBC':
|
||||
GetEPGFromMbc(ChannelInfo)
|
||||
elif ChannelSource == 'MIL':
|
||||
GetEPGFromMil(ChannelInfo)
|
||||
elif ChannelSource == 'IFM':
|
||||
GetEPGFromIfm(ChannelInfo)
|
||||
elif ChannelSource == 'KBS':
|
||||
GetEPGFromKbs(ChannelInfo)
|
||||
print('</tv>')
|
||||
@ -150,6 +148,9 @@ def GetEPGFromEPG(ChannelInfo):
|
||||
ServiceId = ChannelInfo[3]
|
||||
url = 'http://211.43.210.10:88/epg-cgi/extern/cnm_guide_type_v070530.php'
|
||||
epginfo = []
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
for k in range(period):
|
||||
day = today + datetime.timedelta(days=k)
|
||||
params = {'beforegroup':'100', 'checkchannel[]':ServiceId, 'select_group':'100', 'start_date':day.strftime('%Y%m%d')}
|
||||
@ -173,38 +174,26 @@ def GetEPGFromEPG(ChannelInfo):
|
||||
hour = 'AM ' + str(hour)
|
||||
thisday = day + datetime.timedelta(days=1)
|
||||
for celldata in cell.parent.find_all('tr'):
|
||||
pattern = "<tr>.*\[(.*)\]<\/td>\s.*\">(.*?)\s*(<(.*)>)?\s*(\(재\))?\s*(\(([\d,]+)회\))?(<img.*?)?(<\/a>)?\s*<\/td><\/tr>"
|
||||
pattern = "<tr>.*\[(.*)\]<\/td>\s.*\">(.*?)\s*(<(.*)>)?\s*(\(재\))?\s*(\(([\d,]+)회\)?)?(<img.*?)?(<\/a>)?\s*<\/td><\/tr>"
|
||||
matches = re.match(pattern, str(celldata))
|
||||
if not (matches is None):
|
||||
minute = matches.group(1) if matches.group(1) else ''
|
||||
startTime = str(thisday) + ' ' + hour + ':' + minute
|
||||
startTime = str(thisday) + ' ' + hour + ':' + minute[-2:]
|
||||
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %p %I:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
image = matches.group(8) if matches.group(8) else ''
|
||||
grade = re.match('.*schedule_([\d,]+)?.*',image)
|
||||
if not (grade is None): rating = int(grade.group(1))
|
||||
else : rating = 0
|
||||
programName = matches.group(2).strip() if matches.group(2) else ''
|
||||
subprogramName = matches.group(4).strip() if matches.group(4) else ''
|
||||
#programName, startTime, rating, subprogramName, rebroadcast, episode
|
||||
epginfo.append([programName, startTime, rating, subprogramName, matches.group(5), matches.group(7)])
|
||||
rebroadcast = True if matches.group(5) else False;
|
||||
episode = matches.group(7) if matches.group(7) else ''
|
||||
#ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating
|
||||
epginfo.append([ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating])
|
||||
except (requests.exceptions.RequestException) as e:
|
||||
if(debug): printError(ChannelName + str(e))
|
||||
else: pass
|
||||
for epg1, epg2 in zip(epginfo, epginfo[1:]):
|
||||
programName = epg1[0] if epg1[0] else ''
|
||||
subprogramName = epg1[3] if epg1[3] else ''
|
||||
startTime = epg1[1] if epg1[1] else ''
|
||||
endTime = epg2[1] if epg2[1] else ''
|
||||
desc = ''
|
||||
actors = ''
|
||||
producers = ''
|
||||
category = ''
|
||||
rebroadcast = True if epg1[4] else False
|
||||
episode = epg1[5] if epg1[5] else ''
|
||||
rating = int(epg1[2]) if epg1[2] 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)
|
||||
epgzip(epginfo)
|
||||
|
||||
# Get EPG data from KT
|
||||
def GetEPGFromKT(ChannelInfo):
|
||||
@ -213,6 +202,9 @@ def GetEPGFromKT(ChannelInfo):
|
||||
ServiceId = ChannelInfo[3]
|
||||
url = 'http://tv.olleh.com/renewal_sub/liveTv/pop_schedule_week.asp'
|
||||
epginfo = []
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
for k in range(period):
|
||||
day = today + datetime.timedelta(days=k)
|
||||
params = {'ch_name':'', 'ch_no':ServiceId, 'nowdate':day.strftime('%Y%m%d'), 'seldatie':day.strftime('%Y%m%d'), 'tab_no':'1'}
|
||||
@ -227,36 +219,26 @@ def GetEPGFromKT(ChannelInfo):
|
||||
if(html):
|
||||
for row in html:
|
||||
for cell in [row.find_all('td')]:
|
||||
epginfo.append([cell[1].text, str(day) + ' ' + cell[0].text, cell[4].text, cell[2].text])
|
||||
startTime = str(day) + ' ' + cell[0].text
|
||||
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
pattern = '^(.*?)( <(.*)>)?$'
|
||||
matches = re.match(pattern, cell[1].text.decode('string_escape'))
|
||||
if not (matches is None):
|
||||
programName = matches.group(1) if matches.group(1) else ''
|
||||
subprogramName = matches.group(3) if matches.group(3) else ''
|
||||
category = cell[4].text
|
||||
matches = re.match('(\d+)', cell[2].text)
|
||||
if not(matches is None): rating = int(matches.group())
|
||||
#ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating
|
||||
epginfo.append([ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating])
|
||||
epgzip(epginfo)
|
||||
else:
|
||||
if(debug): printError(ChannelName + CONTENT_ERROR)
|
||||
else: pass
|
||||
except (requests.exceptions.RequestException) as e:
|
||||
if(debug): printError(ChannelName + str(e))
|
||||
else: pass
|
||||
for epg1, epg2 in zip(epginfo, epginfo[1:]):
|
||||
programName = ''
|
||||
subprogrmaName = ''
|
||||
pattern = '^(.*?)( <(.*)>)?$'
|
||||
matches = re.match(pattern, epg1[0].decode('string_escape'))
|
||||
if not (matches is None):
|
||||
programName = matches.group(1) if matches.group(1) else ''
|
||||
subprogramName = matches.group(3) if matches.group(3) else ''
|
||||
startTime = datetime.datetime.strptime(epg1[1], '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
endTime = datetime.datetime.strptime(epg2[1], '%Y-%m-%d %H:%M')
|
||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||
category = epg1[2]
|
||||
desc = ''
|
||||
actors = ''
|
||||
producers = ''
|
||||
episode = ''
|
||||
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)
|
||||
|
||||
# Get EPG data from LG
|
||||
def GetEPGFromLG(ChannelInfo):
|
||||
@ -265,6 +247,9 @@ def GetEPGFromLG(ChannelInfo):
|
||||
ServiceId = ChannelInfo[3]
|
||||
url = 'http://www.uplus.co.kr/css/chgi/chgi/RetrieveTvSchedule.hpi'
|
||||
epginfo = []
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
for k in range(period):
|
||||
day = today + datetime.timedelta(days=k)
|
||||
params = {'chnlCd': ServiceId, 'evntCmpYmd': day.strftime('%Y%m%d')}
|
||||
@ -280,44 +265,37 @@ def GetEPGFromLG(ChannelInfo):
|
||||
if(html):
|
||||
for row in html:
|
||||
for cell in [row.find_all('td')]:
|
||||
startTime = str(day) + ' ' + cell[0].text
|
||||
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
rating = 0 if cell[1].find('span', {'class': 'tag cte_all'}).text.strip()=="All" else int(cell[1].find('span', {'class': 'tag cte_all'}).text.strip())
|
||||
cell[1].find('span', {'class': 'tagGroup'}).decompose()
|
||||
epginfo.append([cell[1].text.strip(), str(day) + ' ' + cell[0].text, cell[2].text.strip(), rating])
|
||||
pattern = '(<재>?)?(.*?)(\[(.*)\])?\s?(\(([\d,]+)회\))?$'
|
||||
matches = re.match(pattern, cell[1].text.strip().decode('string_escape'))
|
||||
if not (matches is None):
|
||||
programName = matches.group(2).strip() if matches.group(2) else ''
|
||||
subprogramName = matches.group(4).strip() if matches.group(4) else ''
|
||||
episode = matches.group(6) if matches.group(6) else ''
|
||||
rebroadcast = True if matches.group(1) else False
|
||||
category = cell[2].text.strip()
|
||||
#ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating
|
||||
epginfo.append([ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating])
|
||||
epgzip(epginfo)
|
||||
else:
|
||||
if(debug): printError(ChannelName + CONTENT_ERROR)
|
||||
else: pass
|
||||
except (requests.exceptions.RequestException) as e:
|
||||
if(debug): printError(ChannelName + str(e))
|
||||
else: pass
|
||||
for epg1, epg2 in zip(epginfo, epginfo[1:]):
|
||||
programName = ''
|
||||
subprogramName = ''
|
||||
episode = ''
|
||||
pattern = '(<재>?)?(.*?)(\[(.*)\])?\s?(\(([\d,]+)회\))?$'
|
||||
matches = re.match(pattern, epg1[0].decode('string_escape'))
|
||||
rebroadcast = False
|
||||
if not (matches is None):
|
||||
programName = matches.group(2) if matches.group(2) else ''
|
||||
subprogramName = matches.group(4) if matches.group(4) else ''
|
||||
rebroadcast = True if matches.group(1) else False
|
||||
episode = matches.group(6) if matches.group(6) else ''
|
||||
startTime = datetime.datetime.strptime(epg1[1], '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
endTime = datetime.datetime.strptime(epg2[1], '%Y-%m-%d %H:%M')
|
||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||
category = epg1[2]
|
||||
desc = ''
|
||||
actors = ''
|
||||
producers = ''
|
||||
rating = epg1[3]
|
||||
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)
|
||||
|
||||
# Get EPG data from SK
|
||||
def GetEPGFromSK(ChannelInfo):
|
||||
ChannelId = ChannelInfo[0]
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
lastday = today + datetime.timedelta(days=period-1)
|
||||
url = 'http://m.btvplus.co.kr/Common/Inc/IFGetData.asp'
|
||||
params = {'variable': 'IF_LIVECHART_DETAIL', 'pcode':'|^|start_time=' + today.strftime('%Y%m%d') + '00|^|end_time='+ lastday.strftime('%Y%m%d') + '24|^|svc_id=' + str(ServiceId)}
|
||||
@ -333,10 +311,6 @@ def GetEPGFromSK(ChannelInfo):
|
||||
else :
|
||||
programs = data['channel']['programs']
|
||||
for program in programs:
|
||||
programName = ''
|
||||
subprogramName = ''
|
||||
episode = ''
|
||||
rebroadcast = False
|
||||
pattern = '^(.*?)(?:\s*[\(<]([\d,회]+)[\)>])?(?:\s*<([^<]*?)>)?(\((재)\))?$'
|
||||
matches = re.match(pattern, program['programName'].replace('...', '>').encode('utf-8'))
|
||||
if not (matches is None):
|
||||
@ -354,8 +328,6 @@ def GetEPGFromSK(ChannelInfo):
|
||||
producers = program['directorName'].replace('...','').strip(', ') if program['directorName'] else ''
|
||||
if not (program['mainGenreName'] is None) :
|
||||
category = program['mainGenreName']
|
||||
else:
|
||||
category = ''
|
||||
rating = int(program['ratingCd']) if program['programName'] 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)
|
||||
@ -371,6 +343,9 @@ def GetEPGFromSKB(ChannelInfo):
|
||||
ChannelId = ChannelInfo[0]
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
url = 'http://m.skbroadband.com/content/realtime/Channel_List.do'
|
||||
epginfo = []
|
||||
for k in range(period):
|
||||
@ -398,38 +373,24 @@ def GetEPGFromSKB(ChannelInfo):
|
||||
rating = row.find('span', {'class':re.compile('^watch.*$')})
|
||||
if not(rating is None) :
|
||||
rating = int(rating.text.decode('string_escape').replace('세','').strip())
|
||||
else :
|
||||
rating = 0
|
||||
#programName, startTime, rating, subprogramName, rebroadcast, episode
|
||||
epginfo.append([programName, startTime, rating, subprogramName, rebroadcast, episode])
|
||||
#ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating
|
||||
epginfo.append([ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating])
|
||||
epgzip(epginfo)
|
||||
else:
|
||||
if(debug): printError(ChannelName + CONTENT_ERROR)
|
||||
else: pass
|
||||
except (requests.exceptions.RequestException) as e:
|
||||
if(debug): printError(ChannelName + str(e))
|
||||
else: pass
|
||||
for epg1, epg2 in zip(epginfo, epginfo[1:]):
|
||||
programName = epg1[0] if epg1[0] else ''
|
||||
subprogramName = epg1[3] if epg1[3] else ''
|
||||
episode = epg1[5] if epg1[5] else ''
|
||||
rebroadcast = epg1[4] if epg1[4] else False
|
||||
startTime = datetime.datetime.strptime(epg1[1], '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
endTime = datetime.datetime.strptime(epg2[1], '%Y-%m-%d %H:%M')
|
||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||
category = ''
|
||||
desc = ''
|
||||
actors = ''
|
||||
producers = ''
|
||||
rating = epg1[2] if epg1[2] 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)
|
||||
|
||||
# Get EPG data from SKY
|
||||
def GetEPGFromSKY(ChannelInfo):
|
||||
ChannelId = ChannelInfo[0]
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
url = 'http://www.skylife.co.kr/channel/epg/channelScheduleListJson.do'
|
||||
for k in range(period):
|
||||
day = today + datetime.timedelta(days=k)
|
||||
@ -476,6 +437,9 @@ def GetEPGFromNaver(ChannelInfo):
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
epginfo = []
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
totaldate = []
|
||||
url = 'https://search.naver.com/p/csearch/content/batchrender_ssl.nhn'
|
||||
for k in range(period):
|
||||
@ -491,25 +455,16 @@ def GetEPGFromNaver(ChannelInfo):
|
||||
for i, date in enumerate(data['displayDates']):
|
||||
for j in range(0,24):
|
||||
for program in data['schedules'][j][i]:
|
||||
#programName, startTime, episode, rebroadcast, rating
|
||||
epginfo.append([program['title'], date['date'] + ' ' + program['startTime'], program['episode'].replace('회',''), program['isRerun'], program['grade']])
|
||||
for epg1, epg2 in zip(epginfo, epginfo[1:]):
|
||||
programName = unescape(epg1[0]) if epg1[0] else ''
|
||||
subprogramName = ''
|
||||
startTime = datetime.datetime.strptime(epg1[1], '%Y%m%d %H:%M')
|
||||
programName = unescape(program['title'])
|
||||
startTime = date['date'] + ' ' + program['startTime']
|
||||
startTime = datetime.datetime.strptime(startTime, '%Y%m%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
endTime = datetime.datetime.strptime(epg2[1], '%Y%m%d %H:%M')
|
||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||
desc = ''
|
||||
actors = ''
|
||||
producers = ''
|
||||
category = ''
|
||||
episode = epg1[2] if epg1[2] else ''
|
||||
if episode : episode = int(episode)
|
||||
rebroadcast = epg1[3]
|
||||
rating = epg1[4]
|
||||
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)
|
||||
episode = program['episode'].replace('회','')
|
||||
rebroadcast = program['isRerun']
|
||||
rating = program['grade']
|
||||
#ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating
|
||||
epginfo.append([ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating])
|
||||
epgzip(epginfo)
|
||||
except ValueError:
|
||||
if(debug): printError(ChannelName + CONTENT_ERROR)
|
||||
else: pass
|
||||
@ -523,6 +478,9 @@ def GetEPGFromIscs(ChannelInfo):
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
epginfo = []
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
url='https://www.iscs.co.kr/service/sub/ajax_channel_view.asp'
|
||||
for k in range(period):
|
||||
day = today + datetime.timedelta(days=k)
|
||||
@ -546,26 +504,12 @@ def GetEPGFromIscs(ChannelInfo):
|
||||
matches = re.match(pattern, programName)
|
||||
if not(matches is None) :
|
||||
programName = matches.group(1) if matches.group(1) else ''
|
||||
rebroadcast = True if matches.group(3) else False
|
||||
episode = matches.group(2) if matches.group(2) else ''
|
||||
#programName, startTime, rating, rebroadcast, episode
|
||||
epginfo.append([programName, startTime, rating, rebroadcast, episode])
|
||||
for epg1, epg2 in zip(epginfo, epginfo[1:]):
|
||||
programName = unescape(epg1[0]) if epg1[0] else ''
|
||||
subprogramName = ''
|
||||
startTime = datetime.datetime.strptime(epg1[1], '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
endTime = datetime.datetime.strptime(epg2[1], '%Y-%m-%d %H:%M')
|
||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||
desc = ''
|
||||
actors = ''
|
||||
producers = ''
|
||||
category = ''
|
||||
episode = epg1[4]
|
||||
rebroadcast = epg1[3]
|
||||
rating = epg1[2]
|
||||
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)
|
||||
rebroadcast = True if matches.group(3) else False
|
||||
|
||||
#ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating
|
||||
epginfo.append([ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating])
|
||||
epgzip(epginfo)
|
||||
except ValueError:
|
||||
if(debug): printError(ChannelName + CONTENT_ERROR)
|
||||
else: pass
|
||||
@ -579,6 +523,9 @@ def GetEPGFromHcn(ChannelInfo):
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
epginfo = []
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
url = 'https://www.hcn.co.kr/ur/bs/ch/channelInfo.hcn'
|
||||
for k in range(period):
|
||||
day = today + datetime.timedelta(days=k)
|
||||
@ -594,6 +541,8 @@ def GetEPGFromHcn(ChannelInfo):
|
||||
if(html):
|
||||
for row in html:
|
||||
startTime = str(day) + ' ' + row.find('td', {'class':'f'}).text
|
||||
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
programName = row.find('td', {'class':'left'}).text.decode('string_escape').strip()
|
||||
rating = 0
|
||||
rebroadcast = False
|
||||
@ -602,24 +551,9 @@ def GetEPGFromHcn(ChannelInfo):
|
||||
if not (rebroad is None): rebroadcast = True
|
||||
grade = re.match('([\d,]+)',image['alt'])
|
||||
if not (grade is None): rating = int(grade.group(1))
|
||||
#programName, startTime, rating, rebroadcast
|
||||
epginfo.append([programName, startTime, rating, rebroadcast])
|
||||
for epg1, epg2 in zip(epginfo, epginfo[1:]):
|
||||
programName = unescape(epg1[0]) if epg1[0] else ''
|
||||
subprogramName = ''
|
||||
startTime = datetime.datetime.strptime(epg1[1], '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
endTime = datetime.datetime.strptime(epg2[1], '%Y-%m-%d %H:%M')
|
||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||
desc = ''
|
||||
actors = ''
|
||||
producers = ''
|
||||
category = ''
|
||||
episode = ''
|
||||
rebroadcast = epg1[3]
|
||||
rating = epg1[2]
|
||||
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)
|
||||
#ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating
|
||||
epginfo.append([ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating])
|
||||
epgzip(epginfo)
|
||||
else:
|
||||
if(debug): printError(ChannelName + CONTENT_ERROR)
|
||||
else: pass
|
||||
@ -629,15 +563,61 @@ def GetEPGFromHcn(ChannelInfo):
|
||||
|
||||
# Get EPG data from POOQ
|
||||
def GetEPGFromPooq(ChannelInfo):
|
||||
#pooq
|
||||
#https://wapie.pooq.co.kr/v1/epgs30/C2301/?deviceTypeId=pc&marketTypeId=generic&apiAccessCredential=EEBE901F80B3A4C4E5322D58110BE95C&drm=WC&country=KOR&offset=0&limit=1000&startTime=2017%2F07%2F18+11%3A49&credential=none&endTime=2017%2F07%2F18+23%3A59
|
||||
ChannelId = ChannelInfo[0]
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
url = 'https://wapie.pooq.co.kr/v1/epgs30/C' + str(ServiceId) + '/'
|
||||
lastday = today + datetime.timedelta(days=period-1)
|
||||
params = {'deviceTypeId': 'pc', 'marketTypeId': 'generic', 'apiAccessCredential': 'EEBE901F80B3A4C4E5322D58110BE95C', 'offset': '0', 'limit': '1000', 'startTime': today.strftime('%Y/%m/%d') + ' 00:00', 'endTime': lastday.strftime('%Y/%m/%d') + ' 00:00'}
|
||||
date_list = [(today + datetime.timedelta(days=x)).strftime('%Y-%m-%d') for x in range(0, period)]
|
||||
try:
|
||||
response = requests.get(url, params=params, headers=ua, timeout=timeout)
|
||||
response.raise_for_status()
|
||||
json_data = response.text
|
||||
try:
|
||||
data = json.loads(json_data, encoding='utf-8')
|
||||
if (data['result']['count'] == 0) :
|
||||
if(debug): printError(ChannelName + CONTENT_ERROR)
|
||||
else: pass
|
||||
else :
|
||||
programs = data['result']['list']
|
||||
for program in programs:
|
||||
if program['startDate'] in date_list :
|
||||
startTime = program['startDate'] + ' ' + program['startTime']
|
||||
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
endTime = program['startDate'] + ' ' + program['endTime']
|
||||
endTime = datetime.datetime.strptime(endTime, '%Y-%m-%d %H:%M')
|
||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||
pattern = '^(.*?)(?:([\d,]+)회)?(?:\((재)\))?$'
|
||||
matches = re.match(pattern, program['programTitle'].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
|
||||
actors = program['programStaring'].strip(',').strip() if program['programStaring'] else ''
|
||||
desc = program['programSummary'].strip() if program['programSummary'] else ''
|
||||
rating = int(program['age'])
|
||||
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)
|
||||
except ValueError:
|
||||
if(debug): printError(ChannelName + CONTENT_ERROR)
|
||||
else: pass
|
||||
except (requests.exceptions.RequestException) as e:
|
||||
if(debug): printError(ChannelName + str(e))
|
||||
else: pass
|
||||
|
||||
pass
|
||||
# Get EPG data from MBC
|
||||
def GetEPGFromMbc(ChannelInfo):
|
||||
ChannelId = ChannelInfo[0]
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
dayofweek = ['월', '화', '수', '목', '금', '토', '일']
|
||||
url = 'http://miniunit.imbc.com/Schedule'
|
||||
params = {'rtype': 'json'}
|
||||
@ -651,25 +631,17 @@ def GetEPGFromMbc(ChannelInfo):
|
||||
data = json.loads(json_data, encoding='utf-8')
|
||||
for program in data['Programs']:
|
||||
if program['Channel'] == "CHAM" and program['LiveDays'] == dayofweek[day.weekday()]:
|
||||
programName = ''
|
||||
rebroadcast = True
|
||||
pattern = '^(.*?)(\(재\))?$'
|
||||
matches = re.match(pattern, unescape(program['ProgramTitle'].encode('utf-8', 'ignore')))
|
||||
if not(matches is None):
|
||||
programName = matches.group(1)
|
||||
rebroadcast = True if matches.group(2) else False
|
||||
subprogramName = ''
|
||||
startTime = str(day) + ' ' + program['StartTime']
|
||||
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %H%M')
|
||||
endTime = startTime + datetime.timedelta(minutes=int(program['RunningTime']))
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||
desc = ''
|
||||
actors = ''
|
||||
producers = ''
|
||||
category = '음악'
|
||||
episode = ''
|
||||
rating = 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)
|
||||
except ValueError:
|
||||
@ -684,6 +656,9 @@ def GetEPGFromMil(ChannelInfo):
|
||||
ChannelId = ChannelInfo[0]
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
url = 'http://radio.dema.mil.kr/web/fm/quick/ajaxTimetableList.do'
|
||||
for k in range(period):
|
||||
day = today + datetime.timedelta(days=k)
|
||||
@ -695,8 +670,6 @@ def GetEPGFromMil(ChannelInfo):
|
||||
try:
|
||||
data = json.loads(json_data, encoding='utf-8')
|
||||
for program in data['resultList']:
|
||||
programName = ''
|
||||
rebroadcast = False
|
||||
pattern = '^(.*?)(\(재\))?$'
|
||||
matches = re.match(pattern, unescape(program['program_title'].encode('utf-8', 'ignore')))
|
||||
if not(matches is None):
|
||||
@ -715,12 +688,8 @@ def GetEPGFromMil(ChannelInfo):
|
||||
endTime = datetime.datetime.strptime(endTime, '%Y-%m-%d %H%M')
|
||||
endTime = endTime + datetime.timedelta(hours=1)
|
||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||
desc = ''
|
||||
actors = unescape(program['movie_actor'])
|
||||
producers = unescape(program['movie_director'])
|
||||
category = ''
|
||||
episode = ''
|
||||
rating = 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)
|
||||
except ValueError:
|
||||
@ -735,6 +704,9 @@ def GetEPGFromIfm(ChannelInfo):
|
||||
ChannelId = ChannelInfo[0]
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
dayofweek = ['1', '2', '3', '4', '5', '6', '7']
|
||||
url = 'http://mapp.itvfm.co.kr/hyb/front/selectHybPgmList.do'
|
||||
for k in range(period):
|
||||
@ -748,7 +720,6 @@ def GetEPGFromIfm(ChannelInfo):
|
||||
data = json.loads(json_data, encoding='utf-8')
|
||||
for program in data['hybMusicInfoList']:
|
||||
programName = unescape(program['pgmTitle'])
|
||||
subprogramName = ''
|
||||
startTime = str(day) + ' ' + program['pgmStime']
|
||||
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
@ -761,13 +732,8 @@ def GetEPGFromIfm(ChannelInfo):
|
||||
endTime = datetime.datetime.strptime(endTime, '%Y-%m-%d %H:%M')
|
||||
endTime = endTime + datetime.timedelta(hours=1)
|
||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||
desc = ''
|
||||
actors = program['pgmDj']
|
||||
producers = program['pgmPd']
|
||||
category = ''
|
||||
episode = ''
|
||||
rebroadcast = False
|
||||
rating = 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)
|
||||
except ValueError:
|
||||
@ -782,9 +748,12 @@ def GetEPGFromKbs(ChannelInfo):
|
||||
ChannelId = ChannelInfo[0]
|
||||
ChannelName = ChannelInfo[1]
|
||||
ServiceId = ChannelInfo[3]
|
||||
epginfo = []
|
||||
startTime = endTime = programName = subprogramName = desc = actors = producers = category = episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
url = 'http://world.kbs.co.kr/include/wink/_ajax_schedule.php'
|
||||
params = {'channel':'wink_11'}
|
||||
epginfo = []
|
||||
for k in range(period):
|
||||
day = today + datetime.timedelta(days=k)
|
||||
try:
|
||||
@ -795,42 +764,42 @@ def GetEPGFromKbs(ChannelInfo):
|
||||
data = json.loads(json_data, encoding='utf-8')
|
||||
soup = BeautifulSoup(data['schedule'], 'lxml')
|
||||
for row in soup.find_all('li'):
|
||||
programName = ''
|
||||
startTime = ''
|
||||
pattern = '([0-2][0-9]:[0-5][0-9])[0-2][0-9]:[0-5][0-9]\[(.*)\] Broadcast'
|
||||
matches = re.match(pattern, unescape(row.text.encode('utf-8', 'ignore')))
|
||||
if not(matches is None):
|
||||
programName = unescape(matches.group(2))
|
||||
startTime = str(day) + ' ' + matches.group(1)
|
||||
#programName, startTime
|
||||
epginfo.append([programName, startTime])
|
||||
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
#ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating
|
||||
epginfo.append([ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating])
|
||||
epgzip(epginfo)
|
||||
except ValueError:
|
||||
if(debug): printError(ChannelName + CONTENT_ERROR)
|
||||
else: pass
|
||||
except (requests.exceptions.RequestException) as e:
|
||||
if(debug): printError(ChannelName + str(e))
|
||||
else: pass
|
||||
|
||||
# Zip epginfo
|
||||
def epgzip(epginfo):
|
||||
#ChannelId, startTime, programName, subprogramName, desc, actors, producers, category, episode, rebroadcast, rating
|
||||
for epg1, epg2 in zip(epginfo, epginfo[1:]):
|
||||
programName = epg1[0]
|
||||
subprogramName = ''
|
||||
startTime = epg1[1]
|
||||
startTime = datetime.datetime.strptime(startTime, '%Y-%m-%d %H:%M')
|
||||
startTime = startTime.strftime('%Y%m%d%H%M%S')
|
||||
endTime = epg2[1]
|
||||
endTime = datetime.datetime.strptime(endTime, '%Y-%m-%d %H:%M')
|
||||
endTime = endTime.strftime('%Y%m%d%H%M%S')
|
||||
desc = ''
|
||||
actors = ''
|
||||
producers = ''
|
||||
category = ''
|
||||
episode = ''
|
||||
rebroadcast = False
|
||||
rating = 0
|
||||
ChannelId = epg1[0]
|
||||
startTime = epg1[1] if epg1[1] else ''
|
||||
endTime = epg2[1] if epg2[1] else ''
|
||||
programName = epg1[2] if epg1[2] else ''
|
||||
subprogramName = epg1[3] if epg1[3] else ''
|
||||
desc = epg1[4] if epg1[4] else ''
|
||||
actors = epg1[5] if epg1[5] else ''
|
||||
producers = epg1[6] if epg1[6] else ''
|
||||
category = epg1[7] if epg1[7] else ''
|
||||
episode = epg1[8] if epg1[8] else ''
|
||||
rebroadcast = True if epg1[9] else False
|
||||
rating = int(epg1[10]) if epg1[10] 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)
|
||||
|
||||
|
||||
|
||||
# Write Program
|
||||
def writeProgram(programdata):
|
||||
ChannelId = programdata['channelId']
|
||||
@ -861,6 +830,7 @@ def writeProgram(programdata):
|
||||
if addverbose == 'y':
|
||||
desc = escape(programdata['programName'])
|
||||
if subprogramName : desc = desc + '\n부제 : ' + subprogramName
|
||||
if rebroadcast == True and addrebroadcast == 'y' : desc = desc + '\n방송 : 재방송'
|
||||
if episode : desc = desc + '\n회차 : ' + str(episode) + '회'
|
||||
if category : desc = desc + '\n장르 : ' + category
|
||||
if actors : desc = desc + '\n출연 : ' + actors
|
||||
|
Loading…
x
Reference in New Issue
Block a user