3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
17 global REC_FINAL_RESERVE
18 global REC_ENCODE_GRID
19 global REC_ENCODE_LOCAL
21 global REC_MISS_ENCODE
23 global REC_KEYWORD_EVERY_SOME_DAYS
25 global REC_MISS_DECODE
26 global REC_TS_DECODE_QUE
27 global REC_TS_DECODING
28 global REC_TS_RECORDING
32 global REC_CHANGING_CANTAINER
39 global REC_AUTO_SUGGEST_REC
40 global REC_AUTO_SUGGEST_DECODE
41 global REC_AUTO_SUGGEST_ENCODE
42 global REC_AUTO_SUGGEST_AVI2MP4
43 global REC_AUTO_SUGGEST_MKV2MP4
44 global REC_AUTO_SUGGEST_AVI2FP
45 global REC_AUTO_SUGGEST_AP2FP
46 global REC_BAYES_SUGGEST
47 global REC_AUTO_KEYWORD
48 REC_RESERVE = "reserve_flexible"
49 REC_FINAL_RESERVE = "reserve_fixed"
50 REC_ENCODE_GRID = "convert_ts_mp4_network"
51 REC_ENCODE_LOCAL = "convert_ts_mp4_running"
52 REC_ENCODE_QUE = "convert_ts_mp4"
53 REC_MISS_ENCODE = "convert_avi_mp4_miss"
54 REC_KEYWORD = "search_today"
55 REC_KEYWORD_EVERY_SOME_DAYS = "search_everyday"
56 REC_FIN_LOCAL = "convert_ts_mp4_finished"
57 REC_MISS_DECODE = "convert_b25_ts_miss"
58 REC_TS_DECODE_QUE = "convert_b25_ts"
59 REC_TS_DECODING = "convert_b25_ts_running"
60 REC_TS_RECORDING = "reserve_running"
61 REC_CHANGING_CANTAINER = "convert_mkv_mp4_runnings"
62 REC_AVI_TO_MKV = "convert_avi_mkv"
63 REC_AVI_TO_MP4 = "convert_avi_mp4"
64 REC_MKV_TO_MP4 = "convert_mkv_mp4"
66 REC_MOVE_END = "move_end"
68 REC_AUTO_SUGGEST_REC = "auto_suggest_rec"
69 REC_AUTO_SUGGEST_DECODE = "auto_suggest_dec"
70 REC_AUTO_SUGGEST_ENCODE = "auto_suggest_enc"
71 REC_AUTO_SUGGEST_AVI2FP = "auto_suggest_avi2fp"
72 REC_AUTO_SUGGEST_AP2FP = "auto_suggest_ap2fp"
73 REC_AUTO_KEYWORD = "auto_keyword"
74 REC_BAYES_SUGGEST ="bayes_suggest"
79 global verbose_level_now
83 log_level_now=int(configreader.getlog("log_level"))
84 verbose_level_now=int(configreader.getlog("verbose_level"))
88 def printutf8(unicode,verbose_level=500):
89 if verbose_level_now > verbose_level:
91 str=unicode.encode('utf-8')
93 except Exception, inst:
94 recdblist.Commonlogex("Error", "printutf8(recdblist.py)", str(type(inst)), str(inst)+traceback.format_exc(),log_level=200)
95 def printuft8ex(unicode,verbose_level=500,log_level=500):
96 str=unicode.encode('utf-8')
97 if verbose_level_now > verbose_level:
99 logfname="/var/log/rec10"
101 if log_level_now > log_level:
102 if os.path.exists(logfname):
103 f=open(logfname,mode)
106 def Commonlogex(type,place,inst,txt,verbose_level=500,log_level=500):
107 lt=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+u":"
109 lt=lt+u"["+type+u"] "+place+u" "+inst
111 lt=lt+u"["+type+u"] "+place+u" "+inst+u"\n"+txt
112 lt=lt.encode('utf-8')
113 logfname="/var/log/rec10"
115 if verbose_level_now > verbose_level:
117 if log_level_now > log_level:
118 if os.path.exists(logfname):
119 f=open(logfname,mode)
122 def addCommandLog(tspath,log_title,cmd,cmd_log=""):
123 addlog(tspath,cmd,log_title+u"ログ-コマンド")
124 addlog(tspath,cmd_log,log_title+u"ログ-詳細")
125 def addlog(tspath,txt,log_title):
127 logo=logo.replace("_1.wav",".ts")
128 logo=logo.replace("_2.wav",".ts")
129 logo=logo.replace("_1.aac",".ts")
130 logo=logo.replace("_2.aac",".ts")
131 logo=logo.replace("_1.mp3",".ts")
132 logo=logo.replace("_2.mp3",".ts")
133 logo=logo.replace(".ts.tsmix",".ts")
134 logo=logo.replace(".ts.b25",".ts")
135 logo=logo.replace(".sa.avi",".ts")
136 logo=logo.replace(".m2v",".ts")
137 logo=logo.replace(".avi",".ts")
138 logo=logo.replace(".mkv",".ts")
139 logo=logo.replace(".wav",".ts")
140 logo=logo.replace(".mp4",".ts")
141 logo=logo.replace(".mp3",".ts")
142 logo=logo.replace(".aac",".ts")
143 logo=logo.replace(".srt",".ts")
144 logo=logo.replace(".ts",".log")
149 stxt=txt[0:800]+"\n\n(ry..)\n"
150 st=txt[s-800:].find("\n")
152 stxt=stxt+txt[s-800+st:]
155 txtw= datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
156 txtw=txtw+"\n####"+log_title+"####\n"+stxt
157 f.write(txtw.encode('utf-8'))