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)
15 global REC_FINAL_RESERVE
17 global REC_ENCODE_GRID
18 global REC_ENCODE_LOCAL
20 global REC_MIXING_SOUND
21 global REC_MISS_ENCODE
23 global REC_KEYWORD_EVERY_SOME_DAYS
26 global REC_MISS_DECODE
27 global REC_TS_DECODING
28 global REC_TS_RECORDING
30 REC_FINAL_RESERVE="rec"
32 REC_ENCODE_GRID="grid"
33 REC_ENCODE_LOCAL="local"
34 REC_ENCODE_QUE="ts2avi"
35 REC_MIXING_SOUND="mixsound"
36 REC_MISS_ENCODE="miss"
38 REC_KEYWORD_EVERY_SOME_DAYS="keyevery"
39 REC_FIN_DECODE="tsfin"
40 REC_FIN_LOCAL="fin_local"
41 REC_MISS_DECODE="tsmiss"
42 REC_TS_DECODING="tsdecoding"
43 REC_TS_RECORDING="tsrecording"
46 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))')
48 #print "テーブル作成に失敗しました"
51 def recreserv(title,chtxt,btime,etime,opt):#optにはa(アニメ)d(副音声)v(xvid)
52 rec_reckey("res",title,chtxt,btime,etime,opt)
53 def keyreserv(keyword,chtxt,btime,etime,deltatime,opt):
54 db=sqlite3.connect(dbpath)
55 recline="\""+recdb.REC_KEYWORD+"\",\""+chtxt+"\",\""+keyword+"\",datetime(\""+btime+"\"),datetime(\""+etime+"\"),\""+deltatime+"\",\""+opt+"\""
56 db.execute('insert into rectime ("type","chtxt","title","btime","etime","deltatime","opt") values ('+recline+')')
59 def everyreserv(keyword,chtxt,btime,etime,deltatime,opt,deltaday):
60 db=sqlite3.connect(dbpath)
61 recline="\""+recdb.REC_KEYWORD_EVERY_SOME_DAYS+"\",\""+chtxt+"\",\""+keyword+"\",datetime(\""+btime+"\"),datetime(\""+etime+"\"),\""+deltatime+"\",\""+opt+"\",\""+deltaday+"\""
62 db.execute('insert into rectime ("type","chtxt","title","btime","etime","deltatime","opt","deltaday") values ('+recline+')')
65 def lastrecreserv(title,chtxt,btime,etime,opt):#optにはa(アニメ)d(副音声)v(xvid)##btimeなどは2006-07-17 13:25:23の形
67 Caution this is old function and you should not use it.
68 Please use rec_reckey(recdb.REC_FINAL_RESERVE,title,chtxt,btime,etime,opt) instead of lastrecreserv(title,chtxt,btime,etime,opt)
70 rec_reckey(recdb.REC_FINAL_RESERVE,title,chtxt,btime,etime,opt)
71 def misrecwrite(title,chtxt,btime,etime,opt):
74 Caution this is old function and you should not use it.
75 Please use rec_reckey(recdb.REC_MISS_ENCODE,title,chtxt,btime,etime,opt) instead.
77 rec_reckey(recdb.REC_MISS_ENCODE,title,chtxt,btime,etime,opt)
78 def recend(title,chtxt,btime,etime,opt):#optにはa(アニメ)d(副音声)v(xvid)
80 Caution this is old function and you should not use it.
81 Please use rec_reckey(recdb.REC_END,title,chtxt,btime,etime,opt) instead.
83 rec_reckey(recdb.REC_END,title,chtxt,btime,etime,opt)
84 def rec_reckey(type,title,chtxt,btime,etime,opt):
85 db=sqlite3.connect(dbpath)
86 recline="\""+type+"\",\""+chtxt+"\",\""+title+"\",datetime(\""+btime+"\"),datetime(\""+etime+"\"),\""+opt+"\""
87 db.execute('insert into rectime ("type","chtxt","title","btime","etime","opt") values ('+recline+')')
90 def delrec(title,chtxt,btime):
92 Caution this is old function and you should not use it.
93 Please use del_reckey(recdb.REC_RESERVE,title,chtxt,btime) instead.
95 del_reckey(recdb.REC_RESERVE,title,chtxt,btime)
96 def delkey(keyword,chtxt,btime,deltatime):
98 Caution this is old function and you should not use it.
99 Please use del_reckey(recdb.REC_FINAL_RESERVE,keyword,chtxt,btime) instead.
101 del_reckey(recdb.REC_KEYWORD,keyword,chtxt,btime)
102 def dellastrec(title,chtxt,btime):
104 Caution this is old function and you should not use it.
105 Please use del_reckey(recdb.REC_FINAL_RESERVE,title,chtxt,btime) instead.
107 del_reckey(recdb.REC_FINAL_RESERVE,title,chtxt,btime)
108 def delevery(keyword,chtxt,btime,deltatime,deltaday):
110 Caution this is old function and you should not use it.
111 Please use del_reckey(recdb.REC_FINAL_RESERVE,keyword,chtxt,btime) instead.
113 del_reckey(recdb.REC_KEYWORD_EVERY_SOME_DAYS,keyword,chtxt,btime)
114 def delend(title,chtxt,btime):
116 Caution this is old function and you should not use it.
117 Please use del_reckey(recdb.REC_END,title,chtxt,btime) instead.
119 del_reckey(recdb.REC_END,title,chtxt,btime)
121 db=sqlite3.connect(dbpath)
123 for title in db.execute("SELECT title FROM rectime WHERE title like \"%"+key+"%\""):
126 db.execute("delete from rectime where title like \'%"+key+"%\'")
129 def del_reckey(type,title,chtxt,btime):
130 db=sqlite3.connect(dbpath)
131 db.execute("delete from rectime where type = \'"+type+"\' AND title = \'"+title+"\' AND chtxt = \'"+chtxt+"\' AND btime = datetime(\""+btime+"\")")
135 db=sqlite3.connect(dbpath)
137 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\')"):
141 ret['title']=title.encode('utf-8')
145 if deltatime==None or deltatime=="":
147 if deltaday==None or deltaday=="":
150 ret['deltatime']=deltatime
151 elif typet=='keyevery':
152 ret['deltatime']=deltatime
153 ret['deltaday']=deltaday
158 def countRecNow(dhour):
163 if t=="key" or t=="keyevery" or t=="rec" or t=="ret":
166 def delete_old(dhour):
168 delete keys except recdb.REC_MISS_ENCODE and recdb.REC_KEYWORD_EVERY_SOME_DAYS before dhour hours from now.
170 db=sqlite3.connect(dbpath)
171 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\')")
175 db=sqlite3.connect(dbpath)
177 for typet, chtxt, title, btime, etime, deltatime ,deltaday ,opt in db.execute("SELECT type, chtxt, title, btime, etime, deltatime ,deltaday ,opt FROM rectime"):
181 ret['title']=title.encode('utf-8')
190 ret['deltatime']=deltatime
191 elif typet=='keyevery':
192 ret['deltatime']=deltatime
193 ret['deltaday']=deltaday