OSDN Git Service

fix log data.
[rec10/rec10-git.git] / rec10 / trunk / src / tv2ts.py
1 #!/usr/bin/python
2 # coding: UTF-8
3 #import sys # モジュール属性 argv を取得するため
4 import commands
5 import os
6 import shutil
7 import time
8 import sys
9
10 import configreader
11 import status
12 mypath = str(os.path.dirname(os.path.abspath(__file__))) + "/"
13 def tv2tsmix(pout, ch, time):
14     
15     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
16         status.setBSCSRecording(status.getBSCSRecording() + 1)
17     else:
18         status.setTERecording(status.getTERecording() + 1)
19     tv2b25ts(pout + ".b25", ch, time)
20     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
21         status.setBSCSRecording(status.getBSCSRecording()-1)
22     else:
23         status.setTERecording(status.getTERecording()-1)
24     
25     b252tsmix(pout + ".b25", pout)
26     #os.remove(pout+".b25")
27     if os.access(pout, os.F_OK):
28         try:
29             os.remove(pout + ".b25")
30         except:
31             ""
32 def tv2ts(pout, ch, csch, time):
33     ext = os.path.splitext(pout)[1]#ext=".なんたら"
34     tempt = os.path.split(pout)
35     path = tempt[0]
36     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
37         status.setBSCSRecording(status.getBSCSRecording() + 1)
38     else:
39         status.setTERecording(status.getTERecording() + 1)
40     tv2b25ts(pout + ".b25", ch, time)
41     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
42         status.setBSCSRecording(status.getBSCSRecording()-1)
43     else:
44         status.setTERecording(status.getTERecording()-1)
45     b252tsmix(pout + ".b25", pout + ".tsmix")
46     tsmix2ts(pout + ".tsmix", pout, csch)
47     #os.remove(path+"/"+t+"."+temp[1])
48     if os.access(pout, os.F_OK):
49         try:
50             os.remove(path + "/" + t + ext)
51         except:
52             ""
53 def b252ts(pout, ch, csch):
54     ext = os.path.splitext(pout)[1]#ext=".なんたら"
55     #t=hashlib.md5(pout).hexdigest()
56     tempt = os.path.split(pout)
57     path = tempt[0]
58     b252tsmix(pout + ".b25", pout + ".tsmix")
59     tsmix2ts(pout + ".tsmix", pout, csch)
60     if os.access(pout, os.F_OK):
61         try:
62             os.remove(path + "/" + t + ext)
63         except:
64             ""
65
66 def tv2b25ts(pout, ch, time):
67     exe = configreader.getpath('recpt1')
68     #print [exe,ch,time,pout]
69     #doexe=""
70     doexe = exe + ' ' + ch + ' ' + time + ' \'' + pout + '\''
71     os.system(doexe)
72 def tv2b25ts_b25(pout, ch, time):
73     exe = configreader.getpath('recpt1')
74     doexe = exe + ' --b25 ' + ch + ' ' + time + ' \'' + pout + '\''
75     os.system(doexe)
76 def b252tsmix(pin, pout):
77     exe = configreader.getpath('b25')
78     #doexe = exe.encode('utf-8') + u' \"' + pin.encode('utf-8') + u'\" \"' + pout.encode('utf-8') + u'\"'
79     doexe = exe + u' \"' + pin + u'\" \"' + pout + u'\"'
80     doexe = "nice -n 17 " + doexe
81     print doexe
82     sys.stdout.flush()
83     txt = commands.getoutput(doexe)
84     f=open(pin+".log",'w')
85     f.write(txt)
86     f.close()
87 def tsmix2ts(pin, pout, csch):#csch=0ならcsの処理をしない
88     if csch == "0":
89         time.sleep(1)
90         shutil.move(pin, pout)
91     else:
92         doexe = configreader.getpath("tssplitter_lite") + " \"" + pin + "\" \"" + pout + "\" " + str(csch)
93         doexe = "nice -n 18 " + doexe
94         print doexe
95         sys.stdout.flush()
96         os.system(doexe)
97         time.sleep(1)
98         if os.access(pout, os.F_OK):
99             os.remove(pin)
100