3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
11 path=str(os.path.dirname(os.path.abspath(__file__)))+"/"
16 db=sqlite3.connect(dbpath)
18 for bctype, ontv, chtxt, ch, csch ,updatetime in db.execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata"):
20 for bctype,channel,display in db.execute("SELECT bctype,channel,display FROM ch WHERE channel=\""+ontv+"\""):
22 chopt=chopt+"<option value="+chtxt+">"+display+"</option>\n "
25 def reserv(type,keyword,chtxt,btime,etime,deltatime,opt,deltaday):
26 db=sqlite3.connect(dbpath)
27 recline="\""+type+"\",\""+chtxt+"\",\""+keyword+"\",datetime(\""+btime+"\"),datetime(\""+etime+"\"),\""+deltatime+"\",\""+opt+"\",\""+deltaday+"\""
29 db.execute('insert into rectime ("type","chtxt","title","btime","etime","deltatime","opt","deltaday") values ('+recline+')')
32 def station2chtxt(station):
33 db=sqlite3.connect(dbpath)
35 for bctype, ontv, chtxt, ch, csch ,updatetime in db.execute("SELECT bctype,ontv,chtxt,ch,csch,updatetime FROM chdata WHERE station=\""+station+"\""):
39 def readHtmlSrcSimple():
40 f = open(path+'rswi.htm')
44 def readRecFinisSimple():
45 f = open(path+'fin.htm')
58 if f.getfirst('station'):
59 station=f.getfirst('station')
60 chtxt=station2chtxt(station)
62 if f.getfirst('type'):
63 type=f.getfirst('type')
64 if f.getfirst('title'):
65 title=f.getfirst('title')
66 if f.getfirst('chtxt'):
67 chtxt=f.getfirst('chtxt')
68 if f.getfirst('btime'):
69 btime=f.getfirst('btime')
70 bt=datetime.datetime.strptime(btime,"%Y-%m-%d %H:%M:%S")
71 if f.getfirst('etime'):
72 etime=f.getfirst('etime')
73 et=datetime.datetime.strptime(etime,"%Y-%m-%d %H:%M:%S")
76 dt=delt.days*24*60+delt.seconds
78 dd=datetime.timedelta(days=1)
80 etime=et.strftime("%Y-%m-%d %H:%M:%S")
82 d1=datetime.datetime(bt.year,0,0)
83 d2=datetime.datetime(bt.year+1,0,0)
86 etime=et.strftime("%Y-%m-%d %H:%M:%S")
89 if f.getfirst('size'):
90 size=f.getfirst('size')
92 if f.getfirst('opts'):
93 opts=f.getfirst('opts')
95 if f.getfirst('deltahour',""):
96 deltahour=f.getfirst('deltahour',"")
98 if f.getfirst('deltaday',""):
99 deltaday=f.getfirst('deltaday',"")
101 if f.getfirst('exec',""):
102 exect=f.getfirst('exec',"")
104 htmdate= readHtmlSrcSimple()
105 htmdate=htmdate.replace("<!--text_for_replace_chtxt_input//-->",getchtxt())
107 htmdate=htmdate.replace("<!--btime-value//-->",btime)
108 htmdate=htmdate.replace("<!--etime-value//-->",etime)
109 htmdate=htmdate.replace("<!--type-value//-->",type)
110 htmdate=htmdate.replace("<!--ch-value//-->",chtxt)
111 htmdate=htmdate.replace("<!--title-value//-->",title)
112 htmdate=htmdate.replace("<!--size-value//-->",size)
113 htmdate=htmdate.replace("<!--opts-value//-->",opts)
115 if (chtxt != "")and(title != "")and(btime!="")and(etime!="")and(opts!="")and(exect=="yes"):
116 reserv(type, title, chtxt, btime, etime, deltahour, opts, deltaday)
117 htmdate=readRecFinisSimple()