3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2012 Yukikaze
17 tmppath = configreader.getConfPath("tmp")+"/"
18 if not os.path.exists(tmppath):
20 tssplitterp =configreader.getConfPath("java")+" -jar "+configreader.getConfPath("jTsSplitter")
22 if rec10d.rec10db.select_installed_in_status()<2:
23 rec10d.rec10db.change_installed_in_status(2)
25 for i in xrange(13,52):#62
26 recdblist.printutf8ex(u"チャンネルスキャン:地上デジタル CH "+str(i), 200, 200)
28 addCh(str(i),u"te"+str(i),str(i))
31 recdblist.printutf8ex(u"チャンネルスキャン:BSデジタル ", 200, 200)
32 for i in xrange(100,299):#240
33 recdblist.printutf8ex(u"チャンネルスキャン:BSデジタル CH "+str(i), 200, 200)
35 addCh(str(i),u"bs","BS")
36 for i2 in xrange(0,11):
38 recdblist.printutf8ex(u"チャンネルスキャン:BSデジタル CH "+chi, 200, 200)
39 for ts_offset in xrange(0,3):
40 for ts_idx in xrange(0,7):
41 t_tsid=16384+chi*16+ts_offset*512+ts_idx
42 recdblist.printutf8ex(u"TransportID "+str(t_tsid), 200, 200)
43 if checkTs(chi,str(t_tsid))>0:
44 addCh(str(chi),u"bs","BS",str(t_tsid))
47 #http://www5e.biglobe.ne.jp/~kazu_f/digital-sat/trapon-nsat110.html
51 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS2 ", 200, 200)
52 addCh("CS2","cs1","CS")
54 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS8", 200, 200)
55 addCh("CS8","cs1","CS")
57 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS10", 200, 200)
58 addCh("CS10","cs1","CS")
61 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS4", 200, 200)
62 addCh("CS4","cs2","CS")
64 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS6", 200, 200)
65 addCh("CS6","cs2","CS")
67 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS12", 200, 200)
68 addCh("CS12","cs2","CS")
70 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS14", 200, 200)
71 addCh("CS14","cs2","CS")
73 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS16", 200, 200)
74 addCh("CS16","cs2","CS")
76 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS18", 200, 200)
77 addCh("CS18","cs2","CS")
79 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS20", 200, 200)
80 addCh("CS20","cs2","CS")
82 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS22", 200, 200)
83 addCh("CS22","cs2","CS")
85 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS24", 200, 200)
86 addCh("CS24","cs2","CS")
87 rec10d.rec10db.change_installed_in_status(100)
88 def checkTs(ch,tsid="0"):
89 if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts")):
90 os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts"))
91 if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts.b25")):
92 os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts.b25"))
93 tv2ts.tv2b25ts(os.path.join(tmppath,"ch_"+str(ch)+".ts"), ch, "1",tsid)
94 if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts.b25")):
95 os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts.b25"))
96 if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts")):
97 os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts"))
102 def addCh(ch,bctype,chtxthead,tsid="0"):
103 prglist=getChProgNum(ch)##[prglist,logt]
104 for lstr in prglist[0]:
105 #print [bctype,chtxthead+"_"+lstr, ch, lstr]
107 if int(lstr)<1000000:
110 tnow=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
111 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)
113 tnow=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
114 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)
115 except Exception, inst:
116 recdblist.addCommonlogEX("Warning", "addCh (scan_ch.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
117 checkB25Purchased(ch, prglist[1])
118 def getChProgNum(ch,tsid="0"):
119 pout=os.path.join(tmppath,"ch_"+str(ch)+".ts")
121 pout=os.path.join(tmppath,"ch_"+str(ch)+"_"+tsid+".ts")
122 logt=tv2ts.tv2tsmix(pout, ch, "10",tsid)
123 retl=getTsProgNum(ch,pout)
129 def getTsProgNum(ch,tspath):
131 pout=os.path.join(tmppath,"chscan.txt")
133 if ch.find("CS")>-1 or ch.find("BS")>-1 :
137 doexe = tssplitterp + " "+chopt+" \""+ pin + "\" \""+ pout + "\""
138 doexe = "nice -n 18 " + doexe
139 os.environ['LANG']="ja_JP.UTF-8"
140 os.system(u"touch \""+pout+"\"")
141 txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8','ignore')
150 ret.append(str(int(l)))
153 recdblist.addLog(pin, doexe, u"TsSplitログ-コマンド")
154 recdblist.addLog(pin, txt, u"TsSplitログ-詳細")
162 def getB25UnparchasedList(logtxt):
165 for strt in logtxt.splitlines():
166 if strt.find("unpurchased ECM")>-1:
168 if strt.find("total TS packet")>-1 and warning>0:
170 if strt.find("channel")>-1 and warning>0:
171 txt=strt.replace("channel:","")
172 txt=txt.replace("\n","")
173 txt=txt.replace(" ","")
176 def checkB25Purchased(ch,logtxt):
177 chlists=chdb.searchAllCHFromCh(ch)
178 upl=getB25UnparchasedList(logtxt)
179 if len(upl)>0 and len(chlists)>0:
182 if chl['csch'] in upl:
183 chdb.changeCHShow(chl['chtxt'],"0")