OSDN Git Service

implement encode tester.
[rec10/rec10-git.git] / rec10 / trunk / src / recdblist.py
1 #!/usr/bin/python
2 # coding: UTF-8
3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
5
6 """
7 task names
8 """
9 import datetime
10 import os
11 import os.path
12
13 global REC_RESERVE
14 global REC_FINAL_RESERVE
15 global REC_ENCODE_GRID
16 global REC_ENCODE_LOCAL
17 global REC_ENCODE_QUE
18 global REC_MISS_ENCODE
19 global REC_KEYWORD
20 global REC_KEYWORD_EVERY_SOME_DAYS
21 global REC_FIN_LOCAL
22 global REC_MISS_DECODE
23 global REC_TS_DECODE_QUE
24 global REC_TS_DECODING
25 global REC_TS_RECORDING
26 global REC_AVI_TO_MKV
27 global REC_AVI_TO_MP4
28 global REC_MKV_TO_MP4
29 global REC_CHANGING_CANTAINER
30
31 #ここから処理のちに移動
32
33 global REC_MOVE_END
34
35 #ここから自動で提起される処理。
36 global REC_AUTO_SUGGEST_REC
37 global REC_AUTO_SUGGEST_DECODE
38 global REC_AUTO_SUGGEST_ENCODE
39 global REC_AUTO_SUGGEST_AVI2MP4
40 global REC_AUTO_SUGGEST_MKV2MP4
41 global REC_AUTO_SUGGEST_AVI2FP
42 global REC_AUTO_SUGGEST_AP2FP
43 global REC_BAYES_SUGGEST
44 global REC_AUTO_KEYWORD
45 REC_RESERVE = "reserve_flexible"
46 REC_FINAL_RESERVE = "reserve_fixed"
47 REC_ENCODE_GRID = "convert_ts_mp4_network"
48 REC_ENCODE_LOCAL = "convert_ts_mp4_running"
49 REC_ENCODE_QUE = "convert_ts_mp4"
50 REC_MISS_ENCODE = "convert_avi_mp4_miss"
51 REC_KEYWORD = "search_today"
52 REC_KEYWORD_EVERY_SOME_DAYS = "search_everyday"
53 REC_FIN_LOCAL = "convert_ts_mp4_finished"
54 REC_MISS_DECODE = "convert_b25_ts_miss"
55 REC_TS_DECODE_QUE = "convert_b25_ts"
56 REC_TS_DECODING = "convert_b25_ts_running"
57 REC_TS_RECORDING = "reserve_running"
58 REC_CHANGING_CANTAINER = "convert_mkv_mp4_runnings"
59 REC_AVI_TO_MKV = "convert_avi_mkv"
60 REC_AVI_TO_MP4 = "convert_avi_mp4"
61 REC_MKV_TO_MP4 = "convert_mkv_mp4"
62
63 REC_MOVE_END = "move_end"
64
65 REC_AUTO_SUGGEST_REC = "auto_suggest_rec"
66 REC_AUTO_SUGGEST_DECODE = "auto_suggest_dec"
67 REC_AUTO_SUGGEST_ENCODE = "auto_suggest_enc"
68 REC_AUTO_SUGGEST_AVI2FP = "auto_suggest_avi2fp"
69 REC_AUTO_SUGGEST_AP2FP = "auto_suggest_ap2fp"
70 REC_AUTO_KEYWORD = "auto_keyword"
71 REC_BAYES_SUGGEST ="bayes_suggest"
72
73 version = 96
74 version_str="0.9.6"
75 def printutf8(unicode):
76     str=unicode.encode('utf-8')
77     print str
78 def printuft8ex(unicode):
79     str=unicode.encode('utf-8')
80     print str
81     logfname="/var/log/rec10"
82     mode="a"
83     if os.path.exists(logfname):
84         f=open(logfname,mode)
85         f.write(str+"\n")
86         f.close()
87 def Commonlogex(type,place,inst,txt=""):
88     lt=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+u":"
89     if txt=="":
90         lt=lt+u"["+type+u"] "+place+u" "+inst
91     else:
92         lt=lt+u"["+type+u"] "+place+u" "+inst+u"\n"+txt
93     lt=lt.encode('utf-8')
94     logfname="/var/log/rec10"
95     mode="a"
96     print lt
97     if os.path.exists(logfname):
98         f=open(logfname,mode)
99         f.write(lt+"\n")
100         f.close()
101 def addCommandLog(tspath,log_title,cmd,cmd_log=""):
102     addlog(tspath,cmd,log_title+u"ログ-コマンド")
103     addlog(tspath,cmd_log,log_title+u"ログ-詳細")
104 def addlog(tspath,txt,log_title):
105     logo=tspath
106     logo=logo.replace("_1.wav",".ts")
107     logo=logo.replace("_2.wav",".ts")
108     logo=logo.replace("_1.aac",".ts")
109     logo=logo.replace("_2.aac",".ts")
110     logo=logo.replace("_1.mp3",".ts")
111     logo=logo.replace("_2.mp3",".ts")
112     logo=logo.replace(".ts.tsmix",".ts")
113     logo=logo.replace(".ts.b25",".ts")
114     logo=logo.replace(".sa.avi",".ts")
115     logo=logo.replace(".m2v",".ts")
116     logo=logo.replace(".avi",".ts")
117     logo=logo.replace(".mkv",".ts")
118     logo=logo.replace(".wav",".ts")
119     logo=logo.replace(".mp4",".ts")
120     logo=logo.replace(".mp3",".ts")
121     logo=logo.replace(".aac",".ts")
122     logo=logo.replace(".srt",".ts")
123     logo=logo.replace(".ts",".log")
124     f=open(logo,'a')
125     s=len(txt)
126     stxt=""
127     if s>1600:
128         stxt=txt[0:800]+"\n\n(ry..)\n"
129         st=txt[s-800:].find("\n")
130         if st>0:
131             stxt=stxt+txt[s-800+st:]
132     else:
133         stxt=txt
134     txtw= datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
135     txtw=txtw+"\n####"+log_title+"####\n"+stxt
136     f.write(txtw.encode('utf-8'))
137     f.close()