3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
14 global REC_FINAL_RESERVE
15 global REC_ENCODE_GRID
16 global REC_ENCODE_LOCAL
18 global REC_MISS_ENCODE
20 global REC_KEYWORD_EVERY_SOME_DAYS
22 global REC_MISS_DECODE
23 global REC_TS_DECODE_QUE
24 global REC_TS_DECODING
25 global REC_TS_RECORDING
29 global REC_CHANGING_CANTAINER
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"
63 REC_MOVE_END = "move_end"
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"
76 verbose_level_now = 400
78 def printutf8(unicode,verbose_level=500):
79 print verbose_level_now
81 print verbose_level_now-verbose_level
82 if verbose_level_now > verbose_level:
84 str=unicode.encode('utf-8')
88 def printuft8ex(unicode,verbose_level=500,log_level=500):
89 str=unicode.encode('utf-8')
90 if verbose_level_now > verbose_level:
92 logfname="/var/log/rec10"
94 if log_level_now > log_level:
95 if os.path.exists(logfname):
99 def Commonlogex(type,place,inst,txt,verbose_level=500,log_level=500):
100 lt=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+u":"
102 lt=lt+u"["+type+u"] "+place+u" "+inst
104 lt=lt+u"["+type+u"] "+place+u" "+inst+u"\n"+txt
105 lt=lt.encode('utf-8')
106 logfname="/var/log/rec10"
108 if verbose_level_now > verbose_level:
110 if log_level_now > log_level:
111 if os.path.exists(logfname):
112 f=open(logfname,mode)
115 def addCommandLog(tspath,log_title,cmd,cmd_log=""):
116 addlog(tspath,cmd,log_title+u"ログ-コマンド")
117 addlog(tspath,cmd_log,log_title+u"ログ-詳細")
118 def addlog(tspath,txt,log_title):
120 logo=logo.replace("_1.wav",".ts")
121 logo=logo.replace("_2.wav",".ts")
122 logo=logo.replace("_1.aac",".ts")
123 logo=logo.replace("_2.aac",".ts")
124 logo=logo.replace("_1.mp3",".ts")
125 logo=logo.replace("_2.mp3",".ts")
126 logo=logo.replace(".ts.tsmix",".ts")
127 logo=logo.replace(".ts.b25",".ts")
128 logo=logo.replace(".sa.avi",".ts")
129 logo=logo.replace(".m2v",".ts")
130 logo=logo.replace(".avi",".ts")
131 logo=logo.replace(".mkv",".ts")
132 logo=logo.replace(".wav",".ts")
133 logo=logo.replace(".mp4",".ts")
134 logo=logo.replace(".mp3",".ts")
135 logo=logo.replace(".aac",".ts")
136 logo=logo.replace(".srt",".ts")
137 logo=logo.replace(".ts",".log")
142 stxt=txt[0:800]+"\n\n(ry..)\n"
143 st=txt[s-800:].find("\n")
145 stxt=stxt+txt[s-800+st:]
148 txtw= datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
149 txtw=txtw+"\n####"+log_title+"####\n"+stxt
150 f.write(txtw.encode('utf-8'))