From: gn64_jp Date: Fri, 18 Feb 2011 00:18:40 +0000 (+0000) Subject: add logo search. X-Git-Url: http://git.osdn.net/view?p=rec10%2Frec10-git.git;a=commitdiff_plain;h=975a6c548b6b2c399741a3fbde870c5aa6e7ab0f add logo search. git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@839 4e526526-5e11-4fc0-8910-f8fd03428081 --- diff --git a/rec10/trunk/src/chdata.py b/rec10/trunk/src/chdata.py index 6f2ceb4..861719b 100644 --- a/rec10/trunk/src/chdata.py +++ b/rec10/trunk/src/chdata.py @@ -6,13 +6,15 @@ import os.path import configreader import xml.dom.minidom import scan_ch +import datetime import rec10d path = str(os.path.dirname(os.path.abspath(__file__))) + "/" def chAdd(bctype, chtxt, ch, csch):#すべて文字列 - rec10d.rec10db.add_epg_ch(bctype,chtxt, ch, csch, u"2010-01-01 00:00:00") + tnow=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + rec10d.rec10db.add_epg_ch(bctype,chtxt, ch, csch, u"2010-01-01 00:00:00",u"2010-01-01 00:00:00",tnow) def addCHlist(cl): if len(cl)>0: for c in cl: diff --git a/rec10/trunk/src/chdb.py b/rec10/trunk/src/chdb.py index e542ff8..bfea9a4 100644 --- a/rec10/trunk/src/chdb.py +++ b/rec10/trunk/src/chdb.py @@ -59,7 +59,6 @@ def update(): CSupdate = 0 CS2update = 0 BSupdate = 0 - HUupdate = 0 rec10d.rec10db.set_new_status("8") for datum in rec10d.rec10db.select_get_update_epg_ch("6"): bctype = datum[0] @@ -79,4 +78,15 @@ def update(): ret.append(bctype) return ret def changeCHShow(chtxt,isshow): - rec10d.rec10db.change_visible_epg_ch(chtxt, isshow) \ No newline at end of file + rec10d.rec10db.change_visible_epg_ch(chtxt, isshow) +def updateLogo(): + ret=[] + BSCSUpdate=0 + for datum in rec10d.rec10db.select_get_updatelogo_epg_ch("720"): + bctype=datus[0] + if bctype == "cs1" or bctype == u"cs1": + ret.append(u"bs") + BSCSUpdate=1 + else: + ret.append(bctype) + return ret diff --git a/rec10/trunk/src/dbMySQL.py b/rec10/trunk/src/dbMySQL.py index 1dab3ea..de26606 100644 --- a/rec10/trunk/src/dbMySQL.py +++ b/rec10/trunk/src/dbMySQL.py @@ -101,19 +101,22 @@ class DB_MySQL: logo2 BLOB,\ logo3 BLOB,\ logo4 BLOB,\ - logo5 BLOB\ + logo5 BLOB,\ + logoupdate DATETIME,\ + logostatus TINYINT DEFAULT 2,\ + scanupdate DATETIME\ )') except Exception, inst: if not ((type(inst)==MySQLdb.ProgrammingError and inst[0]==1007)or(type(inst)==MySQLdb.OperationalError and inst[0]==1050)): recdblist.addCommonlogEX("Error", "new_epg_ch (dbMySQL.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200) self.close_db(db) - def add_epg_ch(self, bctype, chtxt, ch, csch, updatetime): + def add_epg_ch(self, bctype, chtxt, ch, csch, updatetime,logoupdate,scanupdate): db = self.connect_db() db[1].execute('\ - INSERT INTO epg_ch (bctype,chtxt,ch,csch,chname,updatetime,status,visible)\ - VALUES (%s,%s,%s,%s,"",%s,%s,%s)', \ - (bctype, chtxt, ch, csch, updatetime, "1","1")) + INSERT INTO epg_ch (bctype,chtxt,ch,csch,chname,updatetime,status,visible,logoupdate,scanupdate)\ + VALUES (%s,%s,%s,%s,"",%s,%s,%s,%s,%s)', \ + (bctype, chtxt, ch, csch, updatetime, "1","1",logoupdate,scanupdate)) self.close_db(db) def delete_all_epg_ch(self): db = self.connect_db() @@ -123,7 +126,7 @@ class DB_MySQL: def select_by_chtxt_epg_ch(self, chtxt): db = self.connect_db() dbexe = db[1].execute("\ - SELECT bctype,chtxt,ch,csch,updatetime,chname,status,visible \ + SELECT bctype,chtxt,ch,csch,updatetime,chname,status,visible,logoupdate,scanupdate \ FROM epg_ch \ WHERE chtxt LIKE %s", \ (chtxt,)) @@ -135,12 +138,14 @@ class DB_MySQL: for dl in dls: r = list(dl) r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S") + r[8] = r[8].strftime("%Y-%m-%d %H:%M:%S") + r[9] = r[9].strftime("%Y-%m-%d %H:%M:%S") ret.append(r) return ret def select_by_bctype_epg_ch(self, bctype): db = self.connect_db() dbexe = db[1].execute("\ - SELECT bctype,chtxt,ch,csch,updatetime,status,chname,status,visible \ + SELECT bctype,chtxt,ch,csch,updatetime,status,chname,status,visible,logoupdate,scanupdate \ FROM epg_ch \ WHERE bctype = %s", \ (bctype,)) @@ -153,6 +158,8 @@ class DB_MySQL: #recdblist.printutf8(dl) r = list(dl) r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S") + r[9] = r[9].strftime("%Y-%m-%d %H:%M:%S") + r[10] = r[10].strftime("%Y-%m-%d %H:%M:%S") r[5] = str(r[5]) ret.append(r) return ret @@ -160,7 +167,7 @@ class DB_MySQL: db = self.connect_db() dbexe = db[1].execute("\ SELECT \ - bctype,chtxt,ch,csch,updatetime,chname,status,visible \ + bctype,chtxt,ch,csch,updatetime,chname,status,visible,logoupdate,scanupdate \ FROM epg_ch \ WHERE ch = %s", \ (ch,)) @@ -172,13 +179,15 @@ class DB_MySQL: for dl in dls: r = list(dl) r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S") + r[8] = r[8].strftime("%Y-%m-%d %H:%M:%S") + r[9] = r[9].strftime("%Y-%m-%d %H:%M:%S") ret.append(r) return ret def select_by_csch_epg_ch(self, csch): db = self.connect_db() dbexe = db[1].execute("\ SELECT \ - bctype,chtxt,ch,csch,updatetime,chname,status,visible \ + bctype,chtxt,ch,csch,updatetime,chname,status,visible,logoupdate,scanupdate \ FROM epg_ch \ WHERE csch = %s", \ (csch,)) @@ -190,12 +199,14 @@ class DB_MySQL: for dl in dls: r = list(dl) r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S") + r[8] = r[8].strftime("%Y-%m-%d %H:%M:%S") + r[9] = r[9].strftime("%Y-%m-%d %H:%M:%S") ret.append(r) return ret def select_all_epg_ch(self): db = self.connect_db() dbexe = db[1].execute("\ - SELECT bctype,chtxt,ch,csch,updatetime,chname,status,visible \ + SELECT bctype,chtxt,ch,csch,updatetime,chname,status,visible,logoupdate,scanupdate \ FROM epg_ch \ ") ret = [] @@ -206,6 +217,8 @@ class DB_MySQL: for dl in dls: r = list(dl) r[4] = r[4].strftime("%Y-%m-%d %H:%M:%S") + r[8] = r[8].strftime("%Y-%m-%d %H:%M:%S") + r[9] = r[9].strftime("%Y-%m-%d %H:%M:%S") ret.append(r) return ret def change_visible_epg_ch(self,chtxt,visible): @@ -247,6 +260,24 @@ class DB_MySQL: ret = db[1].fetchall() self.close_db(db) return ret + def select_get_updatelogo_epg_ch(self, dhour): + db = self.connect_db() + dbexe = db[1].execute("SELECT bctype,chtxt,logostatus FROM epg_ch \ + WHERE (\ + ( \ + updatetime < DATE_SUB(now(),INTERVAL " + dhour + " HOUR) \ + AND \ + logostatus = 1 \ + ) \ + OR \ + logostatus > 1 )\ + ORDER BY status DESC") + ret = [] + #recdblist.printutf8(dbexe) + if dbexe > 0: + ret = db[1].fetchall() + self.close_db(db) + return ret def update_by_bctype_epg_ch(self, bctype): db = self.connect_db() db[1].execute("\ @@ -256,6 +287,7 @@ class DB_MySQL: status = 1 \ WHERE bctype = %s", (bctype,)) self.close_db(db) + def update_by_bctype_and_chtxt_epg_ch(self, bctype, chtxt): db = self.connect_db() db[1].execute("\ @@ -276,14 +308,26 @@ class DB_MySQL: (status, bctype)\ ) self.close_db(db) - def update_chname_by_chtxt_epg_ch(self,chtxt,chname): + def update_status_by_bctype_epg_ch(self, bctype, status): db = self.connect_db() db[1].execute("\ UPDATE epg_ch \ SET \ - chname=%s \ - WHERE chtxt = %s", \ - (chname, chtxt)\ + status=%s , \ + updatetime=now() \ + WHERE bctype = %s", \ + (status, bctype)\ + ) + self.close_db(db) + def update_logostatus_by_bctype_epg_ch(self,bctype,logostatus): + db = self.connect_db() + db[1].execute("\ + UPDATE epg_ch \ + SET \ + logostatus=%s , \ + logoupdate=now() \ + WHERE bctype = %s", \ + (logostatus, bctype)\ ) self.close_db(db) def add_auto_proc_tmp(self,type,title,chtxt): diff --git a/rec10/trunk/src/epgdb.py b/rec10/trunk/src/epgdb.py index 7269ef9..34f1865 100644 --- a/rec10/trunk/src/epgdb.py +++ b/rec10/trunk/src/epgdb.py @@ -45,6 +45,19 @@ def updatebc(bctype): recdblist.addCommonlogEX("Error","updatebc(epgdb.py)", str(type(inst)), str(inst)+"\n"+traceback.format_exc(),log_level=200) xml2db_dom.xml2db_dom(tmppath + bctype + "epgdata.bak.xml", bctype) rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "2") +def updateLogo_bc(bctype): + bctypel = chdb.searchCHFromBctype(bctype) + #print bctype + try: + ts2epg.writeLogoEpgXML(tmppath + bctype + "logo.xml", chdb.searchCHFromBctype(bctype)['ch']) + xml2db_dom.xml2db_dom_logo(tmppath + bctype + "logo.xml", bctype) + shutil.copyfile(tmppath + bctype + "logo.xml", tmppath + bctype + "logo.bak.xml") + time.sleep(5) + rec10d.rec10db.update_logostatus_by_bctype_epg_ch(bctype,"1") + except Exception, inst: + recdblist.addCommonlogEX("Error","updatebc(epgdb.py)", str(type(inst)), str(inst)+"\n"+traceback.format_exc(),log_level=200) + xml2db_dom.xml2db_dom(tmppath + bctype + "logo.bak.xml", bctype) + rec10d.rec10db.update_logostatus_by_bctype_epg_ch(bctype,"2") def searchTime(titletxt, timet, deltatime, chtxt): time = datetime.datetime.strptime(timet, "%Y-%m-%d %H:%M:%S") ret = [] diff --git a/rec10/trunk/src/scan_ch.py b/rec10/trunk/src/scan_ch.py index 9f0be2e..1a6e751 100644 --- a/rec10/trunk/src/scan_ch.py +++ b/rec10/trunk/src/scan_ch.py @@ -7,6 +7,7 @@ import os.path import time import commands import traceback +import datetime import chdb import rec10d @@ -84,9 +85,11 @@ def addCh(ch,bctype,chtxthead): try: if ch.find("bs")>-1: if int(lstr)<300: - rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr, u"2010-01-01 00:00:00") + tnow=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr, u"2010-01-01 00:00:00", u"2010-01-01 00:00:00",tnow) else: - rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr, u"2010-01-01 00:00:00") + tnow=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr, u"2010-01-01 00:00:00", u"2010-01-01 00:00:00",tnow) except Exception, inst: recdblist.addCommonlogEX("Warning", "addCh (scan_ch.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200) checkB25Purchased(ch, prglist[1]) diff --git a/rec10/trunk/src/timerec.py b/rec10/trunk/src/timerec.py index 3b95962..a821e60 100644 --- a/rec10/trunk/src/timerec.py +++ b/rec10/trunk/src/timerec.py @@ -74,6 +74,7 @@ def task(): auto_process.killDeadEncode(recpath) sys.exit() update = chdb.update() + updatelogo = chdb.updateLogo() if len(update) > 0: pid = os.fork() if pid != 0: @@ -101,6 +102,32 @@ def task(): time.sleep(5) auto_process.update_all_timeline_epg() sys.exit() + elif len(updatelogo)>0: + pid = os.fork() + if pid != 0: + "" + else: + i = 0 + for bctype in updatelogo: + recnum = 0 + if bctype.find('te') > -1: + recnum = status.getTERecording() + recdb.countRecNow_minutes_TE("1200") + recdblist.printutf8(u"ロゴ取得 : 放送種別-"+bctype + u"||該当チューナー実行中件数:" + str(status.getTERecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_TE("10")),verbose_level=800) + recnum = int(configreader.getConfEnv("te_max")) -recnum + else: + recnum = status.getBSCSRecording() + recdb.countRecNow_minutes_BSCS("1200") + recdblist.printutf8(u"ロゴ取得 : 放送種別-"+bctype + u"||該当チューナー実行中件数:" + str(status.getBSCSRecording()) + u":直近予約件数:" + str(recdb.countRecNow_minutes_BSCS("10")),verbose_level=800) + recnum = int(configreader.getConfEnv("bscs_max")) -recnum + if recnum >0 : + recdblist.printutf8(str(updatelogo),verbose_level=750) + rec10d.rec10db.update_logostatus_by_bctype_epg_ch(bctype,"0") + epgdb.updateLogo_bc(bctype) + updatelogo = chdb.updateLogo() + i = i + 1 + if i > 0: + break + time.sleep(5) + sys.exit() else: pid = os.fork() if pid != 0: diff --git a/rec10/trunk/src/ts2epg.py b/rec10/trunk/src/ts2epg.py index 65e7f1e..5f6a73d 100644 --- a/rec10/trunk/src/ts2epg.py +++ b/rec10/trunk/src/ts2epg.py @@ -23,7 +23,13 @@ def writeEpgXML(pout, ch): elif len(ch)>2: timet = "240" writeEpgXMLTime(pout, ch ,timet) -def writeEpgXMLTime(pout, ch ,times): +def writeLogoEpgXML(pout, ch): + """ + tsを取得してepgの入ったxmlとして書き出す + """ + timet = "1200" + writeEpgXMLTime(pout, ch ,timet,islogo=1) +def writeEpgXMLTime(pout, ch ,times,islogo=0): """ 指定された時間分tsを取得してepgの入ったxmlとして書き出す """ @@ -39,8 +45,11 @@ def writeEpgXMLTime(pout, ch ,times): if os.access(pout + ".ts", os.F_OK): os.remove(pout + ".ts") time.sleep(10) - tv2ts.tv2tsmix(pout + ".ts", ch, timet) - exe = "export LANG=ja_JP.UTF-8 && nice -n 15 " + epgdump + " " + mode + " " + pout + ".ts " + pout + tv2ts.tv2b25ts(pout+ ".ts", ch, time) + logoopt="" + if islogo==1: + logoopt="/LOGO " + exe = "export LANG=ja_JP.UTF-8 && nice -n 15 " + epgdump + " " +logoopt+ mode + " " + pout + ".ts " + pout recdblist.printutf8(exe) recdblist.addCommonlogEX(u"通常", "write_time(ts2epg.py)", exe,"",log_level=500) unicode(commands.getoutput(exe),'utf-8','ignore')