OSDN Git Service

scan purchased.
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sat, 4 Dec 2010 05:00:25 +0000 (05:00 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sat, 4 Dec 2010 05:00:25 +0000 (05:00 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@788 4e526526-5e11-4fc0-8910-f8fd03428081

rec10/trunk/src/chdb.py
rec10/trunk/src/dbMySQL.py
rec10/trunk/src/scan_ch.py

index dbfbc43..82cefcf 100644 (file)
@@ -1,66 +1,74 @@
-#!/usr/bin/python\r
-# coding: UTF-8\r
-# Rec10 TS Recording Tools\r
-# Copyright (C) 2009-2010 Yukikaze\r
-    # モジュール属性 argv を取得するため\r
-import rec10d\r
-\r
-def searchCHFromChtxt(chtxtin):\r
-    chtxtt=chtxtin.replace("_0","_%")\r
-    ret = []\r
-    for datum in rec10d.rec10db.select_by_chtxt_epg_ch(chtxtt):\r
-        rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}\r
-        ret.append(rett)\r
-    if len(ret) == 0:\r
-        ret.append(None)\r
-    return ret[0]\r
-def searchCHFromBctype(bctypein):\r
-    ret = []\r
-    for datum in rec10d.rec10db.select_by_bctype_epg_ch(bctypein):\r
-        rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}\r
-        ret.append(rett)\r
-    if len(ret) == 0:\r
-        ret.append(None)\r
-    return ret[0]\r
-def searchCHFromCh(chin):\r
-    ret = []\r
-    for datum in rec10d.rec10db.select_by_ch_epg_ch(chin):\r
-        rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}\r
-        ret.append(rett)\r
-    if len(ret) == 0:\r
-        ret.append(None)\r
-    return ret[0]\r
-def getAllCH():\r
-    ret = []\r
-    for datum in rec10d.rec10db.select_all_epg_ch():\r
-        rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}\r
-        ret.append(rett)\r
-    if len(ret) == 0:\r
-        ret.append(None)\r
-    return ret\r
-def update():\r
-    ret = []\r
-    CSupdate = 0\r
-    CS2update = 0\r
-    BSupdate = 0\r
-    HUupdate = 0\r
-    rec10d.rec10db.set_new_status("8")\r
-    for datum in rec10d.rec10db.select_get_update_epg_ch("6"):\r
-        bctype = datum[0]\r
-        if bctype == "cs1" or bctype == u"cs1":\r
-            if CSupdate == 0:\r
-                ret.append(u"cs1")\r
-                CSupdate = 1\r
-        elif bctype == "cs2" or bctype == u"cs2":\r
-            if CS2update == 0:\r
-                ret.append(u"cs2")\r
-                CS2update = 1\r
-        elif bctype == "bs" or bctype == u"bs":\r
-            if BSupdate == 0:\r
-                ret.append(u"bs")\r
-                BSupdate = 1\r
-        else:\r
-            ret.append(bctype)\r
-    return ret\r
-def changeCHShow(chtxt,isshow):\r
+#!/usr/bin/python
+# coding: UTF-8
+# Rec10 TS Recording Tools
+# Copyright (C) 2009-2010 Yukikaze
+    # モジュール属性 argv を取得するため
+import rec10d
+
+def searchCHFromChtxt(chtxtin):
+    chtxtt=chtxtin.replace("_0","_%")
+    ret = []
+    for datum in rec10d.rec10db.select_by_chtxt_epg_ch(chtxtt):
+        rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}
+        ret.append(rett)
+    if len(ret) == 0:
+        ret.append(None)
+    return ret[0]
+def searchCHFromBctype(bctypein):
+    ret = []
+    for datum in rec10d.rec10db.select_by_bctype_epg_ch(bctypein):
+        rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}
+        ret.append(rett)
+    if len(ret) == 0:
+        ret.append(None)
+    return ret[0]
+def searchCHFromCh(chin):
+    ret = []
+    for datum in rec10d.rec10db.select_by_ch_epg_ch(chin):
+        rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}
+        ret.append(rett)
+    if len(ret) == 0:
+        ret.append(None)
+    return ret[0]
+def searchAllCHFromCh(chin):
+    ret = []
+    for datum in rec10d.rec10db.select_by_ch_epg_ch(chin):
+        rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}
+        ret.append(rett)
+    if len(ret) == 0:
+        ret.append(None)
+    return ret
+def getAllCH():
+    ret = []
+    for datum in rec10d.rec10db.select_all_epg_ch():
+        rett = {'bctype':datum[0], 'chtxt':datum[1], 'ch':datum[2], 'csch':datum[3], 'update':datum[4]}
+        ret.append(rett)
+    if len(ret) == 0:
+        ret.append(None)
+    return ret
+def update():
+    ret = []
+    CSupdate = 0
+    CS2update = 0
+    BSupdate = 0
+    HUupdate = 0
+    rec10d.rec10db.set_new_status("8")
+    for datum in rec10d.rec10db.select_get_update_epg_ch("6"):
+        bctype = datum[0]
+        if bctype == "cs1" or bctype == u"cs1":
+            if CSupdate == 0:
+                ret.append(u"cs1")
+                CSupdate = 1
+        elif bctype == "cs2" or bctype == u"cs2":
+            if CS2update == 0:
+                ret.append(u"cs2")
+                CS2update = 1
+        elif bctype == "bs" or bctype == u"bs":
+            if BSupdate == 0:
+                ret.append(u"bs")
+                BSupdate = 1
+        else:
+            ret.append(bctype)
+    return ret
+def changeCHShow(chtxt,isshow):
     rec10d.rec10db.change_isshow_epg_ch(chtxt, isshow)
\ No newline at end of file
index dfde259..c56155e 100644 (file)
@@ -182,7 +182,7 @@ class DB_MySQL:
     def change_isshow_epg_ch(self,chtxt,isshow):
         db = self.connect_db()
         db[1].execute("\
-        UPDATE epg_ch SET isshow=%s WHERE chtxt=%s",(chtxt,isshow))
+        UPDATE epg_ch SET isshow=%s WHERE chtxt=%s",(isshow,chtxt))
         self.close_db(db)
     def set_new_status(self,dhour):
         db = self.connect_db()
index 7bf1c40..8c4b81d 100644 (file)
-#!/usr/bin/python\r
-# coding: UTF-8\r
-# Rec10 TS Recording Tools\r
-# Copyright (C) 2009-2010 Yukikaze\r
-import os\r
-import os.path\r
-import time\r
-import commands\r
-import traceback\r
-\r
-import chdb\r
-import rec10d\r
-import configreader\r
-import recdblist\r
-import tv2ts\r
-tmppath = configreader.getConfPath("tmp")+"/"\r
-tssplitterp = configreader.getConfPath("tssplitter")\r
-def searchCh():\r
-    #地上デジタル\r
-    for i in xrange(13,62):\r
-        recdblist.printuft8ex(u"チャンネルスキャン:地上デジタル CH "+str(i), 200, 200)\r
-        if checkTs(str(i))>0:\r
-            addCh(str(i),u"te"+str(i),str(i))\r
-    #BSデジタル\r
-    recdblist.printuft8ex(u"チャンネルスキャン:BSデジタル "+str(i), 200, 200)\r
-    for i in xrange(100,240):\r
-        recdblist.printuft8ex(u"チャンネルスキャン:BSデジタル CH "+str(i), 200, 200)\r
-        if checkTs(str(i))>0:\r
-            addCh(str(i),u"bs","BS")\r
-    #スカパーe2!\r
-    #http://www5e.biglobe.ne.jp/~kazu_f/digital-sat/trapon-nsat110.html\r
-    #\r
-    #CS1ネットワーク\r
-    if checkTs("CS2")>0:\r
-        addCh("CS2","cs1","CS")\r
-    if checkTs("CS8")>0:\r
-        addCh("CS8","cs1","CS")\r
-    if checkTs("CS10")>0:\r
-        addCh("CS10","cs1","CS")\r
-    #CS2ネットワーク\r
-    if checkTs("CS4")>0:\r
-        addCh("CS4","cs2","CS")\r
-    if checkTs("CS6")>0:\r
-        addCh("CS6","cs2","CS")\r
-    if checkTs("CS12")>0:\r
-        addCh("CS12","cs2","CS")\r
-    if checkTs("CS14")>0:\r
-        addCh("CS14","cs2","CS")\r
-    if checkTs("CS16")>0:\r
-        addCh("CS16","cs2","CS")\r
-    if checkTs("CS18")>0:\r
-        addCh("CS18","cs2","CS")\r
-    if checkTs("CS20")>0:\r
-        addCh("CS20","cs2","CS")\r
-    if checkTs("CS22")>0:\r
-        addCh("CS22","cs2","CS")\r
-    if checkTs("CS24")>0:\r
-        addCh("CS24","cs2","CS")\r
-def checkTs(ch):\r
-    tv2ts.tv2b25ts(os.path.join(tmppath,"ch_"+str(ch)+".ts"), ch, "1")\r
-    if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts")):\r
-        os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts"))\r
-        return 1\r
-    else:\r
-        return 0\r
-def addCh(ch,bctype,chtxthead):\r
-    prglist=getChProgNum(ch)##[prglist,logt]\r
-    for lstr in prglist[0]:\r
-        #print [bctype,chtxthead+"_"+lstr, ch, lstr]\r
-        try:\r
-            if ch.find("bs")>-1:\r
-                if int(lstr)<300:\r
-                    rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr, u"2010-01-01 00:00:00")\r
-            else:\r
-                rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr, u"2010-01-01 00:00:00")\r
-        except Exception, inst:\r
-            recdblist.addCommonlogEX("Warning", "addCh (scan_ch.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)\r
-    checkB25Purchased(ch, prglist[1])\r
-def getChProgNum(ch):\r
-    pout=os.path.join(tmppath,"ch_"+str(ch)+".ts")\r
-    logt=tv2ts.tv2tsmix(pout, ch, "10")\r
-    retl=getTsProgNum(ch,pout)\r
-    os.remove(pout)\r
-    return [retl,logt]\r
-def getTsProgNum(ch,tspath):\r
-    pin=tspath\r
-    pout=os.path.join(tmppath,"chscan.txt")\r
-    chopt="-ch"\r
-    if ch.find("CS")>-1:\r
-        chopt="-cs"\r
-    elif int(ch)>99:\r
-        chopt="-bs"\r
-    doexe = tssplitterp + " "+chopt+" \""+ pin + "\" \""+ pout + "\""\r
-    doexe = "nice -n 18 " + doexe\r
-    os.environ['LANG']="ja_JP.UTF-8"\r
-    txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8','ignore')\r
-    f=open(pout)\r
-    lines=f.readlines()\r
-    f.close()\r
-    ret=[]\r
-    for l in lines:\r
-        try:\r
-            l=l.replace(" ","")\r
-            l=l.replace("\n","")\r
-            ret.append(str(int(l)))\r
-        except:\r
-            ""\r
-    recdblist.addLog(pin, doexe, u"TsSplitログ-コマンド")\r
-    recdblist.addLog(pin, txt, u"TsSplitログ-詳細")\r
-    time.sleep(1)\r
-    try:\r
-        ""\r
-        #os.remove(pout)\r
-    except:\r
-        ""\r
-    return ret\r
-def getB25UnparchasedList(logtxt):\r
-    warning = 0\r
-    ret=[]\r
-    for strt in logtxt.split("\n"):\r
-        if strt.find("unpurchased ECM")>-1:\r
-            warning=1\r
-        if strt.find("total TS packet")>-1 and warning>0:\r
-            warning=0\r
-        if strt.find("channel")>-1 and warning>0:\r
-            ret.append(strt.replace("channel:","").replace("\n","").replace(" ",""))\r
-def checkB25Purchased(ch,logtxt):\r
-    print ch\r
-    print len(logtxt)\r
-    chlists=chdb.searchCHFromCh(ch)\r
-    print chlists\r
-    upl=getB25UnparchasedList(logtxt)\r
-    print "upl:"\r
-    print upl\r
-    for chl in chlists:\r
-        if upl.count(chl['csch'])>0:\r
-            chdb.changeCHShow(chl['chtxt'],"0")\r
-\r
+#!/usr/bin/python
+# coding: UTF-8
+# Rec10 TS Recording Tools
+# Copyright (C) 2009-2010 Yukikaze
+import os
+import os.path
+import time
+import commands
+import traceback
+
+import chdb
+import rec10d
+import configreader
+import recdblist
+import tv2ts
+tmppath = configreader.getConfPath("tmp")+"/"
+tssplitterp = configreader.getConfPath("tssplitter")
+def searchCh():
+    #地上デジタル
+    for i in xrange(13,62):
+        recdblist.printuft8ex(u"チャンネルスキャン:地上デジタル CH "+str(i), 200, 200)
+        if checkTs(str(i))>0:
+            addCh(str(i),u"te"+str(i),str(i))
+    #BSデジタル
+    recdblist.printuft8ex(u"チャンネルスキャン:BSデジタル "+str(i), 200, 200)
+    for i in xrange(100,240):
+        recdblist.printuft8ex(u"チャンネルスキャン:BSデジタル CH "+str(i), 200, 200)
+        if checkTs(str(i))>0:
+            addCh(str(i),u"bs","BS")
+    #スカパーe2!
+    #http://www5e.biglobe.ne.jp/~kazu_f/digital-sat/trapon-nsat110.html
+    #
+    #CS1ネットワーク
+    if checkTs("CS2")>0:
+        addCh("CS2","cs1","CS")
+    if checkTs("CS8")>0:
+        addCh("CS8","cs1","CS")
+    if checkTs("CS10")>0:
+        addCh("CS10","cs1","CS")
+    #CS2ネットワーク
+    if checkTs("CS4")>0:
+        addCh("CS4","cs2","CS")
+    if checkTs("CS6")>0:
+        addCh("CS6","cs2","CS")
+    if checkTs("CS12")>0:
+        addCh("CS12","cs2","CS")
+    if checkTs("CS14")>0:
+        addCh("CS14","cs2","CS")
+    if checkTs("CS16")>0:
+        addCh("CS16","cs2","CS")
+    if checkTs("CS18")>0:
+        addCh("CS18","cs2","CS")
+    if checkTs("CS20")>0:
+        addCh("CS20","cs2","CS")
+    if checkTs("CS22")>0:
+        addCh("CS22","cs2","CS")
+    if checkTs("CS24")>0:
+        addCh("CS24","cs2","CS")
+def checkTs(ch):
+    tv2ts.tv2b25ts(os.path.join(tmppath,"ch_"+str(ch)+".ts"), ch, "1")
+    if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts")):
+        os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts"))
+        return 1
+    else:
+        return 0
+def addCh(ch,bctype,chtxthead):
+    prglist=getChProgNum(ch)##[prglist,logt]
+    for lstr in prglist[0]:
+        #print [bctype,chtxthead+"_"+lstr, ch, lstr]
+        try:
+            if ch.find("bs")>-1:
+                if int(lstr)<300:
+                    rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr, u"2010-01-01 00:00:00")
+            else:
+                rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr, u"2010-01-01 00:00:00")
+        except Exception, inst:
+            recdblist.addCommonlogEX("Warning", "addCh (scan_ch.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
+    checkB25Purchased(ch, prglist[1])
+def getChProgNum(ch):
+    pout=os.path.join(tmppath,"ch_"+str(ch)+".ts")
+    logt=tv2ts.tv2tsmix(pout, ch, "10")
+    retl=getTsProgNum(ch,pout)
+    os.remove(pout)
+    return [retl,logt]
+def getTsProgNum(ch,tspath):
+    pin=tspath
+    pout=os.path.join(tmppath,"chscan.txt")
+    chopt="-ch"
+    if ch.find("CS")>-1:
+        chopt="-cs"
+    elif int(ch)>99:
+        chopt="-bs"
+    doexe = tssplitterp + " "+chopt+" \""+ pin + "\" \""+ pout + "\""
+    doexe = "nice -n 18 " + doexe
+    os.environ['LANG']="ja_JP.UTF-8"
+    txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8','ignore')
+    f=open(pout)
+    lines=f.readlines()
+    f.close()
+    ret=[]
+    for l in lines:
+        try:
+            l=l.replace(" ","")
+            l=l.replace("\n","")
+            ret.append(str(int(l)))
+        except:
+            ""
+    recdblist.addLog(pin, doexe, u"TsSplitログ-コマンド")
+    recdblist.addLog(pin, txt, u"TsSplitログ-詳細")
+    time.sleep(1)
+    try:
+        ""
+        #os.remove(pout)
+    except:
+        ""
+    return ret
+def getB25UnparchasedList(logtxt):
+    warning = 0
+    ret=[]
+    for strt in logtxt.splitlines():
+        if strt.find("unpurchased ECM")>-1:
+            warning=1
+        if strt.find("total TS packet")>-1 and warning>0:
+            warning=0
+        if strt.find("channel")>-1 and warning>0:
+            txt=strt.replace("channel:","")
+            txt=txt.replace("\n","")
+            txt=txt.replace(" ","")
+            ret.append(txt)
+    return ret
+def checkB25Purchased(ch,logtxt):
+    chlists=chdb.searchAllCHFromCh(ch)
+    upl=getB25UnparchasedList(logtxt)
+    if len(upl)>0 and len(chlists)>0:
+        for chl in chlists:
+            if chl['csch'] in upl:
+                chdb.changeCHShow(chl['chtxt'],"0")
+