def get_desc(self, vprogrammedata, vcontent): try: common.dbg_log('parser::get_desc', 'enter_function') if vcontent != '': vdesc = vcontent.replace('<br>', ' ') vdesc = common.remove_specsym(self.remove_tags(vdesc)) vprogrammedata.Desc = vdesc common.dbg_log('parser::get_desc', 'exit_function') except Exception, e: common.dbg_log('parser::get_desc', 'ERROR: (' + repr(e) + ')', common.logErorr)
def get_content_day(self, vchanneldata, vdate): try: common.dbg_log('parser::get_content_day', 'enter_function') ltime = '00:00' ctimeb = '00:00' ctimee = '00:00' ctitle = '' vdirection = 'schedule_channel_%s_day_%s.html' % (vchanneldata.Index, vdate.strftime('%Y-%m-%d')) common.dbg_log('parser::get_content_day', common.host+vdirection) html = common.load_url(common.host+vdirection) html = html.decode('windows-1251').encode('utf-8') if self.FullDesc == 'true': prdata = re.compile('<div class="(?:pasttime|onair|time)">(.+?)</div><div class="(?:pastprname2|prname2)">(.+?)</div>').findall(html) for ctimeb, prtitle in prdata: if ctimeb < ltime: vdate = vdate + datetime.timedelta(days=1) ltime = ctimeb oprtitle = prtitle ctimeb = self.get_datetime_fmt(vdate, ctimeb + ':00', common.correction) ctimee = self.get_datetime_fmt(vdate, '23:59:59', common.correction) ctitle = common.remove_specsym(self.remove_tags(prtitle)) prog = programme.programme(vchanneldata.Index, ctimeb, ctitle.decode('utf-8'), ctimee) self.get_category_from_title(prog) self.get_fulldesc(prog, oprtitle) self.Programmes.Data.append(prog) else: prdata = re.compile('<div class="(?:pasttime|onair|time)">(.+?)</div><div class="(?:pastprname2|prname2)">(.+?)(?:</div><div id=desc\d{16} class="(?:pastdesc|prdesc)"><div class="desc"><b>(.+?)</div></div>|</div>)').findall(html) for ctimeb, prtitle, prdesc in prdata: if ctimeb < ltime: vdate = vdate + datetime.timedelta(days=1) ltime = ctimeb oprtitle = prtitle ctimeb = self.get_datetime_fmt(vdate, ctimeb + ':00', common.correction) ctimee = self.get_datetime_fmt(vdate, '23:59:59', common.correction) ctitle = common.remove_specsym(self.remove_tags(prtitle)) prog = programme.programme(vchanneldata.Index, ctimeb, ctitle.decode('utf-8'), ctimee) self.get_category_from_title(prog) self.get_desc(prog, prdesc.decode('utf-8')) self.Programmes.Data.append(prog) common.dbg_log('parser::get_content_day', 'exit_function') except Exception, e: common.dbg_log('parser::get_content_day', 'ERROR: (' + repr(e) + ')', common.logErorr)