OSDN Git Service

improve update function.
[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 Yukikaze
5  # モジュール属性 argv を取得するため
6 import rec10d
7
8 def ontvsearch(ontvin):
9     ret=[]
10     for datum in rec10d.rec10db.select_by_ontv_chdata(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_chdata(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_chdata(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_chdata(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_chdata():
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     for datum in rec10d.rec10db.select_get_update_chdata("6"):
54         bctype=datum[0]
55         chtxt=datum[1]
56         if bctype=="cs1" or bctype==u"cs1":
57             if CSupdate==0:
58                 ret.append(u"cs1")
59                 CSupdate=1
60                 print "csの番組表取得開始"
61                 #rec10d.rec10db.update_by_bctype_chdata(bctype)
62         elif bctype=="cs2" or bctype==u"cs2":
63             if CS2update==0:
64                 ret.append(u"cs2")
65                 CS2update=1
66                 print "cs2の番組表取得開始"
67                 #rec10d.rec10db.update_by_bctype_chdata(bctype)
68         elif bctype=="bs" or bctype==u"bs":
69             if BSupdate==0:
70                 ret.append(u"bs")
71                 BSupdate=1
72                 print "bsの番組表取得開始"
73                 #rec10d.rec10db.update_by_bctype_chdata(bctype)
74         else:
75             ret.append(bctype)
76             print "取得開始"
77             #rec10d.rec10db.update_by_bctype_and_chtxt_chdata(bctype,chtxt)
78     return ret