OSDN Git Service

fix some bugs.
[rec10/rec10-git.git] / rec10 / trunk / src / scan_ch.py
index 5ff85b5..5b79cf2 100644 (file)
@@ -7,6 +7,7 @@ import os.path
 import time
 import commands
 import traceback
+import datetime
 
 import chdb
 import rec10d
@@ -14,48 +15,64 @@ import configreader
 import recdblist
 import tv2ts
 tmppath = configreader.getConfPath("tmp")+"/"
-tssplitterp = configreader.getConfPath("tssplitter")
+tssplitterp =configreader.getConfPath("java")+" -jar "+configreader.getConfPath("jTsSplitter")
 def searchCh():
+    rec10d.rec10db.change_installed_in_status(2)
     #地上デジタル
-    for i in xrange(13,62):
+    for i in xrange(13,62):#62
         recdblist.printuft8ex(u"チャンネルスキャン:地上デジタル CH "+str(i), 200, 200)
         if checkTs(str(i))>0:
             addCh(str(i),u"te"+str(i),str(i))
+    time.sleep(1)
     #BSデジタル
-    recdblist.printuft8ex(u"チャンネルスキャン:BSデジタル "+str(i), 200, 200)
-    for i in xrange(100,240):
+    recdblist.printuft8ex(u"チャンネルスキャン:BSデジタル ", 200, 200)
+    for i in xrange(100,280):#240
         recdblist.printuft8ex(u"チャンネルスキャン:BSデジタル CH "+str(i), 200, 200)
         if checkTs(str(i))>0:
             addCh(str(i),u"bs","BS")
+    time.sleep(1)
     #スカパーe2!
     #http://www5e.biglobe.ne.jp/~kazu_f/digital-sat/trapon-nsat110.html
     #
     #CS1ネットワーク
     if checkTs("CS2")>0:
+        recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS2 ", 200, 200)
         addCh("CS2","cs1","CS")
     if checkTs("CS8")>0:
+        recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS8", 200, 200)
         addCh("CS8","cs1","CS")
     if checkTs("CS10")>0:
+        recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS10", 200, 200)
         addCh("CS10","cs1","CS")
     #CS2ネットワーク
     if checkTs("CS4")>0:
+        recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS4", 200, 200)
         addCh("CS4","cs2","CS")
     if checkTs("CS6")>0:
+        recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS6", 200, 200)
         addCh("CS6","cs2","CS")
     if checkTs("CS12")>0:
+        recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS12", 200, 200)
         addCh("CS12","cs2","CS")
     if checkTs("CS14")>0:
+        recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS14", 200, 200)
         addCh("CS14","cs2","CS")
     if checkTs("CS16")>0:
+        recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS16", 200, 200)
         addCh("CS16","cs2","CS")
     if checkTs("CS18")>0:
+        recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS18", 200, 200)
         addCh("CS18","cs2","CS")
     if checkTs("CS20")>0:
+        recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS20", 200, 200)
         addCh("CS20","cs2","CS")
     if checkTs("CS22")>0:
+        recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS22", 200, 200)
         addCh("CS22","cs2","CS")
     if checkTs("CS24")>0:
+        recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS24", 200, 200)
         addCh("CS24","cs2","CS")
+    rec10d.rec10db.change_installed_in_status(100)
 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")):
@@ -70,9 +87,11 @@ def addCh(ch,bctype,chtxthead):
         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")
+                    tnow=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+                    rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr, u"2010-01-01 00:00:00", u"2010-01-01 00:00:00",tnow)
             else:
-                rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr, u"2010-01-01 00:00:00")
+                tnow=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+                rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr, u"2010-01-01 00:00:00", u"2010-01-01 00:00:00",tnow)
         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])
@@ -93,6 +112,7 @@ def getTsProgNum(ch,tspath):
     doexe = tssplitterp + " "+chopt+" \""+ pin + "\" \""+ pout + "\""
     doexe = "nice -n 18 " + doexe
     os.environ['LANG']="ja_JP.UTF-8"
+    os.system(u"touch \""+pout+"\"")
     txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8','ignore')
     f=open(pout)
     lines=f.readlines()
@@ -133,5 +153,6 @@ def checkB25Purchased(ch,logtxt):
     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")
+            if chl != None:
+                if chl['csch'] in upl:
+                    chdb.changeCHShow(chl['chtxt'],"0")