OSDN Git Service

add tsid channel information for complete BS support.
[rec10/rec10-git.git] / rec10 / trunk / src / scan_ch.py
index 16290bd..d7b5380 100644 (file)
@@ -35,9 +35,14 @@ def searchCh():
                 addCh(str(i),u"bs","BS")
         for i2 in xrange(0,11):
             chi=u"BS"+str(2*i2+1)
+            chii=2*i2+1
             recdblist.printutf8ex(u"チャンネルスキャン:BSデジタル CH "+chi, 200, 200)
-            if checkTs(chi)>0:
-                addCh(str(chi),u"bs","BS")
+            for ts_offset in xrange(0,4):
+                for ts_idx in xrange(0,8):
+                    t_tsid=16384+chii*16+ts_offset*512+ts_idx
+                    recdblist.printutf8ex(u"TransportID "+str(t_tsid), 200, 200)
+                    if checkTs(chi,str(t_tsid))>0:
+                        addCh(str(chi),u"bs","BS",str(t_tsid))
         time.sleep(1)
         #スカパーe2!
         #http://www5e.biglobe.ne.jp/~kazu_f/digital-sat/trapon-nsat110.html
@@ -81,36 +86,41 @@ def searchCh():
             recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS24", 200, 200)
             addCh("CS24","cs2","CS")
         rec10d.rec10db.change_installed_in_status(100)
-def checkTs(ch):
+def checkTs(ch,tsid="0"):
     if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts")):
         os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts"))
     if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts.b25")):
         os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts.b25"))
-    tv2ts.tv2b25ts(os.path.join(tmppath,"ch_"+str(ch)+".ts"), ch, "1")
+    tv2ts.tv2b25ts(os.path.join(tmppath,"ch_"+str(ch)+".ts"), ch, "1",tsid)
+    if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts.b25")):
+        os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts.b25"))
     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]
+
+def addCh(ch,bctype,chtxthead,tsid="0"):
+    prglist=getChProgNum(ch,tsid)##[prglist,logt]
     for lstr in prglist[0]:
         #print [bctype,chtxthead+"_"+lstr, ch, lstr]
         try:
-            if int(lstr)<10000:
+            if int(lstr)<1000000:
                 if ch.find("bs")>-1:
                     if int(lstr)<300:
                         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)
+                        rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr,tsid, u"2010-01-01 00:00:00", u"2010-01-01 00:00:00",tnow)
                 else:
                     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)
+                    rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr,tsid, 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])
-def getChProgNum(ch):
+def getChProgNum(ch,tsid):
     pout=os.path.join(tmppath,"ch_"+str(ch)+".ts")
-    logt=tv2ts.tv2tsmix(pout, ch, "10")
+    if tsid != "0":
+        pout=os.path.join(tmppath,"ch_"+str(ch)+"_"+tsid+".ts")
+    logt=tv2ts.tv2tsmix(pout, ch, "10",tsid)
     retl=getTsProgNum(ch,pout)
     try:
         os.remove(pout)