3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
12 #japanesenkf.overrideEncodings()
13 path=str(os.path.dirname(os.path.abspath(__file__)))+"/"
17 tnow=datetime.datetime.now()
19 lastup=datetime.datetime.strptime(chdb.chtxtsearch(chtxt)[0]['update'],"%Y-%m-%d %H:%M:%S")
21 lastup=datetime.datetime.strptime("2009-04-01 00:00:00","%Y-%m-%d %H:%M:%S")
23 dt=dt.days*24*60+dt.seconds
26 ts2epg.write(tmppath+"epgdate.xml",chdb.chtxtsearch(chtxt)['ch'])
27 xml2db.xml2db(tmppath+"epgdate.xml",path+"ch.db",chdb.chtxtsearch(chtxt)['bctype'])
28 #os.remove(path+"epgdate.xml")
31 #tnow=datetime.datetime.now()
32 bctypel=chdb.bctypesearch(bctype)
34 ts2epg.write(tmppath+"epgdate.xml",chdb.bctypesearch(bctype)['ch'])
35 xml2db.xml2db(tmppath+"epgdate.xml",path+"ch.db",bctype)
36 #os.remove(path+"epgdate.xml")
50 db=sqlite3.connect(dbpath)
53 for ch, title, start, stop in db.execute("SELECT channel,title,start,stop FROM tv WHERE title LIKE \"%"+titletxt+"%\""):
54 btime=start.replace(" +0900","")
55 btime=btime[0:4]+"-"+btime[4:6]+"-"+btime[6:8]+" "+btime[8:10]+":"+btime[10:12]+":00"
56 etime=stop.replace(" +0900","")
57 etime=etime[0:4]+"-"+etime[4:6]+"-"+etime[6:8]+" "+etime[8:10]+":"+etime[10:12]+":00"
59 chtxt=chdb.ontvsearch(ch)['chtxt']
63 ret.append(chtxt+","+title.encode('utf-8')+","+btime+","+etime)
65 #r=db.execute("SELECT * FROM tv")
72 def searchtime(titletxt,time,deltatime):#時間以内のものだけを表示 deltatimeはhours
74 db=sqlite3.connect(dbpath)
77 deltatime=int(deltatime)
78 for ch, title, start, stop in db.execute("SELECT channel,title,start,stop FROM tv WHERE title LIKE \"%"+titletxt+"%\""):
79 btime=start.replace(" +0900","")
80 btime=btime[0:4]+"-"+btime[4:6]+"-"+btime[6:8]+" "+btime[8:10]+":"+btime[10:12]+":00"
81 etime=stop.replace(" +0900","")
82 etime=etime[0:4]+"-"+etime[4:6]+"-"+etime[6:8]+" "+etime[8:10]+":"+etime[10:12]+":00"
83 bt=datetime.datetime.strptime(btime,"%Y-%m-%d %H:%M:%S")
84 t=datetime.datetime.strptime(time,"%Y-%m-%d %H:%M:%S")
86 chtxt=chdb.ontvsearch(ch)['chtxt']
91 dt=dt.days*24*60*60+dt.seconds
93 if dt<deltatime*60*60:
94 ret.append(chtxt+","+title.encode('utf-8')+","+btime+","+etime)
96 #r=db.execute("SELECT * FROM tv")