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)
40 addCh(str(chi),u"bs","BS")
43 #http://www5e.biglobe.ne.jp/~kazu_f/digital-sat/trapon-nsat110.html
47 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS2 ", 200, 200)
48 addCh("CS2","cs1","CS")
50 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS8", 200, 200)
51 addCh("CS8","cs1","CS")
53 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS10", 200, 200)
54 addCh("CS10","cs1","CS")
57 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS4", 200, 200)
58 addCh("CS4","cs2","CS")
60 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS6", 200, 200)
61 addCh("CS6","cs2","CS")
63 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS12", 200, 200)
64 addCh("CS12","cs2","CS")
66 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS14", 200, 200)
67 addCh("CS14","cs2","CS")
69 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS16", 200, 200)
70 addCh("CS16","cs2","CS")
72 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS18", 200, 200)
73 addCh("CS18","cs2","CS")
75 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS20", 200, 200)
76 addCh("CS20","cs2","CS")
78 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS22", 200, 200)
79 addCh("CS22","cs2","CS")
81 recdblist.printutf8ex(u"チャンネルスキャン:CSSデジタル CH:CS24", 200, 200)
82 addCh("CS24","cs2","CS")
83 rec10d.rec10db.change_installed_in_status(100)
85 if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts")):
86 os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts"))
87 if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts.b25")):
88 os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts.b25"))
89 tv2ts.tv2b25ts(os.path.join(tmppath,"ch_"+str(ch)+".ts"), ch, "1")
90 if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts.b25")):
91 os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts.b25"))
92 if os.path.exists(os.path.join(tmppath,"ch_"+str(ch)+".ts")):
93 os.remove(os.path.join(tmppath,"ch_"+str(ch)+".ts"))
98 def addCh(ch,bctype,chtxthead):
99 prglist=getChProgNum(ch)##[prglist,logt]
100 for lstr in prglist[0]:
101 #print [bctype,chtxthead+"_"+lstr, ch, lstr]
103 if int(lstr)<1000000:
106 tnow=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
107 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)
109 tnow=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
110 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)
111 except Exception, inst:
112 recdblist.addCommonlogEX("Warning", "addCh (scan_ch.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
113 checkB25Purchased(ch, prglist[1])
114 def getChProgNum(ch):
115 pout=os.path.join(tmppath,"ch_"+str(ch)+".ts")
116 logt=tv2ts.tv2tsmix(pout, ch, "10")
117 retl=getTsProgNum(ch,pout)
123 def getTsProgNum(ch,tspath):
125 pout=os.path.join(tmppath,"chscan.txt")
127 if ch.find("CS")>-1 or ch.find("BS")>-1 :
131 doexe = tssplitterp + " "+chopt+" \""+ pin + "\" \""+ pout + "\""
132 doexe = "nice -n 18 " + doexe
133 os.environ['LANG']="ja_JP.UTF-8"
134 os.system(u"touch \""+pout+"\"")
135 txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8','ignore')
144 ret.append(str(int(l)))
147 recdblist.addLog(pin, doexe, u"TsSplitログ-コマンド")
148 recdblist.addLog(pin, txt, u"TsSplitログ-詳細")
156 def getB25UnparchasedList(logtxt):
159 for strt in logtxt.splitlines():
160 if strt.find("unpurchased ECM")>-1:
162 if strt.find("total TS packet")>-1 and warning>0:
164 if strt.find("channel")>-1 and warning>0:
165 txt=strt.replace("channel:","")
166 txt=txt.replace("\n","")
167 txt=txt.replace(" ","")
170 def checkB25Purchased(ch,logtxt):
171 chlists=chdb.searchAllCHFromCh(ch)
172 upl=getB25UnparchasedList(logtxt)
173 if len(upl)>0 and len(chlists)>0:
176 if chl['csch'] in upl:
177 chdb.changeCHShow(chl['chtxt'],"0")