3 # Rec10 TS Recording Tools
\r
4 # Copyright (C) 2009-2011 Yukikaze
\r
19 path = str(os.path.dirname(os.path.abspath(__file__))) + "/"
\r
20 tmppath = configreader.getConfPath("tmp")+"/"
\r
24 recdblist.printutf8(chtxt)
\r
25 tnow = datetime.datetime.now()
\r
27 lastup = datetime.datetime.strptime(chdb.searchCHFromChtxt(chtxt)[0]['update'], "%Y-%m-%d %H:%M:%S")
\r
29 lastup = datetime.datetime.strptime("2009-04-01 00:00:00", "%Y-%m-%d %H:%M:%S")
\r
31 dt = dt.days * 24 * 60 + dt.seconds
\r
32 if dt > 2 * 60 * 60:
\r
33 ts2epg.writeEpgXML(os.path.join(tmppath, chtxt + "epgdata.xml"), chdb.searchCHFromChtxt(chtxt)['ch'])
\r
34 xml2db_dom.xml2db_dom(os.path.join(tmppath, chtxt + "epgdata.xml"), chdb.searchCHFromChtxt(chtxt)['bctype'])
\r
35 def updatebc(bctype):
\r
36 bctypel = chdb.searchCHFromBctype(bctype)
\r
39 ts2epg.writeEpgXML(tmppath + bctype + "epgdata.xml", chdb.searchCHFromBctype(bctype)['ch'])
\r
40 xml2db_dom.xml2db_dom(tmppath + bctype + "epgdata.xml", bctype)
\r
41 shutil.copyfile(tmppath + bctype + "epgdata.xml", tmppath + bctype + "epgdata.bak.xml")
\r
43 rec10d.rec10db.update_by_bctype_epg_ch(bctype)
\r
44 except Exception, inst:
\r
45 recdblist.addCommonlogEX("Error","updatebc(epgdb.py)", str(type(inst)), str(inst)+"\n"+traceback.format_exc(),log_level=200)
\r
46 xml2db_dom.xml2db_dom(tmppath + bctype + "epgdata.bak.xml", bctype)
\r
47 rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "2")
\r
48 def updateLogo_bc(bctype):
\r
49 bctypel = chdb.searchCHFromBctype(bctype)
\r
52 ts2epg.writeLogoEpgXML(tmppath + bctype + "logo.xml", chdb.searchCHFromBctype(bctype)['ch'])
\r
53 xml2db_dom.xml2db_dom_logo(tmppath + bctype + "logo.xml", bctype)
\r
54 shutil.copyfile(tmppath + bctype + "logo.xml", tmppath + bctype + "logo.bak.xml")
\r
56 rec10d.rec10db.update_logostatus_by_bctype_epg_ch(bctype,"1")
\r
57 except Exception, inst:
\r
58 recdblist.addCommonlogEX("Error","updatebc(epgdb.py)", str(type(inst)), str(inst)+"\n"+traceback.format_exc(),log_level=200)
\r
59 xml2db_dom.xml2db_dom(tmppath + bctype + "logo.bak.xml", bctype)
\r
60 rec10d.rec10db.update_logostatus_by_bctype_epg_ch(bctype,"2")
\r
61 def searchTime(titletxt, timet, deltatime, chtxt):
\r
62 time = datetime.datetime.strptime(timet, "%Y-%m-%d %H:%M:%S")
\r
64 deltatime = int(deltatime)
\r
65 beforetime = time.strftime("%Y%m%d%H%M%S")
\r
66 beforetime = time - datetime.timedelta(hours=deltatime)
\r
67 aftertime = time + datetime.timedelta(hours=deltatime)
\r
68 beforetime = beforetime.strftime("%Y%m%d%H%M%S")
\r
69 aftertime = aftertime.strftime("%Y%m%d%H%M%S")
\r
70 one = ["", "", "", "","","",""]
\r
72 chtxtt=chtxt.replace("_0","_%")
\r
73 d = rec10d.rec10db.select_by_time_ngram_epg_timeline(beforetime, aftertime, chtxtt)
\r
74 for chtxtt, title, start, stop ,exp,longexp,category in d:
\r
75 #recdblist.printutf8(chtxtt+":"+title+":"+start+":"+stop)
\r
76 p = n_gram.bigram(titletxt, title)
\r
78 btime = btime[0:4] + "-" + btime[4:6] + "-" + btime[6:8] + " " + btime[8:10] + ":" + btime[10:12] + ":00"
\r
80 etime = etime[0:4] + "-" + etime[4:6] + "-" + etime[6:8] + " " + etime[8:10] + ":" + etime[10:12] + ":00"
\r
81 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
\r
84 dt = 24 * 60 * 60 * dt.days + dt.seconds + 1
\r
86 dt = 1000-1000 * dt / (7 * 24 * 60 * 60)
\r
90 one = [chtxtt, title, btime, etime,exp,longexp,category]
\r
93 #recdblist.printutf8(title + ":" + str(p) + u"点")
\r
98 def searchTimeAuto(keytxt, timet, deltatime):
\r
99 time = datetime.datetime.strptime(timet, "%Y-%m-%d %H:%M:%S")
\r
101 deltatime = int(deltatime)
\r
102 beforetime = time.strftime("%Y%m%d%H%M%S")
\r
103 aftertime = time + datetime.timedelta(hours=deltatime)
\r
104 aftertime = aftertime.strftime("%Y%m%d%H%M%S")
\r
105 d = rec10d.rec10db.select_by_time_keyword_auto_suggest_epg_timeline(keytxt,beforetime, aftertime)
\r
106 for chtxtt, title, start, stop ,exp,longexp,category in d:
\r
108 btime = btime[0:4] + "-" + btime[4:6] + "-" + btime[6:8] + " " + btime[8:10] + ":" + btime[10:12] + ":00"
\r
110 etime = etime[0:4] + "-" + etime[4:6] + "-" + etime[6:8] + " " + etime[8:10] + ":" + etime[10:12] + ":00"
\r
111 ret.append([chtxtt, title, btime, etime,exp,longexp,category])
\r
113 def countSchedule(btime,etime):
\r
115 return rec num (int return[0]:TE /int return[1]:BS/CS)
\r
126 dls = rec10d.rec10db.select_bytime_all_timeline(btime, etime)
\r
128 btd = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
\r
129 etd = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
\r
131 dd1 = datetime.datetime.strptime(dl['btime'], "%Y-%m-%d %H:%M:%S")
\r
132 dd2 = datetime.datetime.strptime(dl['etime'], "%Y-%m-%d %H:%M:%S")
\r
139 times = list(set(times))
\r
143 for i in xrange(0, len(times)-2, 1):
\r
146 btime1 = bt1.strftime("%Y-%m-%d %H:%M:%S")
\r
147 etime1 = et1.strftime("%Y-%m-%d %H:%M:%S")
\r
148 ret1 = rec10d.rec10db.count_schedule_timeline(btime1, etime1)
\r
149 if retcount[0] < ret1[0]:
\r
150 retcount[0] = ret1[0]
\r
151 if retcount[1] < ret1[1]:
\r
152 retcount[1] = ret1[1]
\r
155 def searchSchedule(btime,etime):
\r
157 return rec num (int return[0]:TE /int return[1]:BS/CS)
\r
168 dls = rec10d.rec10db.select_bytime_all_timeline(btime, etime)
\r
170 btd = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
\r
171 etd = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
\r
173 dd1 = datetime.datetime.strptime(dl['btime'], "%Y-%m-%d %H:%M:%S")
\r
174 dd2 = datetime.datetime.strptime(dl['etime'], "%Y-%m-%d %H:%M:%S")
\r
181 times = list(set(times))
\r
185 for i in xrange(0, len(times)-2, 1):
\r
188 btime1 = bt1.strftime("%Y-%m-%d %H:%M:%S")
\r
189 etime1 = et1.strftime("%Y-%m-%d %H:%M:%S")
\r
190 ret1 = rec10d.rec10db.search_schedule_timeline(btime1, etime1)
\r
192 ret = list(set(ret))
\r
195 def countEpgSchedule(epgbtime,epgetime):
\r
197 return rec num (int return[0]:TE /int return[1]:BS/CS)
\r
208 dls = rec10d.rec10db.select_byepgtime_over_timeline(epgbtime, epgetime)
\r
211 btd = datetime.datetime.strptime(epgbtime, "%Y-%m-%d %H:%M:%S")
\r
212 etd = datetime.datetime.strptime(epgetime, "%Y-%m-%d %H:%M:%S")
\r
214 dd1 = datetime.datetime.strptime(dl['epgbtime'], "%Y-%m-%d %H:%M:%S")
\r
215 dd2 = datetime.datetime.strptime(dl['epgetime'], "%Y-%m-%d %H:%M:%S")
\r
222 times = list(set(times))
\r
226 for i in xrange(0, len(times)-1, 1):
\r
229 epgbtime1 = bt1.strftime("%Y-%m-%d %H:%M:%S")
\r
230 epgetime1 = et1.strftime("%Y-%m-%d %H:%M:%S")
\r
231 ret1 = rec10d.rec10db.count_epgschedule_timeline(epgbtime1, epgetime1)
\r
232 if retcount[0] < ret1[0]:
\r
233 retcount[0] = ret1[0]
\r
234 if retcount[1] < ret1[1]:
\r
235 retcount[1] = ret1[1]
\r
237 def searchEpgSchedule(epgbtime,epgetime):
\r
239 return rec num (int return[0]:TE /int return[1]:BS/CS)
\r
250 dls = rec10d.rec10db.select_byepgtime_all_timeline(epgbtime, epgetime)
\r
252 btd = datetime.datetime.strptime(epgbtime, "%Y-%m-%d %H:%M:%S")
\r
253 etd = datetime.datetime.strptime(epgetime, "%Y-%m-%d %H:%M:%S")
\r
255 dd1 = datetime.datetime.strptime(dl['epgbtime'], "%Y-%m-%d %H:%M:%S")
\r
256 dd2 = datetime.datetime.strptime(dl['epgetime'], "%Y-%m-%d %H:%M:%S")
\r
263 times = list(set(times))
\r
267 for i in xrange(0, len(times)-2, 1):
\r
270 epgbtime1 = bt1.strftime("%Y-%m-%d %H:%M:%S")
\r
271 epgetime1 = et1.strftime("%Y-%m-%d %H:%M:%S")
\r
272 ret1 = rec10d.rec10db.search_epgschedule_timeline(epgbtime1, epgetime1)
\r
274 ret = list(set(ret))
\r