3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
12 path=str(os.path.dirname(os.path.abspath(__file__)))+"/"
16 tnow=datetime.datetime.now()
18 lastup=datetime.datetime.strptime(chdb.chtxtsearch(chtxt)[0]['update'],"%Y-%m-%d %H:%M:%S")
20 lastup=datetime.datetime.strptime("2009-04-01 00:00:00","%Y-%m-%d %H:%M:%S")
22 dt=dt.days*24*60+dt.seconds
24 ts2epg.write(tmppath+chtxt+"epgdate.xml",chdb.chtxtsearch(chtxt)['ch'])
25 xml2db.xml2db(tmppath+chtxt+"epgdate.xml",path+"ch.db",chdb.chtxtsearch(chtxt)['bctype'])
27 bctypel=chdb.bctypesearch(bctype)
30 ts2epg.write(tmppath+bctype+"epgdate.xml",chdb.bctypesearch(bctype)['ch'])
31 xml2db.xml2db(tmppath+bctype+"epgdate.xml",path+"ch.db",bctype)
32 except Exception,inst:
47 return rec10d.rec10db.select_by_title_tv(titletxt)
48 def searchtime2(titletxt,timet,deltatime,chtxt):
49 time=datetime.datetime.strptime(timet,"%Y-%m-%d %H:%M:%S")
51 deltatime=int(deltatime)
52 beforetime=time.strftime("%Y%m%d%H%M%S")
53 aftertime=time+datetime.timedelta(hours=deltatime)
54 aftertime=aftertime.strftime("%Y%m%d%H%M%S")
57 d=rec10d.rec10db.select_by_time_ngram_tv(beforetime,aftertime,chtxt)
59 for chtxtt, title, start, stop in d:
60 print chtxtt+":"+title+":"+start+":"+stop
62 p=n_gram.bigram(titletxt,title)
64 btime=btime[0:4]+"-"+btime[4:6]+"-"+btime[6:8]+" "+btime[8:10]+":"+btime[10:12]+":00"
66 etime=etime[0:4]+"-"+etime[4:6]+"-"+etime[6:8]+" "+etime[8:10]+":"+etime[10:12]+":00"
67 bt=datetime.datetime.strptime(btime,"%Y-%m-%d %H:%M:%S")
68 et=datetime.datetime.strptime(etime,"%Y-%m-%d %H:%M:%S")
70 dt=24*60*60*dt.days+dt.seconds+1
72 dt=1000-1000*dt/(7*24*60*60)
77 one=chtxtt+","+title.encode('utf-8')+","+btime+","+etime
80 print title+":"+str(p)+"点"