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)
 def load_channels_from_net(self):
     try:
         common.dbg_log('channel_list::load_channel_from_net', 'enter_function')
         self.Data = []
         html = common.load_url(common.host+'channels.html')
         html = html.decode('windows-1251').encode('utf-8')
         datalst = re.compile('<option value=channel_(.+?)>(.+?)</option>').findall(html)
         for index,oname in datalst:
             if common.lang == 'ru':
                 flag = oname.find('(на укр.)') == -1
             else:
                 flag = oname.find('(на укр.)') != -1
             if flag:
                 icon = common.host + 'pic/channel_logos/' + index + '.gif'
                 chn = channel(index, oname.decode('utf-8'), oname.decode('utf-8'), icon)
                 self.Data.append(chn)
         if common.sort_by_index == 'true':
             self.Data.sort(key = lambda x: int(x.Index))
         common.dbg_log('channel_list::load_channel_from_net', 'exit_function')
     except Exception, e:
         common.dbg_log('channel_list::load_channel_from_net', 'ERROR: (' + repr(e) + ')', common.logErorr)
 def get_fulldesc(self, vprogrammedata, vcontent):
     try:
         common.dbg_log('parser::get_fulldesc', 'enter_function')
         idx_beg = vcontent.find('<a href=')
         if idx_beg != -1:
             idx_end = vcontent.find('.html')
             url = vcontent[idx_beg+8:idx_end]+'.html'
             sprg = self.Programmes.get_programme_for_url(url)
             if sprg != None:
                 vprogrammedata.copy_fulldesc(sprg)
             else:
                 html = common.load_url(common.host+url)
                 html = html.decode('windows-1251').encode('utf-8')
                 vprogrammedata.UrlDesc = url
                 showname = '<td colspan="2" valign="top" class="showname">'
                 showmain = '<td width="700" valign="top" class="showmain">'
                 showname1 = self.parse_strings(html,showname,showmain)
                 ctmp = ''
                 ccountry = ''
                 cdate = ''
                 if showname1.find('<strong>') != -1:
                     ctmp = self.parse_strings(showname1,'<br>','<strong>',1).strip(',')
                 else:
                     ctmp = self.parse_strings(showname1,'<br>','<!--',1).strip(',').replace('&nbsp;','')
                 if len(ctmp.split(','))==2:                     
                     ccountry = ctmp.split(',')[0].strip()
                     cdate = ctmp.split(',')[1].strip()
                     if cdate[-1] == '-':
                         cdate = cdate[:-1]           
                     if cdate != '':
                         ctmp = ccountry + ', ' + cdate
                         vprogrammedata.Date = cdate
                 ctmp = ctmp.decode('utf-8').strip(' \t\n\r')
                 cgenre = ''
                 cgenre = self.parse_strings(showname1,'<strong>','</strong>',1).replace(' / ', ',')
                 if cgenre != '':
                     cgenre = cgenre.decode('utf-8').strip(' \t\n\r')
                     if vprogrammedata.CategoryLang1 != '':
                         vprogrammedata.CategoryLang1 = vprogrammedata.CategoryLang1 + ',' + cgenre
                     else:
                         vprogrammedata.CategoryLang1 = cgenre
                 cdirectors = ''
                 cactors = ''
                 cdesc = ''
                 crat = ''
                 showmain1 = self.parse_strings(html,showmain,'<td valign="top">')
                 cdirectors = self.parse_strings(showmain1,'Режиссер(ы):','<br>',1)
                 if cdirectors != '':
                     vprogrammedata.Directors = cdirectors.decode('utf-8')[12:].strip().strip(' \t\n\r')                        
                 cactors = self.parse_strings(showmain1,'Актеры:','<div>',1)
                 if cactors != '':
                     vprogrammedata.Actors = cactors.decode('utf-8')[7:].strip().strip(' \t\n\r') 
                 cactors1 = self.parse_strings(showmain1,'Ведущие:','<div>',1)
                 if cactors1 != '':
                     if vprogrammedata.Actors != '':
                         vprogrammedata.Actors = vprogrammedata.Actors + cactors1.decode('utf-8')[8:].strip().strip(' \t\n\r')
                     else:
                         vprogrammedata.Actors = cactors1.decode('utf-8')[8:].strip().strip(' \t\n\r')
                 cdesc = self.parse_strings(showmain1,'<span class="big">','<span class="name">',1)
                 if ctmp !='':
                     vprogrammedata.FullDesc = ctmp + '. ' + cdesc.decode('utf-8').strip().strip(' \t\n\r')
                 else:
                     vprogrammedata.FullDesc = cdesc.decode('utf-8').strip().strip(' \t\n\r')
                 crat = self.parse_strings(showmain1,'<span class="name">','Проголосовало',1)
                 if len(crat.decode('utf-8').split(':'))>1:
                     crat = crat.decode('utf-8').split(':')[1].strip().strip(' \t\n\r')
                 else:
                     crat = ''
                 if crat != '':
                     vprogrammedata.Starrating = crat
         common.dbg_log('parser::get_fulldesc', 'exit_function')
     except Exception, e:
         common.dbg_log('parser::get_fulldesc', 'ERROR: (' + repr(e) + ')', common.logErorr)