3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
16 tmppath = configreader.getConfPath("tmp")+"/"
17 tssplitterp = configreader.getConfPath("tssplitter")
20 for i in xrange(13,62):
21 recdblist.printuft8ex(u"チャンネルスキャン:地上デジタル CH "+str(i), 200, 200)
23 addCh(str(i),u"te"+str(i),str(i))
25 recdblist.printuft8ex(u"チャンネルスキャン:BSデジタル "+str(i), 200, 200)
26 for i in xrange(100,240):
27 recdblist.printuft8ex(u"チャンネルスキャン:BSデジタル CH "+str(i), 200, 200)
29 addCh(str(i),u"bs","BS")
31 #http://www5e.biglobe.ne.jp/~kazu_f/digital-sat/trapon-nsat110.html
35 addCh("CS2","cs1","CS")
37 addCh("CS8","cs1","CS")
39 addCh("CS10","cs1","CS")
42 addCh("CS4","cs2","CS")
44 addCh("CS6","cs2","CS")
46 addCh("CS12","cs2","CS")
48 addCh("CS14","cs2","CS")
50 addCh("CS16","cs2","CS")
52 addCh("CS18","cs2","CS")
54 addCh("CS20","cs2","CS")
56 addCh("CS22","cs2","CS")
58 addCh("CS24","cs2","CS")
60 tv2ts.tv2b25ts(os.path.join(tmppath,"ch_"+str(ch)+".ts"), ch, "1")
61 if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts")):
62 os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts"))
66 def addCh(ch,bctype,chtxthead):
67 prglist=getChProgNum(ch)##[prglist,logt]
68 for lstr in prglist[0]:
69 #print [bctype,chtxthead+"_"+lstr, ch, lstr]
73 rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr, u"2010-01-01 00:00:00")
75 rec10d.rec10db.add_epg_ch(bctype,chtxthead+"_"+lstr, ch, lstr, u"2010-01-01 00:00:00")
76 except Exception, inst:
77 recdblist.addCommonlogEX("Warning", "addCh (scan_ch.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
78 checkB25Purchased(ch, prglist[1])
80 pout=os.path.join(tmppath,"ch_"+str(ch)+".ts")
81 logt=tv2ts.tv2tsmix(pout, ch, "10")
82 retl=getTsProgNum(ch,pout)
85 def getTsProgNum(ch,tspath):
87 pout=os.path.join(tmppath,"chscan.txt")
93 doexe = tssplitterp + " "+chopt+" \""+ pin + "\" \""+ pout + "\""
94 doexe = "nice -n 18 " + doexe
95 os.environ['LANG']="ja_JP.UTF-8"
96 txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8','ignore')
105 ret.append(str(int(l)))
108 recdblist.addLog(pin, doexe, u"TsSplitログ-コマンド")
109 recdblist.addLog(pin, txt, u"TsSplitログ-詳細")
117 def getB25UnparchasedList(logtxt):
120 for strt in logtxt.splitlines():
121 if strt.find("unpurchased ECM")>-1:
123 if strt.find("total TS packet")>-1 and warning>0:
125 if strt.find("channel")>-1 and warning>0:
126 txt=strt.replace("channel:","")
127 txt=txt.replace("\n","")
128 txt=txt.replace(" ","")
131 def checkB25Purchased(ch,logtxt):
132 chlists=chdb.searchAllCHFromCh(ch)
133 upl=getB25UnparchasedList(logtxt)
134 if len(upl)>0 and len(chlists)>0:
136 if chl['csch'] in upl:
137 chdb.changeCHShow(chl['chtxt'],"0")