OSDN Git Service

make it to rec10 0.5.9.0
[rec10/rec10-git.git] / rec10 / trunk / src / tv2ts.py
1 #!/usr/bin/python
2 # coding: UTF-8
3 #import sys # モジュール属性 argv を取得するため
4 import os
5 import shutil
6 import commands
7 import configreader
8 #import re
9 #import glob
10 import time
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="nice -n 17 "+doexe
80     txt=commands.getoutput(doexe)
81 def tsmix2ts(pin,pout,csch):#csch=0ならcsの処理をしない
82     if csch == "0":
83         time.sleep(1)
84         shutil.move(pin,pout)
85     else:
86         doexe=configreader.getpath("tssplitter_lite")+" \""+pin+"\" \""+pout+"\" "+str(csch)
87         doexe="nice -n 18 "+doexe
88         print doexe
89         os.system(doexe)
90         time.sleep(1)
91         if os.access(pout, os.F_OK):
92             os.remove(pin)
93