OSDN Git Service

stop using trunk or dist directory in rec10 project.
[rec10/rec10-git.git] / dist / trunk / rec10 / epgdb.py
diff --git a/dist/trunk/rec10/epgdb.py b/dist/trunk/rec10/epgdb.py
deleted file mode 100755 (executable)
index f0bfaf6..0000000
+++ /dev/null
@@ -1,277 +0,0 @@
-#!/usr/bin/python\r
-# coding: UTF-8\r
-# Rec10 TS Recording Tools\r
-# Copyright (C) 2009-2011 Yukikaze\r
-import datetime\r
-import os\r
-import shutil\r
-import time\r
-import os.path\r
-import traceback\r
-\r
-import chdb\r
-import n_gram\r
-import rec10d\r
-import ts2epg\r
-import xml2db_dom\r
-import configreader\r
-import recdblist\r
-path = str(os.path.dirname(os.path.abspath(__file__))) + "/"\r
-tmppath = configreader.getConfPath("tmp")+"/"\r
-if tmppath=="/":\r
-    tmppath=path\r
-if not os.path.exists(tmppath):\r
-    os.mkdir(tmppath)\r
-def update(chtxt):\r
-    recdblist.printutf8(chtxt)\r
-    tnow = datetime.datetime.now()\r
-    try:\r
-        lastup = datetime.datetime.strptime(chdb.searchCHFromChtxt(chtxt)[0]['update'], "%Y-%m-%d %H:%M:%S")\r
-    except:\r
-        lastup = datetime.datetime.strptime("2009-04-01 00:00:00", "%Y-%m-%d %H:%M:%S")\r
-    dt = tnow-lastup\r
-    dt = dt.days * 24 * 60 + dt.seconds\r
-    if dt > 2 * 60 * 60:\r
-        ts2epg.writeEpgXML(os.path.join(tmppath, chtxt + "epgdata.xml"), chdb.searchCHFromChtxt(chtxt)['ch'])\r
-        xml2db_dom.xml2db_dom(os.path.join(tmppath, chtxt + "epgdata.xml"), chdb.searchCHFromChtxt(chtxt)['bctype'])\r
-def updatebc(bctype):\r
-    bctypel = chdb.searchCHFromBctype(bctype)\r
-    #print bctype\r
-    try:\r
-        ts2epg.writeEpgXML(tmppath + bctype + "epgdata.xml", chdb.searchCHFromBctype(bctype)['ch'])\r
-        xml2db_dom.xml2db_dom(tmppath + bctype + "epgdata.xml", bctype)\r
-        shutil.copyfile(tmppath + bctype + "epgdata.xml", tmppath + bctype + "epgdata.bak.xml")\r
-        time.sleep(5)\r
-        rec10d.rec10db.update_by_bctype_epg_ch(bctype)\r
-    except Exception, inst:\r
-        recdblist.addCommonlogEX("Error","updatebc(epgdb.py)", str(type(inst)), str(inst)+"\n"+traceback.format_exc(),log_level=200)\r
-        xml2db_dom.xml2db_dom(tmppath + bctype + "epgdata.bak.xml", bctype)\r
-        rec10d.rec10db.update_status_by_bctype_epg_ch(bctype, "2")\r
-def updateLogo_bc(bctype):\r
-    bctypel = chdb.searchCHFromBctype(bctype)\r
-    #print bctype\r
-    try:\r
-        ts2epg.writeLogoEpgXML(tmppath + bctype + "logo.xml", chdb.searchCHFromBctype(bctype)['ch'])\r
-        xml2db_dom.xml2db_dom_logo(tmppath + bctype + "logo.xml", bctype)\r
-        shutil.copyfile(tmppath + bctype + "logo.xml", tmppath + bctype + "logo.bak.xml")\r
-        time.sleep(5)\r
-        rec10d.rec10db.update_logostatus_by_bctype_epg_ch(bctype,"1")\r
-    except Exception, inst:\r
-        recdblist.addCommonlogEX("Error","updatebc(epgdb.py)", str(type(inst)), str(inst)+"\n"+traceback.format_exc(),log_level=200)\r
-        xml2db_dom.xml2db_dom(tmppath + bctype + "logo.bak.xml", bctype)\r
-        rec10d.rec10db.update_logostatus_by_bctype_epg_ch(bctype,"2")\r
-def searchTime(titletxt, timet, deltatime, chtxt):\r
-    time = datetime.datetime.strptime(timet, "%Y-%m-%d %H:%M:%S")\r
-    ret = []\r
-    deltatime = int(deltatime)\r
-    beforetime = time.strftime("%Y%m%d%H%M%S")\r
-    beforetime = time - datetime.timedelta(hours=deltatime)\r
-    aftertime = time + datetime.timedelta(hours=deltatime)\r
-    beforetime = beforetime.strftime("%Y%m%d%H%M%S")\r
-    aftertime = aftertime.strftime("%Y%m%d%H%M%S")\r
-    one = ["", "", "", "","","",""]\r
-    tempt = 0\r
-    chtxtt=chtxt.replace("_0","_%")\r
-    d = rec10d.rec10db.select_by_time_ngram_epg_timeline(beforetime, aftertime, chtxtt)\r
-    for chtxtt, title, start, stop ,exp,longexp,category in d:\r
-        #recdblist.printutf8(chtxtt+":"+title+":"+start+":"+stop)\r
-        p = n_gram.bigram(titletxt, title)\r
-        btime = start\r
-        btime = btime[0:4] + "-" + btime[4:6] + "-" + btime[6:8] + " " + btime[8:10] + ":" + btime[10:12] + ":00"\r
-        etime = stop\r
-        etime = etime[0:4] + "-" + etime[4:6] + "-" + etime[6:8] + " " + etime[8:10] + ":" + etime[10:12] + ":00"\r
-        bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")\r
-        dt = bt-time\r
-        dt = abs(dt)\r
-        dt = 24 * 60 * 60 * dt.days + dt.seconds + 1\r
-        p = p * 90\r
-        dt = 1000-1000 * dt / (7 * 24 * 60 * 60)\r
-        if p > 0:\r
-            p = p + dt\r
-        if p > tempt:\r
-            one = [chtxtt, title, btime, etime,exp,longexp,category]\r
-            tempt = p\r
-        if p > 0:\r
-            #recdblist.printutf8(title + ":" + str(p) + u"点")\r
-            ""\r
-    ret = one\r
-    #print ret\r
-    return ret\r
-def searchTimeAuto(keytxt, timet, deltatime):\r
-    time = datetime.datetime.strptime(timet, "%Y-%m-%d %H:%M:%S")\r
-    ret = []\r
-    deltatime = int(deltatime)\r
-    beforetime = time.strftime("%Y%m%d%H%M%S")\r
-    aftertime = time + datetime.timedelta(hours=deltatime)\r
-    aftertime = aftertime.strftime("%Y%m%d%H%M%S")\r
-    d = rec10d.rec10db.select_by_time_keyword_auto_suggest_epg_timeline(keytxt,beforetime, aftertime)\r
-    for chtxtt, title, start, stop ,exp,longexp,category in d:\r
-        btime = start\r
-        btime = btime[0:4] + "-" + btime[4:6] + "-" + btime[6:8] + " " + btime[8:10] + ":" + btime[10:12] + ":00"\r
-        etime = stop\r
-        etime = etime[0:4] + "-" + etime[4:6] + "-" + etime[6:8] + " " + etime[8:10] + ":" + etime[10:12] + ":00"\r
-        ret.append([chtxtt, title, btime, etime,exp,longexp,category])\r
-    return ret\r
-def countSchedule(btime,etime):\r
-    """\r
-    return rec num (int return[0]:TE /int return[1]:BS/CS)\r
-    """\r
-    def cmpare(x, y):\r
-        xt = x\r
-        yt = y\r
-        if xt > yt:\r
-            return -1\r
-        elif xt == yt:\r
-            return 0\r
-        else:\r
-            return 1\r
-    dls = rec10d.rec10db.select_bytime_all_timeline(btime, etime)\r
-    times = []\r
-    btd = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")\r
-    etd = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")\r
-    for dl in dls:\r
-        dd1 = datetime.datetime.strptime(dl['btime'], "%Y-%m-%d %H:%M:%S")\r
-        dd2 = datetime.datetime.strptime(dl['etime'], "%Y-%m-%d %H:%M:%S")\r
-        if dd1 < btd:\r
-            dd1 = btd\r
-        if dd2 > etd:\r
-            dd2 = etd\r
-        times.append(dd1)\r
-        times.append(dd2)\r
-    times = list(set(times))\r
-    times.sort(cmpare)\r
-    times.reverse()\r
-    retcount = [0, 0]\r
-    for i in xrange(0, len(times)-2, 1):\r
-        bt1 = times[i]\r
-        et1 = times[i + 1]\r
-        btime1 = bt1.strftime("%Y-%m-%d %H:%M:%S")\r
-        etime1 = et1.strftime("%Y-%m-%d %H:%M:%S")\r
-        ret1 = rec10d.rec10db.count_schedule_timeline(btime1, etime1)\r
-        if retcount[0] < ret1[0]:\r
-            retcount[0] = ret1[0]\r
-        if retcount[1] < ret1[1]:\r
-            retcount[1] = ret1[1]\r
-    return retcount\r
-\r
-def searchSchedule(btime,etime):\r
-    """\r
-    return rec num (int return[0]:TE /int return[1]:BS/CS)\r
-    """\r
-    def cmpare(x, y):\r
-        xt = x\r
-        yt = y\r
-        if xt > yt:\r
-            return -1\r
-        elif xt == yt:\r
-            return 0\r
-        else:\r
-            return 1\r
-    dls = rec10d.rec10db.select_bytime_all_timeline(btime, etime)\r
-    times = []\r
-    btd = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")\r
-    etd = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")\r
-    for dl in dls:\r
-        dd1 = datetime.datetime.strptime(dl['btime'], "%Y-%m-%d %H:%M:%S")\r
-        dd2 = datetime.datetime.strptime(dl['etime'], "%Y-%m-%d %H:%M:%S")\r
-        if dd1 < btd:\r
-            dd1 = btd\r
-        if dd2 > etd:\r
-            dd2 = etd\r
-        times.append(dd1)\r
-        times.append(dd2)\r
-    times = list(set(times))\r
-    times.sort(cmpare)\r
-    times.reverse()\r
-    ret=[]\r
-    for i in xrange(0, len(times)-2, 1):\r
-        bt1 = times[i]\r
-        et1 = times[i + 1]\r
-        btime1 = bt1.strftime("%Y-%m-%d %H:%M:%S")\r
-        etime1 = et1.strftime("%Y-%m-%d %H:%M:%S")\r
-        ret1 = rec10d.rec10db.search_schedule_timeline(btime1, etime1)\r
-        ret.append(ret1)\r
-    ret = list(set(ret))\r
-    return ret\r
-\r
-def countEpgSchedule(epgbtime,epgetime):\r
-    """\r
-    return rec num (int return[0]:TE /int return[1]:BS/CS)\r
-    """\r
-    def cmpare(x, y):\r
-        xt = x\r
-        yt = y\r
-        if xt > yt:\r
-            return -1\r
-        elif xt == yt:\r
-            return 0\r
-        else:\r
-            return 1\r
-    dls = rec10d.rec10db.select_byepgtime_over_timeline(epgbtime, epgetime)\r
-    #print dls\r
-    times = []\r
-    btd = datetime.datetime.strptime(epgbtime, "%Y-%m-%d %H:%M:%S")\r
-    etd = datetime.datetime.strptime(epgetime, "%Y-%m-%d %H:%M:%S")\r
-    for dl in dls:\r
-        dd1 = datetime.datetime.strptime(dl['epgbtime'], "%Y-%m-%d %H:%M:%S")\r
-        dd2 = datetime.datetime.strptime(dl['epgetime'], "%Y-%m-%d %H:%M:%S")\r
-        if dd1 < btd:\r
-            dd1 = btd\r
-        if dd2 > etd:\r
-            dd2 = etd\r
-        times.append(dd1)\r
-        times.append(dd2)\r
-    times = list(set(times))\r
-    times.sort(cmpare)\r
-    times.reverse()\r
-    retcount = [0, 0]\r
-    for i in xrange(0, len(times)-1, 1):\r
-        bt1 = times[i]\r
-        et1 = times[i + 1]\r
-        epgbtime1 = bt1.strftime("%Y-%m-%d %H:%M:%S")\r
-        epgetime1 = et1.strftime("%Y-%m-%d %H:%M:%S")\r
-        ret1 = rec10d.rec10db.count_epgschedule_timeline(epgbtime1, epgetime1)\r
-        if retcount[0] < ret1[0]:\r
-            retcount[0] = ret1[0]\r
-        if retcount[1] < ret1[1]:\r
-            retcount[1] = ret1[1]\r
-    return retcount\r
-def searchEpgSchedule(epgbtime,epgetime):\r
-    """\r
-    return rec num (int return[0]:TE /int return[1]:BS/CS)\r
-    """\r
-    def cmpare(x, y):\r
-        xt = x\r
-        yt = y\r
-        if xt > yt:\r
-            return -1\r
-        elif xt == yt:\r
-            return 0\r
-        else:\r
-            return 1\r
-    dls = rec10d.rec10db.select_byepgtime_all_timeline(epgbtime, epgetime)\r
-    times = []\r
-    btd = datetime.datetime.strptime(epgbtime, "%Y-%m-%d %H:%M:%S")\r
-    etd = datetime.datetime.strptime(epgetime, "%Y-%m-%d %H:%M:%S")\r
-    for dl in dls:\r
-        dd1 = datetime.datetime.strptime(dl['epgbtime'], "%Y-%m-%d %H:%M:%S")\r
-        dd2 = datetime.datetime.strptime(dl['epgetime'], "%Y-%m-%d %H:%M:%S")\r
-        if dd1 < btd:\r
-            dd1 = btd\r
-        if dd2 > etd:\r
-            dd2 = etd\r
-        times.append(dd1)\r
-        times.append(dd2)\r
-    times = list(set(times))\r
-    times.sort(cmpare)\r
-    times.reverse()\r
-    ret=[]\r
-    for i in xrange(0, len(times)-2, 1):\r
-        bt1 = times[i]\r
-        et1 = times[i + 1]\r
-        epgbtime1 = bt1.strftime("%Y-%m-%d %H:%M:%S")\r
-        epgetime1 = et1.strftime("%Y-%m-%d %H:%M:%S")\r
-        ret1 = rec10d.rec10db.search_epgschedule_timeline(epgbtime1, epgetime1)\r
-        ret.append(ret1)\r
-    ret = list(set(ret))\r
-    return ret\r