OSDN Git Service

epg-longexp fuction added.
[rec10/rec10-git.git] / rec10 / trunk / src / recdb.py
1 #!/usr/bin/python
2 # coding: UTF-8
3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
5 import chdb
6 import rec10d
7 import recdb
8 """
9 task names
10 """
11 global REC_RESERVE
12 global REC_FINAL_RESERVE
13 global REC_END
14 global REC_ENCODE_GRID
15 global REC_ENCODE_LOCAL
16 global REC_ENCODE_QUE
17 global REC_MIXING_SOUND
18 global REC_MISS_ENCODE
19 global REC_KEYWORD
20 global REC_KEYWORD_EVERY_SOME_DAYS
21 global REC_FIN_DECODE
22 global REC_FIN_LOCAL
23 global REC_MISS_DECODE
24 global REC_TS_DECODE_QUE
25 global REC_TS_DECODING
26 global REC_TS_RECORDING
27 global REC_AVI_TO_MKV
28 global REC_AVI_TO_MP4
29 global REC_MKV_TO_MP4
30 global REC_CHANGING_CANTAINER
31 global REC_AUTO_SUGGEST
32 global REC_BAYES_SUGGEST
33 global REC_AUTO_KEYWORD
34 REC_RESERVE = "res"
35 REC_FINAL_RESERVE = "rec"
36 REC_END = "end"
37 REC_ENCODE_GRID = "grid"
38 REC_ENCODE_LOCAL = "local"
39 REC_ENCODE_QUE = "ts2avi"
40 REC_MIXING_SOUND = "mixsound"
41 REC_MISS_ENCODE = "miss"
42 REC_KEYWORD = "key"
43 REC_KEYWORD_EVERY_SOME_DAYS = "keyevery"
44 REC_FIN_DECODE = "tsfin"
45 REC_FIN_LOCAL = "fin_local"
46 REC_MISS_DECODE = "tsmiss"
47 REC_TS_DECODE_QUE = "b252ts"
48 REC_TS_DECODING = "tsdecoding"
49 REC_TS_RECORDING = "tsrecording"
50 REC_CHANGING_CANTAINER = "changingcontainer"
51 REC_AVI_TO_MKV = "avi2mkv"
52 REC_AVI_TO_MP4 = "avi2mp4"
53 REC_MKV_TO_MP4 = "mkv2mp4"
54 REC_AUTO_SUGGEST = "auto_suggest"
55 REC_AUTO_KEYWORD = "auto_keyword"
56 REC_BAYES_SUGGEST ="bayes_suggest"
57 def recreserv(title, chtxt, btime, etime, opt):#optにはa(アニメ)d(副音声)v(xvid)
58     rec_reckey("res", title, chtxt, btime, etime, opt)
59 def auto_keyreserv(keyword, chtxt, btime, etime, deltatime, opt):
60     rec10d.rec10db.add_rectime(type=recdb.REC_AUTO_KEYWORD, chtxt=chtxt, title=keyword, btime=btime, etime=etime, deltatime=deltatime, opt=opt)
61 def keyreserv(keyword, chtxt, btime, etime, deltatime, opt):
62     rec10d.rec10db.add_rectime(type=recdb.REC_KEYWORD, chtxt=chtxt, title=keyword, btime=btime, etime=etime, deltatime=deltatime, opt=opt)
63 def everyreserv(keyword, chtxt, btime, etime, deltatime, opt, deltaday):
64     rec10d.rec10db.add_rectime(type=recdb.REC_KEYWORD_EVERY_SOME_DAYS, chtxt=chtxt, title=keyword, btime=btime, etime=etime, deltatime=deltatime, opt=opt, deltaday=deltaday)
65 def rec_reckey(type, title, chtxt, btime, etime, opt):
66     rec10d.rec10db.add_rectime(type=type, chtxt=chtxt, title=title, btime=btime, etime=etime, opt=opt)
67 def del_reckey(type, title, chtxt, btime):
68     rec10d.rec10db.del_rectime(type=type, title=title, chtxt=chtxt, btime=btime)
69 def getnow(dhour):
70     dhour = int(dhour)
71     dminutes = 60 * dhour
72     dminutes = str(dminutes)
73     return rec10d.rec10db.select_bytime_rectime(dminutes)
74 def getnow_minutes(dminutes):
75     return rec10d.rec10db.select_bytime_rectime(dminutes)
76 def countRecNow(dhour):
77     d = getnow(dhour)
78     ret = 0
79     for i in d:
80         t = i['type']
81         if t == "key" or t == "keyevery" or t == "rec" or t == "res":
82             ret = ret + 1
83     return ret
84 def countRecNow_minutes(dminutes):
85     d = getnow_minutes(dminutes)
86     ret = 0
87     for i in d:
88         t = i['type']
89         if t == "key" or t == "keyevery" or t == "rec" or t == "res":
90             ret = ret + 1
91     return ret
92 def countRecNow_minutes_BSCS(dminutes):
93     d = getnow_minutes(dminutes)
94     ret = 0
95     for i in d:
96         t = i['type']
97         if t == "key" or t == "keyevery" or t == "rec" or t == "res":
98             if len(chdb.chtxtsearch(i['chtxt'])['ch']) > 2:
99                 ret = ret + 1
100     return ret
101 def countRecNow_minutes_TE(dminutes):
102     d = getnow_minutes(dminutes)
103     ret = 0
104     for i in d:
105         t = i['type']
106         if t == "key" or t == "keyevery" or t == "rec" or t == "res":
107             if len(chdb.chtxtsearch(i['chtxt'])['ch']) < 3:
108                 ret = ret + 1
109     return ret
110 def delete_old(dhour):
111     """
112     delete keys except recdb.REC_MISS_ENCODE and recdb.REC_KEYWORD_EVERY_SOME_DAYS before dhour hours from now.
113     """
114     rec10d.rec10db.delete_old_rectime(dhour)
115 def getall():
116     return rec10d.rec10db.select_all_rectime()
117 def rec_reclog(title,chtxt,btime,etime,opt,exp,longexp,category):
118     rec10d.rec10db.add_reclog(chtxt,title,btime,etime,opt,exp,longexp,category)
119 def get_key():
120     return rec10d.rec10db.select_all_recjbk()