db = self.connect_db()
dbexe=db[1].execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE ontv = %s",(ontv,))
ret=[]
+ dls=[]
if dbexe>0:
- ret=db[1].fetchall()
+ dls=db[1].fetchall()
self.close_db(db)
+ for dl in dls:
+ r=list(dl)
+ r[5]=r[5].strftime("%Y-%m-%d %H:%M:%S")
+ ret.append(r)
return ret
def select_by_chtxt_chdata(self,chtxt):
db = self.connect_db()
dbexe=db[1].execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE chtxt = %s",(chtxt,))
ret=[]
+ dls=[]
if dbexe>0:
- ret=db[1].fetchall()
+ dls=db[1].fetchall()
self.close_db(db)
+ for dl in dls:
+ r=list(dl)
+ r[5]=r[5].strftime("%Y-%m-%d %H:%M:%S")
+ ret.append(r)
return ret
def select_by_bctype_chdata(self,bctype):
db = self.connect_db()
- dbexe=db[1].execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE bctype = %s",(bctype,))
+ dbexe=db[1].execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime,status FROM chdata WHERE bctype = %s",(bctype,))
ret=[]
+ dls=[]
if dbexe>0:
- ret=db[1].fetchall()
+ dls=db[1].fetchall()
self.close_db(db)
+ for dl in dls:
+ #print dl
+ r=list(dl)
+ r[5]=r[5].strftime("%Y-%m-%d %H:%M:%S")
+ ret.append(r)
return ret
def select_by_ch_chdata(self,ch):
db = self.connect_db()
dbexe=db[1].execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE ch = %s",(ch,))
ret=[]
+ dls=[]
if dbexe>0:
- ret=db[1].fetchall()
+ dls=db[1].fetchall()
self.close_db(db)
+ for dl in dls:
+ r=list(dl)
+ r[5]=r[5].strftime("%Y-%m-%d %H:%M:%S")
+ ret.append(r)
return ret
def select_all_chdata(self):
db = self.connect_db()
dbexe=db[1].execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata ")
ret=[]
+ dls=[]
if dbexe>0:
- ret=db[1].fetchall()
+ dls=db[1].fetchall()
self.close_db(db)
+ for dl in dls:
+ r=list(dl)
+ r[5]=r[5].strftime("%Y-%m-%d %H:%M:%S")
+ ret.append(r)
return ret
def select_get_update_chdata(self,dhour):
db = self.connect_db()
- dbexe=db[1].execute("SELECT bctype,chtxt,status FROM chdata WHERE updatetime < DATE_SUB(now(),INTERVAL "+dhour+" HOUR) AND status > 0 ORDER BY status DESC")
+ dbexe=db[1].execute("SELECT bctype,chtxt,status FROM chdata WHERE ( updatetime < DATE_SUB(now(),INTERVAL "+dhour+" HOUR) AND status = 0 ) OR status > 1 ORDER BY status DESC")
ret=[]
- print dbexe
+ #print dbexe
if dbexe>0:
ret=db[1].fetchall()
self.close_db(db)
return ret
def select_by_bctype_chdata(self,bctype):
db = self.connect_db(480)
- dbexe=db.execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE bctype = ?",(bctype,))
+ dbexe=db.execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime,status FROM chdata WHERE bctype = ?",(bctype,))
ret=dbexe.fetchall()
self.close_db(db)
return ret
return ret
def select_get_update_chdata(self,dhour):
db = self.connect_db(480)
- dbexe=db.execute("SELECT bctype,chtxt,status FROM chdata WHERE updatetime < datetime(\'now\',\'localtime\',\'-"+dhour+" hours\') AND status > 0 ORDER BY status DESC")
+ dbexe=db.execute("SELECT bctype,chtxt,status FROM chdata WHERE ( updatetime < datetime(\'now\',\'localtime\',\'-"+dhour+" hours\') AND status > 0 ) OR status > 1 ORDER BY status DESC")
ret=dbexe.fetchall()
self.close_db(db)
return ret
print type(inst)
print inst
xml2db.xml2db(tmppath+bctype+"epgdate.bak.xml",bctype)
- rec10d.rec10db.update_status_by_bctype_chdata(bctype,"2")
+ if rec10d.rec10db.select_by_bctype_chdata(bctypet)[0][6]!="0":
+ rec10d.rec10db.update_status_by_bctype_chdata(bctype,"2")
def updatebc_bak(bctype):
"""
update epg data by .bak file
#if inum+status.getBSCSRecording()+status.getTERecording() < 2:
update=chdb.update()
+ print update
print "番組表更新処理"
if len(update)>0:
pid=os.fork()
else:#子プロセスの場合 アップデートを行って終了
bctypet=chdb.chtxtsearch(chtxt)['bctype']
chdatat=rec10d.rec10db.select_by_bctype_chdata(bctypet)
- dt1=datetime.datetime.now()-datetime.datetime.strptime(chdatat[5],"%Y-%m-%d %H:%M:%S")
+ dt1=datetime.datetime.now()-datetime.datetime.strptime(chdatat[0][5],"%Y-%m-%d %H:%M:%S")
dt1=dt1.days*24*60*60+dt1.seconds
if dt1<60*60:
recdata=epgdb.searchtime2(title.decode('utf-8'),btime,"5",chtxt)
print "nothing match"
else:
rec10d.rec10db.update_status_by_bctype_chdata(bctypet,"3")
+ sys.exit()
"""cht=chdb.chtxtsearch(chtxt)['bctype']
if cht.find('te')!=-1:
cht='te'
et=et+datetime.timedelta(seconds=600)
btime=bt.strftime("%Y-%m-%d %H:%M:%S")
etime=et.strftime("%Y-%m-%d %H:%M:%S")
- recdb.rec_reckey(recdb.REC_ENCODE_QUE,title,chtxt,btime,etime,opt)
\ No newline at end of file
+ recdb.rec_reckey(recdb.REC_ENCODE_QUE,title,chtxt,btime,etime,opt)