OSDN Git Service

adfc07410fc1def5d76643dca0df7fb4ba25395f
[rec10/rec10-git.git] / rec10 / trunk / src / chdb.py
1 #!/usr/bin/python
2 # coding: UTF-8
3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
5     # モジュール属性 argv を取得するため
6 import rec10d
7
8 def chtxtsearch(chtxtin):
9     chtxtt=chtxtin.replace("_0","_%")
10     ret = []
11     for datum in rec10d.rec10db.select_by_chtxt_epg_ch(chtxtt):
12         rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}
13         ret.append(rett)
14     if len(ret) == 0:
15         ret.append(None)
16     return ret[0]
17 def bctypesearch(bctypein):
18     ret = []
19     for datum in rec10d.rec10db.select_by_bctype_epg_ch(bctypein):
20         rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}
21         ret.append(rett)
22     if len(ret) == 0:
23         ret.append(None)
24     return ret[0]
25 def chsearch(chin):
26     ret = []
27     for datum in rec10d.rec10db.select_by_ch_epg_ch(chin):
28         rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}
29         ret.append(rett)
30     if len(ret) == 0:
31         ret.append(None)
32     return ret[0]
33 def getall():
34     ret = []
35     for datum in rec10d.rec10db.select_all_epg_ch():
36         rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}
37         ret.append(rett)
38     if len(ret) == 0:
39         ret.append(None)
40     return ret
41 def update():
42     ret = []
43     CSupdate = 0
44     CS2update = 0
45     BSupdate = 0
46     HUupdate = 0
47     rec10d.rec10db.set_new_status("8")
48     for datum in rec10d.rec10db.select_get_update_epg_ch("6"):
49         bctype = datum[0]
50         if bctype == "cs1" or bctype == u"cs1":
51             if CSupdate == 0:
52                 ret.append(u"cs1")
53                 CSupdate = 1
54         elif bctype == "cs2" or bctype == u"cs2":
55             if CS2update == 0:
56                 ret.append(u"cs2")
57                 CS2update = 1
58         elif bctype == "bs" or bctype == u"bs":
59             if BSupdate == 0:
60                 ret.append(u"bs")
61                 BSupdate = 1
62         elif bctype == "hu" or bctype == u"hu":
63             if HUupdate == 0:
64                 ret.append(u"hu")
65                 HUupdate = 1
66         else:
67             ret.append(bctype)
68     return ret