4 # Rec10 TS Recording Tools
5 # 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="keyevery"
30 REC_FIN_DECODE="tsfin"
31 global REC_MISS_DECODE
32 REC_MISS_DECODE="tsmiss"
33 global REC_TS_DECODING
34 REC_MISS_DECODE="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 "テーブル作成に失敗しました"
42 def recreserv(title,chtxt,btime,etime,opt):#optにはa(アニメ)d(副音声)v(xvid)
43 rec_reckey("res",title,chtxt,btime,etime,opt)
44 def keyreserv(keyword,chtxt,btime,etime,deltatime,opt):
45 db=sqlite3.connect(dbpath)
46 recline="\""+recdb.REC_KEYWORD+"\",\""+chtxt+"\",\""+keyword+"\",datetime(\""+btime+"\"),datetime(\""+etime+"\"),\""+deltatime+"\",\""+opt+"\""
47 db.execute('insert into rectime ("type","chtxt","title","btime","etime","deltatime","opt") values ('+recline+')')
50 def everyreserv(keyword,chtxt,btime,etime,deltatime,opt,deltaday):
51 db=sqlite3.connect(dbpath)
52 recline="\""+recdb.REC_KEYWORD_EVERY_SOME_DAYS+"\",\""+chtxt+"\",\""+keyword+"\",datetime(\""+btime+"\"),datetime(\""+etime+"\"),\""+deltatime+"\",\""+opt+"\",\""+deltaday+"\""
53 db.execute('insert into rectime ("type","chtxt","title","btime","etime","deltatime","opt","deltaday") values ('+recline+')')
56 def lastrecreserv(title,chtxt,btime,etime,opt):#optにはa(アニメ)d(副音声)v(xvid)##btimeなどは2006-07-17 13:25:23の形
58 Caution this is old function and you should not use it.
59 Please use rec_reckey(recdb.REC_FINAL_RESERVE,title,chtxt,btime,etime,opt) instead of lastrecreserv(title,chtxt,btime,etime,opt)
61 rec_reckey(recdb.REC_FINAL_RESERVE,title,chtxt,btime,etime,opt)
62 def misrecwrite(title,chtxt,btime,etime,opt):
65 Caution this is old function and you should not use it.
66 Please use rec_reckey(recdb.REC_MISS_ENCODE,title,chtxt,btime,etime,opt) instead.
68 rec_reckey(recdb.REC_MISS_ENCODE,title,chtxt,btime,etime,opt)
69 def recend(title,chtxt,btime,etime,opt):#optにはa(アニメ)d(副音声)v(xvid)
71 Caution this is old function and you should not use it.
72 Please use rec_reckey(recdb.REC_END,title,chtxt,btime,etime,opt) instead.
74 rec_reckey(recdb.REC_END,title,chtxt,btime,etime,opt)
75 def rec_reckey(type,title,chtxt,btime,etime,opt):
76 db=sqlite3.connect(dbpath)
77 recline="\""+type+"\",\""+chtxt+"\",\""+title+"\",datetime(\""+btime+"\"),datetime(\""+etime+"\"),\""+opt+"\""
78 db.execute('insert into rectime ("type","chtxt","title","btime","etime","opt") values ('+recline+')')
81 def delrec(title,chtxt,btime):
83 Caution this is old function and you should not use it.
84 Please use del_reckey(recdb.REC_RESERVE,title,chtxt,btime) instead.
86 del_reckey(recdb.REC_RESERVE,title,chtxt,btime)
87 def delkey(keyword,chtxt,btime,deltatime):
89 Caution this is old function and you should not use it.
90 Please use del_reckey(recdb.REC_FINAL_RESERVE,keyword,chtxt,btime) instead.
92 del_reckey(recdb.REC_KEYWORD,keyword,chtxt,btime)
93 def dellastrec(title,chtxt,btime):
95 Caution this is old function and you should not use it.
96 Please use del_reckey(recdb.REC_FINAL_RESERVE,title,chtxt,btime) instead.
98 del_reckey(recdb.REC_FINAL_RESERVE,title,chtxt,btime)
99 def delevery(keyword,chtxt,btime,deltatime,deltaday):
101 Caution this is old function and you should not use it.
102 Please use del_reckey(recdb.REC_FINAL_RESERVE,keyword,chtxt,btime) instead.
104 del_reckey(recdb.REC_KEYWORD_EVERY_SOME_DAYS,keyword,chtxt,btime)
105 def delend(title,chtxt,btime):
107 Caution this is old function and you should not use it.
108 Please use del_reckey(recdb.REC_END,title,chtxt,btime) instead.
110 del_reckey(recdb.REC_END,title,chtxt,btime)
112 db=sqlite3.connect(dbpath)
114 for title in db.execute("SELECT title FROM rectime WHERE title like \"%"+key+"%\""):
117 db.execute("delete from rectime where title like \'%"+key+"%\'")
120 def del_reckey(type,title,chtxt,btime):
121 db=sqlite3.connect(dbpath)
122 db.execute("delete from rectime where type = \'"+type+"\' AND title = \'"+title+"\' AND chtxt = \'"+chtxt+"\' AND btime = datetime(\""+btime+"\")")
126 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