OSDN Git Service

fix epg updating.
[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 ontvsearch(ontvin):
9     ret = []
10     for datum in rec10d.rec10db.select_by_ontv_epg_ch(ontvin):
11         rett = {'bctype':datum[0], 'ontv':datum[1], 'chtxt':datum[2], 'ch':datum[3], 'csch':datum[4], 'update':datum[5]}
12         ret.append(rett)
13     if len(ret) == 0:
14         ret.append(None)
15     return ret[0]
16 def chtxtsearch(chtxtin):
17     ret = []
18     for datum in rec10d.rec10db.select_by_chtxt_epg_ch(chtxtin):
19         rett = {'bctype':datum[0], 'ontv':datum[1], 'chtxt':datum[2], 'ch':datum[3], 'csch':datum[4], 'update':datum[5]}
20         ret.append(rett)
21     if len(ret) == 0:
22         ret.append(None)
23     return ret[0]
24 def bctypesearch(bctypein):
25     ret = []
26     for datum in rec10d.rec10db.select_by_bctype_epg_ch(bctypein):
27         rett = {'bctype':datum[0], 'ontv':datum[1], 'chtxt':datum[2], 'ch':datum[3], 'csch':datum[4], 'update':datum[5]}
28         ret.append(rett)
29     if len(ret) == 0:
30         ret.append(None)
31     return ret[0]
32 def chsearch(chin):
33     ret = []
34     for datum in rec10d.rec10db.select_by_ch_epg_ch(chin):
35         rett = {'bctype':datum[0], 'ontv':datum[1], 'chtxt':datum[2], 'ch':datum[3], 'csch':datum[4], 'update':datum[5]}
36         ret.append(rett)
37     if len(ret) == 0:
38         ret.append(None)
39     return ret[0]
40 def getall():
41     ret = []
42     for datum in rec10d.rec10db.select_all_epg_ch():
43         rett = {'bctype':datum[0], 'ontv':datum[1], 'chtxt':datum[2], 'ch':datum[3], 'csch':datum[4], 'update':datum[5]}
44         ret.append(rett)
45     if len(ret) == 0:
46         ret.append(None)
47     return ret[0]
48 def update():
49     ret = []
50     CSupdate = 0
51     CS2update = 0
52     BSupdate = 0
53     rec10d.rec10db.set_new_status("8")
54     for datum in rec10d.rec10db.select_get_update_epg_ch("6"):
55         bctype = datum[0]
56         if bctype == "cs1" or bctype == u"cs1":
57             if CSupdate == 0:
58                 ret.append(u"cs1")
59                 CSupdate = 1
60         elif bctype == "cs2" or bctype == u"cs2":
61             if CS2update == 0:
62                 ret.append(u"cs2")
63                 CS2update = 1
64         elif bctype == "bs" or bctype == u"bs":
65             if BSupdate == 0:
66                 ret.append(u"bs")
67                 BSupdate = 1
68         else:
69             ret.append(bctype)
70     return ret