OSDN Git Service

fix rename miss.
[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 os.path
7 import time
8 import traceback
9
10 import configreader
11 import status
12 import recdblist
13 mypath = str(os.path.dirname(os.path.abspath(__file__))) + "/"
14 def tv2tsmix(pout, ch, time):
15     tv2b25ts(pout + ".b25", ch, time)
16     b252tsmix(pout + ".b25", pout)
17     #if os.access(pout, os.F_OK):
18     #    try:
19     #        os.remove(pout + ".b25")
20     #    except:
21     #        ""
22 def tv2ts(pout, ch, csch, time):
23     ext = os.path.splitext(pout)[1]#ext=".なんたら"
24     tempt = os.path.split(pout)
25     path = tempt[0]
26     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
27         status.changeBSCSRecording(1)
28     else:
29         status.changeTERecording(1)
30     try:
31         tv2b25ts(pout + ".b25", ch, time)
32     except Exception, inst:
33         recdblist.addCommonlogEX(u"Error",u"tv2ts(tv2ts.py)", str(type(inst)),str(inst)+traceback.format_exc(),log_level=200)
34     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
35         status.changeBSCSRecording(-1)
36     else:
37         status.changeTERecording(-1)
38     b252tsmix(pout + ".b25", pout + ".tsmix")
39     tch="0"
40     if csch!=u"0":
41         tch=csch
42     elif ch==u"101":
43         tch="101"
44     elif ch==u"102":
45         tch="102"
46     #else:
47     #    tch=ch
48     tsmix2ts(pout + ".tsmix", pout, tch)
49     if os.access(pout, os.F_OK):
50         try:
51             #os.remove(path + "/" + t + ext)
52             ""
53         except:
54             ""
55 def b252ts(pout, ch, csch):
56     ext = os.path.splitext(pout)[1]#ext=".なんたら"
57     tempt = os.path.split(pout)
58     path = tempt[0]
59     b252tsmix(pout + ".b25", pout + ".tsmix")
60     tch=u"0"
61     if csch!=u"0":
62         tch=csch
63     elif ch==u"101":
64         tch=u"101"
65     elif ch==u"102":
66         tch=u"102"
67     #else:
68     #    tch=ch
69     tsmix2ts(pout + ".tsmix", pout, tch)
70     if os.access(pout, os.F_OK):
71         try:
72             #os.remove(path + "/" + t + ext)
73             ""
74         except:
75             ""
76 def tv2b25ts(pout, ch, time):
77     exe = configreader.getConfPath('recpt1')
78     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
79         status.changeBSCSRecording(1)
80     else:
81         status.changeTERecording(1)
82     try:
83         doexe = exe + ' ' + ch + ' ' + time + ' \'' + pout + '\''
84         recdblist.printutf8(doexe)
85         recdblist.addLog(pout, doexe, u"recpt1ログ-コマンド")
86         recdblist.addLog(pout, unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8'), u"recpt1ログ-詳細")
87     except Exception, inst:
88         recdblist.addCommonlogEX(u"Error",u"tv2b25ts(tv2ts.py)", str(type(inst)),str(inst))
89     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
90         status.changeBSCSRecording(-1)
91     else:
92         status.changeTERecording(-1)
93 def tv2b25ts_b25(pout, ch, time):
94     exe = configreader.getConfPath('recpt1')
95     doexe = exe + ' --b25 ' + ch + ' ' + time + ' \'' + pout + '\''
96     os.system(doexe)
97 def b252tsmix(pin, pout):
98     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):
99         exe=""
100         if configreader.getConfPath('b25_remote')=="1":
101             try:
102                 exe = configreader.getConfPath('b25_env')+" && "
103             except:
104                 inst=u"b25_remoteがオンになっていますが、b25_envが設定されていないかコメントアウトされています。"
105                 recdblist.addCommonlogEX(u"Error",u"b252tsmix(tv2ts.py)", "",inst)
106         exe = exe + "nice -n 17 " + configreader.getConfPath('b25')
107         doexe = exe + u' \"' + pin + u'\" \"' + pout + u'\"'
108         recdblist.printutf8(doexe)
109         txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8')
110         recdblist.addLog(pin, doexe, u"b25ログ-コマンド")
111         recdblist.addLog(pin, txt, u"b25ログ-詳細")
112 def tsmix2ts(pin, pout, csch):#csch=0ならcsの処理をしない
113     doexe = configreader.getConfPath("tssplitter") + " \""+ pin + "\" \""+ pout + "\" " + str(csch)
114     doexe = "nice -n 18 " + doexe
115     os.environ['LANG']="ja_JP.UTF-8"
116     txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8')
117     recdblist.addLog(pin, doexe, u"TsSplitログ-コマンド")
118     recdblist.addLog(pin, txt, u"TsSplitログ-詳細")
119     time.sleep(1)
120     if os.access(pout, os.F_OK) and os.path.getsize(pout)>10*1000*1000:
121         os.remove(pin)
122