OSDN Git Service

implement tmp config.
[rec10/rec10-git.git] / rec10 / trunk / src / epgdb.py
index 0372d1d..77e480e 100644 (file)
@@ -11,8 +11,9 @@ import n_gram
 import rec10d
 import ts2epg
 import xml2db
+import configreader
 path = str(os.path.dirname(os.path.abspath(__file__))) + "/"
-tmppath = path
+tmppath = configreader.getpath("tmp")+"/"
 def update(chtxt):
     print chtxt
     tnow = datetime.datetime.now()
@@ -43,28 +44,6 @@ def updatebc_bak(bctype):
     update epg data by .bak file
     """
     xml2db.xml2db(tmppath + bctype + "epgdate.bak.xml", bctype)
-def updateall_bak():
-    updatebc_bak("te13")
-    updatebc_bak("te20")
-    updatebc_bak("te22")
-    updatebc_bak("te18")
-    updatebc_bak("te19")
-    updatebc_bak("te21")
-    updatebc_bak("te23")
-    updatebc_bak("cs1")
-    updatebc_bak("cs2")
-    updatebc_bak("bs")
-def updateall():
-    updatebc("te13")
-    updatebc("te20")
-    updatebc("te22")
-    updatebc("te18")
-    updatebc("te19")
-    updatebc("te21")
-    updatebc("te23")
-    updatebc("cs1")
-    updatebc("cs2")
-    updatebc("bs")
 def searchtime2(titletxt, timet, deltatime, chtxt):
     time = datetime.datetime.strptime(timet, "%Y-%m-%d %H:%M:%S")
     ret = []
@@ -75,7 +54,7 @@ def searchtime2(titletxt, timet, deltatime, chtxt):
     one = ["", "", "", ""]
     tempt = 0
     d = rec10d.rec10db.select_by_time_ngram_tv(beforetime, aftertime, chtxt)
-    for chtxtt, title, start, stop in d:
+    for chtxtt, title, start, stop ,exp,longexp,category in d:
         #print chtxtt+":"+title+":"+start+":"+stop
         p = n_gram.bigram(titletxt, title)
         btime = start
@@ -91,10 +70,25 @@ def searchtime2(titletxt, timet, deltatime, chtxt):
             p = p + dt
             print dt
         if p > tempt:
-            one = [chtxtt, title.encode('utf-8'), btime, etime]
+            one = [chtxtt, title.encode('utf-8'), btime, etime,exp.encode('UTF-8'),longexp.encode('UTF-8'),category.encode('UTF-8')]
             tempt = p
         if p > 0:
             print title + ":" + str(p) + "点"
     ret = one
     print ret
     return ret
+def searchtime_auto(keytxt, timet, deltatime):
+    time = datetime.datetime.strptime(timet, "%Y-%m-%d %H:%M:%S")
+    ret = []
+    deltatime = int(deltatime)
+    beforetime = time.strftime("%Y%m%d%H%M%S")
+    aftertime = time + datetime.timedelta(hours=deltatime)
+    aftertime = aftertime.strftime("%Y%m%d%H%M%S")
+    d = rec10d.rec10db.select_by_time_auto_suggest_tv(keytxt,beforetime, aftertime)
+    for chtxtt, title, start, stop ,exp,longexp,category in d:
+        btime = start
+        btime = btime[0:4] + "-" + btime[4:6] + "-" + btime[6:8] + " " + btime[8:10] + ":" + btime[10:12] + ":00"
+        etime = stop
+        etime = etime[0:4] + "-" + etime[4:6] + "-" + etime[6:8] + " " + etime[8:10] + ":" + etime[10:12] + ":00"
+        ret.append([chtxtt, title.encode('utf-8'), btime, etime,exp.encode('UTF-8'),longexp.encode('UTF-8'),category.encode('UTF-8')])
+    return ret
\ No newline at end of file