3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
8 dbpath=str(os.path.dirname(os.path.abspath(__file__)))+"/"+"ch.db"
9 db=sqlite3.connect(dbpath)
13 global REC_FINAL_RESERVE
14 REC_FINAL_RESERVE="rec"
20 REC_ENCODE_QUE="ts2avi"
21 global REC_MIXING_SOUND
22 REC_MIXING_SOUND="mixsound"
23 global REC_MISS_ENCODE
24 REC_MISS_ENCODE="miss"
27 global REC_KEYWORD_EVERY_SOME_DAYS
28 REC_KEYWORD_EVERY_SOME_DAYS="keyevery"
30 REC_FIN_DECODE="tsfin"
31 global REC_MISS_DECODE
32 REC_MISS_DECODE="tsmiss"
33 global REC_TS_DECODING
34 REC_TS_DECODING="tsdecoding"
36 db.execute('create table rectime (type TEXT,chtxt TEXT,title TEXT,btime TEXT,etime TEXT,deltatime TEXT,deltaday TEXT,opt TEXT,id INTEGER PRIMARY KEY,UNIQUE(type,chtxt,title,btime,deltaday))')
38 #print "テーブル作成に失敗しました"
41 def recreserv(title,chtxt,btime,etime,opt):#optにはa(アニメ)d(副音声)v(xvid)
42 rec_reckey("res",title,chtxt,btime,etime,opt)
43 def keyreserv(keyword,chtxt,btime,etime,deltatime,opt):
44 db=sqlite3.connect(dbpath)
45 recline="\""+recdb.REC_KEYWORD+"\",\""+chtxt+"\",\""+keyword+"\",datetime(\""+btime+"\"),datetime(\""+etime+"\"),\""+deltatime+"\",\""+opt+"\""
46 db.execute('insert into rectime ("type","chtxt","title","btime","etime","deltatime","opt") values ('+recline+')')
49 def everyreserv(keyword,chtxt,btime,etime,deltatime,opt,deltaday):
50 db=sqlite3.connect(dbpath)
51 recline="\""+recdb.REC_KEYWORD_EVERY_SOME_DAYS+"\",\""+chtxt+"\",\""+keyword+"\",datetime(\""+btime+"\"),datetime(\""+etime+"\"),\""+deltatime+"\",\""+opt+"\",\""+deltaday+"\""
52 db.execute('insert into rectime ("type","chtxt","title","btime","etime","deltatime","opt","deltaday") values ('+recline+')')
55 def lastrecreserv(title,chtxt,btime,etime,opt):#optにはa(アニメ)d(副音声)v(xvid)##btimeなどは2006-07-17 13:25:23の形
57 Caution this is old function and you should not use it.
58 Please use rec_reckey(recdb.REC_FINAL_RESERVE,title,chtxt,btime,etime,opt) instead of lastrecreserv(title,chtxt,btime,etime,opt)
60 rec_reckey(recdb.REC_FINAL_RESERVE,title,chtxt,btime,etime,opt)
61 def misrecwrite(title,chtxt,btime,etime,opt):
64 Caution this is old function and you should not use it.
65 Please use rec_reckey(recdb.REC_MISS_ENCODE,title,chtxt,btime,etime,opt) instead.
67 rec_reckey(recdb.REC_MISS_ENCODE,title,chtxt,btime,etime,opt)
68 def recend(title,chtxt,btime,etime,opt):#optにはa(アニメ)d(副音声)v(xvid)
70 Caution this is old function and you should not use it.
71 Please use rec_reckey(recdb.REC_END,title,chtxt,btime,etime,opt) instead.
73 rec_reckey(recdb.REC_END,title,chtxt,btime,etime,opt)
74 def rec_reckey(type,title,chtxt,btime,etime,opt):
75 db=sqlite3.connect(dbpath)
76 recline="\""+type+"\",\""+chtxt+"\",\""+title+"\",datetime(\""+btime+"\"),datetime(\""+etime+"\"),\""+opt+"\""
77 db.execute('insert into rectime ("type","chtxt","title","btime","etime","opt") values ('+recline+')')
80 def delrec(title,chtxt,btime):
82 Caution this is old function and you should not use it.
83 Please use del_reckey(recdb.REC_RESERVE,title,chtxt,btime) instead.
85 del_reckey(recdb.REC_RESERVE,title,chtxt,btime)
86 def delkey(keyword,chtxt,btime,deltatime):
88 Caution this is old function and you should not use it.
89 Please use del_reckey(recdb.REC_FINAL_RESERVE,keyword,chtxt,btime) instead.
91 del_reckey(recdb.REC_KEYWORD,keyword,chtxt,btime)
92 def dellastrec(title,chtxt,btime):
94 Caution this is old function and you should not use it.
95 Please use del_reckey(recdb.REC_FINAL_RESERVE,title,chtxt,btime) instead.
97 del_reckey(recdb.REC_FINAL_RESERVE,title,chtxt,btime)
98 def delevery(keyword,chtxt,btime,deltatime,deltaday):
100 Caution this is old function and you should not use it.
101 Please use del_reckey(recdb.REC_FINAL_RESERVE,keyword,chtxt,btime) instead.
103 del_reckey(recdb.REC_KEYWORD_EVERY_SOME_DAYS,keyword,chtxt,btime)
104 def delend(title,chtxt,btime):
106 Caution this is old function and you should not use it.
107 Please use del_reckey(recdb.REC_END,title,chtxt,btime) instead.
109 del_reckey(recdb.REC_END,title,chtxt,btime)
111 db=sqlite3.connect(dbpath)
113 for title in db.execute("SELECT title FROM rectime WHERE title like \"%"+key+"%\""):
116 db.execute("delete from rectime where title like \'%"+key+"%\'")
119 def del_reckey(type,title,chtxt,btime):
120 db=sqlite3.connect(dbpath)
121 db.execute("delete from rectime where type = \'"+type+"\' AND title = \'"+title+"\' AND chtxt = \'"+chtxt+"\' AND btime = datetime(\""+btime+"\")")
125 db=sqlite3.connect(dbpath)
127 for typet, chtxt, title, btime, etime, deltatime ,deltaday ,opt in db.execute("SELECT type, chtxt, title, DATETIME(btime), DATETIME(etime), deltatime ,deltaday ,opt FROM rectime WHERE btime < datetime(\'now\',\'localtime\',\'+"+dhour+" hours\') AND btime >datetime(\'now\',\'localtime\',\'-"+dhour+" hours\')"):
131 ret['title']=title.encode('utf-8')
136 ret['deltatime']=deltatime
137 elif typet=='keyevery':
138 ret['deltatime']=deltatime
139 ret['deltaday']=deltaday
144 def delete_old(dhour):
146 delete keys except recdb.REC_MISS_ENCODE and recdb.REC_KEYWORD_EVERY_SOME_DAYS before dhour hours from now.
148 db=sqlite3.connect(dbpath)
149 db.execute("DELETE FROM rectime WHERE NOT ( type = \""+recdb.REC_MISS_ENCODE+"\" OR type = \""+recdb.REC_KEYWORD_EVERY_SOME_DAYS+"\" ) AND btime < datetime(\'now\',\'localtime\',\'-"+dhour+" hours\')")
153 db=sqlite3.connect(dbpath)
155 for typet, chtxt, title, btime, etime, deltatime ,deltaday ,opt in db.execute("SELECT type, chtxt, title, btime, etime, deltatime ,deltaday ,opt FROM rectime"):
159 ret['title']=title.encode('utf-8')
164 ret['deltatime']=deltatime
165 elif typet=='keyevery':
166 ret['deltatime']=deltatime
167 ret['deltaday']=deltaday