3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
16 path = str(os.path.dirname(os.path.abspath(__file__))) + "/"
17 tmppath = configreader.getpath("tmp")+"/"
21 recdblist.printutf8(chtxt)
22 tnow = datetime.datetime.now()
24 lastup = datetime.datetime.strptime(chdb.chtxtsearch(chtxt)[0]['update'], "%Y-%m-%d %H:%M:%S")
26 lastup = datetime.datetime.strptime("2009-04-01 00:00:00", "%Y-%m-%d %H:%M:%S")
28 dt = dt.days * 24 * 60 + dt.seconds
30 ts2epg.write(tmppath + chtxt + "epgdata.xml", chdb.chtxtsearch(chtxt)['ch'])
31 xml2db.xml2db(tmppath + chtxt + "epgdata.xml", chdb.chtxtsearch(chtxt)['bctype'])
33 bctypel = chdb.bctypesearch(bctype)
36 ts2epg.write(tmppath + bctype + "epgdata.xml", chdb.bctypesearch(bctype)['ch'])
37 xml2db.xml2db(tmppath + bctype + "epgdata.xml", bctype)
38 shutil.copyfile(tmppath + bctype + "epgdata.xml", tmppath + bctype + "epgdata.bak.xml")
39 rec10d.rec10db.update_by_bctype_epg_ch(bctype)
40 except Exception, inst:
41 print "error occurs in updatebc(epgdb)"
44 xml2db.xml2db(tmppath + bctype + "epgdata.bak.xml", bctype)
45 rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "2")
46 def updatebc_bak(bctype):
48 update epg data by .bak file
50 xml2db.xml2db(tmppath + bctype + "epgdata.bak.xml", bctype)
51 def searchtime2(titletxt, timet, deltatime, chtxt):
52 time = datetime.datetime.strptime(timet, "%Y-%m-%d %H:%M:%S")
54 deltatime = int(deltatime)
55 beforetime = time.strftime("%Y%m%d%H%M%S")
56 aftertime = time + datetime.timedelta(hours=deltatime)
57 aftertime = aftertime.strftime("%Y%m%d%H%M%S")
58 one = ["", "", "", ""]
60 d = rec10d.rec10db.select_by_time_ngram_epg_timeline(beforetime, aftertime, chtxt)
61 for chtxtt, title, start, stop ,exp,longexp,category in d:
62 #recdblist.printutf8(chtxtt+":"+title+":"+start+":"+stop)
63 p = n_gram.bigram(titletxt, title)
65 btime = btime[0:4] + "-" + btime[4:6] + "-" + btime[6:8] + " " + btime[8:10] + ":" + btime[10:12] + ":00"
67 etime = etime[0:4] + "-" + etime[4:6] + "-" + etime[6:8] + " " + etime[8:10] + ":" + etime[10:12] + ":00"
68 bt = datetime.datetime.strptime(btime, "%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)
76 one = [chtxtt, title, btime, etime,exp,longexp,category]
79 recdblist.printutf8(title + ":" + str(p) + u"点")
83 def searchtime_auto(keytxt, timet, deltatime):
84 time = datetime.datetime.strptime(timet, "%Y-%m-%d %H:%M:%S")
86 deltatime = int(deltatime)
87 beforetime = time.strftime("%Y%m%d%H%M%S")
88 aftertime = time + datetime.timedelta(hours=deltatime)
89 aftertime = aftertime.strftime("%Y%m%d%H%M%S")
90 d = rec10d.rec10db.select_by_time_auto_suggest_epg_timeline(keytxt,beforetime, aftertime)
91 for chtxtt, title, start, stop ,exp,longexp,category in d:
93 btime = btime[0:4] + "-" + btime[4:6] + "-" + btime[6:8] + " " + btime[8:10] + ":" + btime[10:12] + ":00"
95 etime = etime[0:4] + "-" + etime[4:6] + "-" + etime[6:8] + " " + etime[8:10] + ":" + etime[10:12] + ":00"
96 ret.append([chtxtt, title, btime, etime,exp,longexp,category])