3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
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
25 ts2epg.write(tmppath+chtxt+"epgdate.xml",chdb.chtxtsearch(chtxt)['ch'])
26 xml2db.xml2db(tmppath+chtxt+"epgdate.xml",chdb.chtxtsearch(chtxt)['bctype'])
27 #def update_bak(chtxt):
29 # update epgdata by .bak file in chtxt channnel
33 bctypel=chdb.bctypesearch(bctype)
36 ts2epg.write(tmppath+bctype+"epgdate.xml",chdb.bctypesearch(bctype)['ch'])
37 xml2db.xml2db(tmppath+bctype+"epgdate.xml",bctype)
38 shutil.copyfile(tmppath+bctype+"epgdate.xml", tmppath+bctype+"epgdate.bak.xml")
39 rec10d.rec10db.update_by_bctype_chdata(bctype)
40 except Exception,inst:
43 xml2db.xml2db(tmppath+bctype+"epgdate.bak.xml",bctype)
44 def updatebc_bak(bctype):
46 update epg data by .bak file
48 xml2db.xml2db(tmppath+bctype+"epgdate.bak.xml",bctype)
71 #def search(titletxt):
72 ## return rec10d.rec10db.select_by_title_tv(titletxt)
73 def searchtime2(titletxt,timet,deltatime,chtxt):
74 time=datetime.datetime.strptime(timet,"%Y-%m-%d %H:%M:%S")
76 deltatime=int(deltatime)
77 beforetime=time.strftime("%Y%m%d%H%M%S")
78 aftertime=time+datetime.timedelta(hours=deltatime)
79 aftertime=aftertime.strftime("%Y%m%d%H%M%S")
82 d=rec10d.rec10db.select_by_time_ngram_tv(beforetime,aftertime,chtxt)
83 for chtxtt, title, start, stop in d:
84 #print chtxtt+":"+title+":"+start+":"+stop
85 p=n_gram.bigram(titletxt,title)
87 btime=btime[0:4]+"-"+btime[4:6]+"-"+btime[6:8]+" "+btime[8:10]+":"+btime[10:12]+":00"
89 etime=etime[0:4]+"-"+etime[4:6]+"-"+etime[6:8]+" "+etime[8:10]+":"+etime[10:12]+":00"
90 bt=datetime.datetime.strptime(btime,"%Y-%m-%d %H:%M:%S")
92 dt=24*60*60*dt.days+dt.seconds+1
94 dt=1000-1000*dt/(7*24*60*60)
99 one=[chtxtt,title.encode('utf-8'),btime,etime]
102 print title+":"+str(p)+"点"