3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
11 path=str(os.path.dirname(os.path.abspath(__file__)))+"/"
15 db=sqlite3.connect(dbpath)
17 for bctype, ontv, chtxt, ch, csch ,updatetime in db.execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata"):
19 for bctype,channel,display in db.execute("SELECT bctype,channel,display FROM ch WHERE channel=\""+ontv+"\""):
21 chopt=chopt+"<option value="+chtxt+">"+display+"</option>\n "
24 def reserv(type,keyword,chtxt,btime,etime,deltatime,opt,deltaday):
27 db=sqlite3.connect(dbpath)
30 dbexe="SELECT chdata.bctype,rectime.chtxt,rectime.title FROM rectime INNER JOIN chdata ON rectime.chtxt=chdata.chtxt"
31 #dbexe="SELECT bctype,chtxt,title FROM rectime INNER JOIN chdata ON rectime.chtxt=chdata.chtxt"
33 dbexe=dbexe+" WHERE NOT( ( rectime.etime <= "+bt+" ) OR ( rectime.btime >= "+et+" ) )"
34 for bctypet, chtxtt, titlet in db.execute(dbexe):
35 if bctypet.find("cs")>-1:
37 elif bctypet.find("bs")>-1:
39 elif bctypet.find("te")>-1:
43 for bctypet, chtxtt in db.execute("SELECT bctype,chtxt FROM chdata WHERE chtxt=\'"+chtxt+"\'"):
45 if bctype.find("cs")>-1:
47 elif bctype.find("bs")>-1:
49 elif bctype.find("te")>-1:
51 if MaxS>-1 and MaxT>-1:
52 recline="\""+type+"\",\""+chtxt+"\",\""+keyword+"\",datetime(\""+btime+"\"),datetime(\""+etime+"\"),\""+deltatime+"\",\""+opt+"\",\""+deltaday+"\""
54 db.execute('insert into rectime ("type","chtxt","title","btime","etime","deltatime","opt","deltaday") values ('+recline+')')
60 def station2chtxt(station):
61 db=sqlite3.connect(dbpath)
63 for bctype, ontv, chtxt, ch, csch ,updatetime in db.execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE station=\""+station+"\""):
67 def readHtmlSrcSimple():
68 f = open(path+'rswi.htm')
73 def readRecFinisSimple():
74 f = open(path+'fin.htm')
78 def readRecFinisOver():
79 f = open(path+'finover.htm')
92 if f.getfirst('station'):
93 station=f.getfirst('station')
94 chtxt=station2chtxt(station)
96 if f.getfirst('type'):
97 type=f.getfirst('type')
98 if f.getfirst('title'):
99 title=f.getfirst('title')
100 if f.getfirst('chtxt'):
101 chtxt=f.getfirst('chtxt')
102 if f.getfirst('btime'):
103 btime=f.getfirst('btime')
104 bt=datetime.datetime.strptime(btime,"%Y-%m-%d %H:%M:%S")
105 if f.getfirst('etime'):
106 etime=f.getfirst('etime')
107 et=datetime.datetime.strptime(etime,"%Y-%m-%d %H:%M:%S")
110 dt=delt.days*24*60*60+delt.seconds
112 dd=datetime.timedelta(days=1)
114 etime=et.strftime("%Y-%m-%d %H:%M:%S")
116 d1=datetime.datetime(bt.year,0,0)
117 d2=datetime.datetime(bt.year+1,0,0)
120 etime=et.strftime("%Y-%m-%d %H:%M:%S")
123 if f.getfirst('size'):
124 size=f.getfirst('size')
126 if f.getfirst('opts'):
127 opts=f.getfirst('opts')
129 if f.getfirst('deltahour',""):
130 deltahour=f.getfirst('deltahour',"")
132 if f.getfirst('deltaday',""):
133 deltaday=f.getfirst('deltaday',"")
135 if f.getfirst('exec',""):
136 exect=f.getfirst('exec',"")
138 htmdate= readHtmlSrcSimple()
139 htmdate=htmdate.replace("<!--text_for_replace_chtxt_input//-->",getchtxt())
141 htmdate=htmdate.replace("<!--btime-value//-->",btime)
142 htmdate=htmdate.replace("<!--etime-value//-->",etime)
143 htmdate=htmdate.replace("<!--type-value//-->",type)
144 htmdate=htmdate.replace("<!--ch-value//-->",chtxt)
145 htmdate=htmdate.replace("<!--title-value//-->",title)
146 htmdate=htmdate.replace("<!--size-value//-->",size)
147 htmdate=htmdate.replace("<!--opts-value//-->",opts)
149 if (chtxt != "")and(title != "")and(btime!="")and(etime!="")and(opts!="")and(exect=="yes"):
150 restxt=reserv(type, title, chtxt, btime, etime, deltahour, opts, deltaday)
152 htmdate=readRecFinisSimple()
154 htmdate=readRecFinisOver()