OSDN Git Service

change function name.
[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 searchFromCHtxt(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 getChCSchFromCHtxt(chtxt):
18     ret = {'csch':chtxt.split("_")[1],'ch':chtxt.split("_")[0]}
19     return ret
20 def searchFromBctype(bctypein):
21     ret = []
22     for datum in rec10d.rec10db.select_by_bctype_epg_ch(bctypein):
23         rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}
24         ret.append(rett)
25     if len(ret) == 0:
26         ret.append(None)
27     return ret[0]
28 def searchFromCH(chin):
29     ret = []
30     for datum in rec10d.rec10db.select_by_ch_epg_ch(chin):
31         rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}
32         ret.append(rett)
33     if len(ret) == 0:
34         ret.append(None)
35     return ret[0]
36 def getAll():
37     ret = []
38     for datum in rec10d.rec10db.select_all_epg_ch():
39         rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}
40         ret.append(rett)
41     if len(ret) == 0:
42         ret.append(None)
43     return ret
44 def update():
45     ret = []
46     CSupdate = 0
47     CS2update = 0
48     BSupdate = 0
49     HUupdate = 0
50     rec10d.rec10db.set_new_status("8")
51     for datum in rec10d.rec10db.select_get_update_epg_ch("6"):
52         bctype = datum[0]
53         if bctype == "cs1" or bctype == u"cs1":
54             if CSupdate == 0:
55                 ret.append(u"cs1")
56                 CSupdate = 1
57         elif bctype == "cs2" or bctype == u"cs2":
58             if CS2update == 0:
59                 ret.append(u"cs2")
60                 CS2update = 1
61         elif bctype == "bs" or bctype == u"bs":
62             if BSupdate == 0:
63                 ret.append(u"bs")
64                 BSupdate = 1
65         elif bctype == "hu" or bctype == u"hu":
66             if HUupdate == 0:
67                 ret.append(u"hu")
68                 HUupdate = 1
69         else:
70             ret.append(bctype)
71     return ret