3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2011 Yukikaze
17 tmppath = configreader.getConfPath("tmp")+"/"
18 if not os.path.exists(tmppath):
20 tssplitterp =configreader.getConfPath("java")+" -jar "+configreader.getConfPath("jTsSplitter")
22 rec10d.rec10db.change_installed_in_status(2)
24 for i in xrange(13,52):#62
25 recdblist.printuft8ex(u"チャンネルスキャン:地上デジタル CH "+str(i), 200, 200)
27 addCh(str(i),u"te"+str(i),str(i))
30 recdblist.printuft8ex(u"チャンネルスキャン:BSデジタル ", 200, 200)
31 for i in xrange(100,299):#240
32 recdblist.printuft8ex(u"チャンネルスキャン:BSデジタル CH "+str(i), 200, 200)
34 addCh(str(i),u"bs","BS")
37 #http://www5e.biglobe.ne.jp/~kazu_f/digital-sat/trapon-nsat110.html
41 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS2 ", 200, 200)
42 addCh("CS2","cs1","CS")
44 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS8", 200, 200)
45 addCh("CS8","cs1","CS")
47 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS10", 200, 200)
48 addCh("CS10","cs1","CS")
51 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS4", 200, 200)
52 addCh("CS4","cs2","CS")
54 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS6", 200, 200)
55 addCh("CS6","cs2","CS")
57 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS12", 200, 200)
58 addCh("CS12","cs2","CS")
60 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS14", 200, 200)
61 addCh("CS14","cs2","CS")
63 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS16", 200, 200)
64 addCh("CS16","cs2","CS")
66 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS18", 200, 200)
67 addCh("CS18","cs2","CS")
69 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS20", 200, 200)
70 addCh("CS20","cs2","CS")
72 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS22", 200, 200)
73 addCh("CS22","cs2","CS")
75 recdblist.printuft8ex(u"チャンネルスキャン:CSSデジタル CH:CS24", 200, 200)
76 addCh("CS24","cs2","CS")
77 rec10d.rec10db.change_installed_in_status(100)
79 tv2ts.tv2b25ts(os.path.join(tmppath,"ch_"+str(ch)+".ts"), ch, "1")
80 if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts")):
81 os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts"))
85 def addCh(ch,bctype,chtxthead):
86 prglist=getChProgNum(ch)##[prglist,logt]
87 for lstr in prglist[0]:
88 #print [bctype,chtxthead+"_"+lstr, ch, lstr]
92 tnow=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
93 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 tnow=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
96 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)
97 except Exception, inst:
98 recdblist.addCommonlogEX("Warning", "addCh (scan_ch.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
99 checkB25Purchased(ch, prglist[1])
100 def getChProgNum(ch):
101 pout=os.path.join(tmppath,"ch_"+str(ch)+".ts")
102 logt=tv2ts.tv2tsmix(pout, ch, "10")
103 retl=getTsProgNum(ch,pout)
106 def getTsProgNum(ch,tspath):
108 pout=os.path.join(tmppath,"chscan.txt")
114 doexe = tssplitterp + " "+chopt+" \""+ pin + "\" \""+ pout + "\""
115 doexe = "nice -n 18 " + doexe
116 os.environ['LANG']="ja_JP.UTF-8"
117 os.system(u"touch \""+pout+"\"")
118 txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8','ignore')
127 ret.append(str(int(l)))
130 recdblist.addLog(pin, doexe, u"TsSplitログ-コマンド")
131 recdblist.addLog(pin, txt, u"TsSplitログ-詳細")
139 def getB25UnparchasedList(logtxt):
142 for strt in logtxt.splitlines():
143 if strt.find("unpurchased ECM")>-1:
145 if strt.find("total TS packet")>-1 and warning>0:
147 if strt.find("channel")>-1 and warning>0:
148 txt=strt.replace("channel:","")
149 txt=txt.replace("\n","")
150 txt=txt.replace(" ","")
153 def checkB25Purchased(ch,logtxt):
154 chlists=chdb.searchAllCHFromCh(ch)
155 upl=getB25UnparchasedList(logtxt)
156 if len(upl)>0 and len(chlists)>0:
159 if chl['csch'] in upl:
160 chdb.changeCHShow(chl['chtxt'],"0")