3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
9 dbpath=str(os.path.dirname(os.path.abspath(__file__)))+"/"+"ch.db"
10 #db=sqlite3.connect(dbpath)
12 def ontvsearch(ontvin):
13 db=sqlite3.connect(dbpath)
15 for bctype, ontv, chtxt, ch, csch ,updatetime in db.execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE ontv = \""+ontvin+"\""):
16 rett={'bctype':bctype,'ontv':ontv,'chtxt':chtxt,'ch':ch,'csch':csch,'update':updatetime}
20 def chtxtsearch(chtxtin):
21 db=sqlite3.connect(dbpath)
24 for bctype, ontv, chtxt, ch, csch ,updatetime in db.execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE chtxt = \""+chtxtin+"\""):
25 rett={'bctype':bctype,'ontv':ontv,'chtxt':chtxt,'ch':ch,'csch':csch,'update':updatetime}
30 def bctypesearch(bctypein):
31 db=sqlite3.connect(dbpath)
33 for bctype, ontv, chtxt, ch, csch ,updatetime in db.execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE bctype = \""+bctypein+"\""):
34 rett={'bctype':bctype,'ontv':ontv,'chtxt':chtxt,'ch':ch,'csch':csch,'update':updatetime}
40 db=sqlite3.connect(dbpath)
42 for bctype, ontv, chtxt, ch, csch ,updatetime in db.execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE ch = \""+chin+"\""):
43 rett={'bctype':bctype,'ontv':ontv,'chtxt':chtxt,'ch':ch,'csch':csch,'update':updatetime}
49 db=sqlite3.connect(dbpath)
51 for bctype, ontv, chtxt, ch, csch ,updatetime in db.execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata"):
52 rett={'bctype':bctype,'ontv':ontv,'chtxt':chtxt,'ch':ch,'csch':csch,'update':updatetime}
60 db=sqlite3.connect(dbpath)
64 for bctype , chtxt in db.execute("SELECT bctype,chtxt FROM chdata WHERE updatetime < datetime(\'now\',\'localtime\',\'-6 hours\')"):
71 db.execute("UPDATE chdata SET updatetime=datetime(\'now\',\'localtime\') WHERE bctype = \""+bctype+"\"")
77 db.execute("UPDATE chdata SET updatetime=datetime(\'now\',\'localtime\') WHERE bctype = \""+bctype+"\"")
82 db.execute("UPDATE chdata SET updatetime=datetime(\'now\',\'localtime\') WHERE bctype = \""+bctype+"\" AND chtxt = \""+chtxt+"\"")
83 #db.execute("UPDATE chdata SET updatetime=datetime(\'now\',\'localtime\') WHERE updatetime < datetime(\'now\',\'localtime\',\'-2 hours\')")
89 db=sqlite3.connect(dbpath)
90 for bctype, ontv, chtxt, ch, csch ,updatetime in db.execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata"):
91 print (bctype+","+ontv+","+chtxt+","+ch+","+csch+","+updatetime)