3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2011 Yukikaze
17 tmppath = configreader.getConfPath("tmp")+"/"
18 tssplitterp =configreader.getConfPath("java")+" -jar "+configreader.getConfPath("jTsSplitter")
20 rec10d.rec10db.change_installed_in_status(2)
22 for i in xrange(13,62):#62
23 recdblist.printuft8ex(u"チャンネルスキャン:地上デジタル CH "+str(i), 200, 200)
25 addCh(str(i),u"te"+str(i),str(i))
28 recdblist.printuft8ex(u"チャンネルスキャン:BSデジタル ", 200, 200)
29 for i in xrange(100,280):#240
30 recdblist.printuft8ex(u"チャンネルスキャン:BSデジタル CH "+str(i), 200, 200)
32 addCh(str(i),u"bs","BS")
35 #http://www5e.biglobe.ne.jp/~kazu_f/digital-sat/trapon-nsat110.html
39 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS2 ", 200, 200)
40 addCh("CS2","cs1","CS")
42 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS8", 200, 200)
43 addCh("CS8","cs1","CS")
45 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS10", 200, 200)
46 addCh("CS10","cs1","CS")
49 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS4", 200, 200)
50 addCh("CS4","cs2","CS")
52 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS6", 200, 200)
53 addCh("CS6","cs2","CS")
55 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS12", 200, 200)
56 addCh("CS12","cs2","CS")
58 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS14", 200, 200)
59 addCh("CS14","cs2","CS")
61 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS16", 200, 200)
62 addCh("CS16","cs2","CS")
64 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS18", 200, 200)
65 addCh("CS18","cs2","CS")
67 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS20", 200, 200)
68 addCh("CS20","cs2","CS")
70 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS22", 200, 200)
71 addCh("CS22","cs2","CS")
73 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS24", 200, 200)
74 addCh("CS24","cs2","CS")
75 rec10d.rec10db.change_installed_in_status(100)
77 tv2ts.tv2b25ts(os.path.join(tmppath,"ch_"+str(ch)+".ts"), ch, "1")
78 if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts")):
79 os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts"))
83 def addCh(ch,bctype,chtxthead):
84 prglist=getChProgNum(ch)##[prglist,logt]
85 for lstr in prglist[0]:
86 #print [bctype,chtxthead+"_"+lstr, ch, lstr]
90 tnow=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
91 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)
93 tnow=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
94 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)
95 except Exception, inst:
96 recdblist.addCommonlogEX("Warning", "addCh (scan_ch.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
97 checkB25Purchased(ch, prglist[1])
99 pout=os.path.join(tmppath,"ch_"+str(ch)+".ts")
100 logt=tv2ts.tv2tsmix(pout, ch, "10")
101 retl=getTsProgNum(ch,pout)
104 def getTsProgNum(ch,tspath):
106 pout=os.path.join(tmppath,"chscan.txt")
112 doexe = tssplitterp + " "+chopt+" \""+ pin + "\" \""+ pout + "\""
113 doexe = "nice -n 18 " + doexe
114 os.environ['LANG']="ja_JP.UTF-8"
115 os.system(u"touch \""+pout+"\"")
116 txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8','ignore')
125 ret.append(str(int(l)))
128 recdblist.addLog(pin, doexe, u"TsSplitログ-コマンド")
129 recdblist.addLog(pin, txt, u"TsSplitログ-詳細")
137 def getB25UnparchasedList(logtxt):
140 for strt in logtxt.splitlines():
141 if strt.find("unpurchased ECM")>-1:
143 if strt.find("total TS packet")>-1 and warning>0:
145 if strt.find("channel")>-1 and warning>0:
146 txt=strt.replace("channel:","")
147 txt=txt.replace("\n","")
148 txt=txt.replace(" ","")
151 def checkB25Purchased(ch,logtxt):
152 chlists=chdb.searchAllCHFromCh(ch)
153 upl=getB25UnparchasedList(logtxt)
154 if len(upl)>0 and len(chlists)>0:
157 if chl['csch'] in upl:
158 chdb.changeCHShow(chl['chtxt'],"0")