PortHUEPG class updated to work with port.ro
example channel:
Code:
<stream>
<title><![CDATA[DolceSport]]></title>
<info resolution="" bitrate=""/>
<swfUrl><![CDATA[http://static1.mediadirect.ro/player-preload/swf/dolce_video_1019/player.swf]]></swfUrl>
<link><![CDATA[rtmpe://fms38.mediadirect.ro:1935/live3]]></link>
<pageUrl><![CDATA[http://-----dolcetv.ro/]]></pageUrl>
<playpath><![CDATA[dolcesport]]></playpath>
<language><![CDATA[Sport]]></language>
<advanced><![CDATA[app=live3?id=59941582%26publisher=2 conn=O:1 conn=O:0 live=1]]></advanced>
<logourl>http://www.lyngsat-logo.com/hires/dd/dolce_sport.png</logourl><epgid>porthu:10212</epgid></stream>
<stream>
Code:
class PortHUEPG(BaseEPG):
def getList(self,chan,offset=0,next=None,au=False):
tepg = []
domain = ['hu','ro','cz','hu','hr','sk','rs'][ int(chan) / 10000 ]
#added these 2 lines and replaced Europe with timezone in class
if domain == 'ro': timezone = Turkey
else: timezone = Europe
tdate = datetime.now(timezone) - timedelta(days=offset)
#changed encoding to iso-8859-2
listingsSplit = getURL('http://port.'+domain+'/pls/w/tv.channel?i_date='+tdate.strftime("%Y-%m-%d")+'&i_ch='+chan+'&i_xday=13','iso-8859-2').split('class="date_box"')
for j in range(13):
listings=' '.join([listingsSplit[1+j], listingsSplit[14+j]])
if j == 0:
listings = listings.split('<div class="progress_place"')[-1] # Ignore past entries
#changed from porthu- to port
lis = re.compile('<tr style="" class="port.*?<div class="btxt".+?(\d\d?:\d\d)<!.+?class="btxt">(.+?)<(.+?)</tr>', re.S).findall(listings)
if j == 0:
lis[:0] = re.compile('class="begin_time">(\d\d?:\d\d)</p>.+?class="btxt">(.+?)<(.+?)</tr>', re.S).findall(listings) # Add program currently on-air
nextDay = j
for i,l in enumerate(lis):
if i > 0 and int(l[0].split(':')[0]) < int(lis[i-1][0].split(':')[0]):
nextDay = j + 1
start=datetime.fromtimestamp(time.mktime(time.strptime((tdate+timedelta(days=nextDay)).strftime("%Y %m %d ")+l[0], "%Y %m %d %H:%M")))
start=start.replace(tzinfo=timezone)
if i + 1 < len(lis):
if int(lis[i+1][0].split(':')[0]) < int(l[0].split(':')[0]):
nextDay = j + 1
end=datetime.fromtimestamp(time.mktime(time.strptime((tdate+timedelta(days=nextDay)).strftime("%Y %m %d ")+lis[i+1][0], "%Y %m %d %H:%M")))
else:
end=datetime.fromtimestamp(time.mktime(time.strptime((start+timedelta(hours=1)).strftime("%Y %m %d %H:%M"), "%Y %m %d %H:%M")))
end=end.replace(tzinfo=timezone).astimezone(LocalTimezone)
start=start.replace(tzinfo=timezone).astimezone(LocalTimezone)
#added mtxt
mtxt = '\n'.join(re.compile('<span class="mtxt">(.+?)</span>').findall(l[2]))
ltxt = '\n'.join(re.compile('<span class="ltxt">(.+?)</span>').findall(l[2]))
btxt = '\n'.join(re.compile('<span class="btxt">(.+?)</span>').findall(l[2]))
descText = '\n'.join(re.compile('<p class="desc_text">(.+?)</p>').findall(l[2]))
desc = '\n'.join([ltxt, mtxt, btxt, descText]).replace('<br/>','\n').replace('\n\n','\n')
thumbMatch = re.compile('<img class="object_picture" src="(.+?)"').findall(l[2])
if len(thumbMatch) > 0:
thumb = thumbMatch[0].replace('_3','_1')
else:
thumb = None
tepg.append([l[1], start, end, desc, thumb])
self.insertIntoDB(tepg,au=au)