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