3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2012 Yukikaze
5 #import sys # モジュール属性 argv を取得するため
15 import recording_earth_pt1
16 mypath = str(os.path.dirname(os.path.abspath(__file__))) + "/"
17 def tv2tsmix(pout, ch, time,tsid="0",getlog=0):
18 tv2b25ts(pout + ".b25", ch, time,tsid)
19 txt=b252tsmix(pout + ".b25", pout)
21 #if os.access(pout, os.F_OK):
23 # os.remove(pout + ".b25")
26 def tv2ts(pout, ch, csch, time,tsid):
27 if ch.replace(" ","").replace("CS","").isdigit():
28 if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
29 status.changeBSCSRecording(1)
31 status.changeTERecording(1)
33 tv2b25ts(pout + ".b25", ch, time,tsid)
34 except Exception, inst:
35 recdblist.addCommonlogEX(u"Error",u"tv2ts(tv2ts.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
36 if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
37 status.changeBSCSRecording(-1)
39 status.changeTERecording(-1)
43 b252tsmix(pout + ".b25", pout + ".tsmix")
53 tsmix2ts(pout + ".tsmix", pout, tch)
54 if os.access(pout, os.F_OK):
56 #os.remove(path + "/" + t + ext)
60 def b252ts(pout, ch, csch):
61 b252tsmix(pout + ".b25", pout + ".tsmix")
63 if ch.replace(" ","").replace("CS","").isdigit():
72 tsmix2ts(pout + ".tsmix", pout, tch)
73 def tv2b25ts(pout, ch, time,tsid):
74 if recording_earth_pt1.useDVB()==0:
75 exe = configreader.getConfPath('recpt1')
76 if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
77 status.changeBSCSRecording(1)
79 status.changeTERecording(1)
81 doexe = exe + ' ' + ch + ' ' + time + ' \'' + pout + '\''
82 recdblist.printutf8(doexe)
83 recdblist.addLog(pout, doexe, u"recpt1ログ-コマンド")
84 recdblist.addLog(pout, unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8'), u"recpt1ログ-詳細")
85 except Exception, inst:
86 recdblist.addCommonlogEX(u"Error",u"tv2b25ts(tv2ts.py)", str(type(inst)),str(inst))
87 if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
88 status.changeBSCSRecording(-1)
90 status.changeTERecording(-1)
91 elif recording_earth_pt1.useDVB()==1:
92 if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
93 status.changeBSCSRecording(1)
95 status.changeTERecording(1)
97 recording_earth_pt1.record(ch,tsid,pout,time,0)
98 except Exception, inst:
99 recdblist.addCommonlogEX(u"Error",u"tv2b25ts(tv2ts.py)", str(type(inst)),str(inst))
100 if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
101 status.changeBSCSRecording(-1)
103 status.changeTERecording(-1)
104 if os.path.exists(pout):
109 def b252tsmix(pin, pout):
110 if not (os.path.exists(pout) and os.path.getsize(pin)>os.path.getsize(pout)*0.95 and os.path.getsize(pin)<os.path.getsize(pout)*1.05):
112 if configreader.getConfPath('b25_remote')=="1":
114 exe = configreader.getConfPath('b25_env')+" && "
116 inst=u"b25_remoteがオンになっていますが、b25_envが設定されていないかコメントアウトされています。"
117 recdblist.addCommonlogEX(u"Error",u"b252tsmix(tv2ts.py)", "",inst)
118 exe = exe + "nice -n 17 " + configreader.getConfPath('b25')
119 doexe = exe + u' \"' + pin + u'\" \"' + pout + u'\"'
120 recdblist.printutf8(doexe)
121 recdblist.addCommandSelfLog(pin,doexe)
122 txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8')
123 recdblist.addLog(pin, doexe, u"b25ログ-コマンド")
124 recdblist.addLog(pin, txt, u"b25ログ-詳細")
125 recdblist.addCommandLogZip(pin, "b25", "b25", doexe, txt)
127 def tsmix2ts(pin, pout, csch):#csch=0ならcsの処理をしない
128 tssplitterex=configreader.getConfPath("java")+" -jar "+configreader.getConfPath("jTsSplitter")
129 doexe =tssplitterex + " \""+ pin + "\" \""+ pout + "\" " + str(csch)
130 doexe = "nice -n 18 " + doexe
131 os.environ['LANG']="ja_JP.UTF-8"
132 txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8')
133 recdblist.addLog(pin, doexe, u"TsSplitログ-コマンド")
134 recdblist.addLog(pin, txt, u"TsSplitログ-詳細")
136 if os.access(pout, os.F_OK) and os.path.getsize(pout)>10*1000*1000: