3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2011 Yukikaze
17 tmppath = configreader.getConfPath("tmp")+"/"
18 tssplitterp = configreader.getConfPath("tssplitter")
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,240):#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 txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8','ignore')
124 ret.append(str(int(l)))
127 recdblist.addLog(pin, doexe, u"TsSplitログ-コマンド")
128 recdblist.addLog(pin, txt, u"TsSplitログ-詳細")
136 def getB25UnparchasedList(logtxt):
139 for strt in logtxt.splitlines():
140 if strt.find("unpurchased ECM")>-1:
142 if strt.find("total TS packet")>-1 and warning>0:
144 if strt.find("channel")>-1 and warning>0:
145 txt=strt.replace("channel:","")
146 txt=txt.replace("\n","")
147 txt=txt.replace(" ","")
150 def checkB25Purchased(ch,logtxt):
151 chlists=chdb.searchAllCHFromCh(ch)
152 upl=getB25UnparchasedList(logtxt)
153 if len(upl)>0 and len(chlists)>0:
155 if chl['csch'] in upl:
156 chdb.changeCHShow(chl['chtxt'],"0")