1 | 1a2
|
---|
2 | > # -*- coding: utf-8 -*-
|
---|
3 | 33c34
|
---|
4 | < # ProjectX - 0.90.4.00
|
---|
5 | ---
|
---|
6 | > # ProjectX - >=0.91
|
---|
7 | 38a40,45
|
---|
8 | >
|
---|
9 | > # All strings in this file should be unicode, not byte string!! They get converted to utf-8 only
|
---|
10 | >
|
---|
11 | >
|
---|
12 | >
|
---|
13 | >
|
---|
14 | 258a266,267
|
---|
15 | >
|
---|
16 | > text = text.encode("utf-8", "replace")
|
---|
17 | 272a282
|
---|
18 | > write("See mythburn.log for more information.")
|
---|
19 | 307c317
|
---|
20 | < """return the number of CPU's"""
|
---|
21 | ---
|
---|
22 | > """return the number of CPUs"""
|
---|
23 | 341c351
|
---|
24 | < # Escape quotes in a filename
|
---|
25 | ---
|
---|
26 | > # Escape quotes in a command line argument
|
---|
27 | 343,346c353,356
|
---|
28 | < def quoteFilename(filename):
|
---|
29 | < filename = filename.replace('"', '\\"')
|
---|
30 | < filename = filename.replace('`', '\\`')
|
---|
31 | < return '"%s"' % filename
|
---|
32 | ---
|
---|
33 | > def quoteCmdArg(arg):
|
---|
34 | > arg = arg.replace('"', '\\"')
|
---|
35 | > arg = arg.replace('`', '\\`')
|
---|
36 | > return '"%s"' % arg
|
---|
37 | 417a428,440
|
---|
38 | > # Romoves all the objects from a directory
|
---|
39 | >
|
---|
40 | > def deleteEverythingInFolder(folder):
|
---|
41 | > for root, dirs, files in os.walk(folder, topdown=False):
|
---|
42 | > for name in files:
|
---|
43 | > os.remove(os.path.join(root, name))
|
---|
44 | > for name in dirs:
|
---|
45 | > if os.path.islink(os.path.join(root, name)):
|
---|
46 | > os.remove(os.path.join(root, name))
|
---|
47 | > else:
|
---|
48 | > os.rmdir(os.path.join(root, name))
|
---|
49 | >
|
---|
50 | > #############################################################
|
---|
51 | 436c459,466
|
---|
52 | < result = os.system(command)
|
---|
53 | ---
|
---|
54 | > # mytharchivehelper needes this locale to work correctly
|
---|
55 | > try:
|
---|
56 | > oldlocale = os.environ["LC_ALL"]
|
---|
57 | > except:
|
---|
58 | > oldlocale = ""
|
---|
59 | > os.putenv("LC_ALL", "en_US.UTF-8")
|
---|
60 | > result = os.system(command.encode('utf-8'))
|
---|
61 | > os.putenv("LC_ALL", oldlocale)
|
---|
62 | 467,468c497,498
|
---|
63 | < command = path_jpeg2yuv[0] + " -n %s -v0 -I p -f %s -j '%s' | %s -b 5000 -a %s -v 1 -f 8 -o '%s'" \
|
---|
64 | < % (totalframes, framespersecond, background, path_mpeg2enc[0], aspectratio, tempvideo)
|
---|
65 | ---
|
---|
66 | > command = quoteCmdArg(path_jpeg2yuv[0]) + " -n %s -v0 -I p -f %s -j %s | %s -b 5000 -a %s -v 1 -f 8 -o %s" \
|
---|
67 | > % (totalframes, framespersecond, quoteCmdArg(background), quoteCmdArg(path_mpeg2enc[0]), aspectratio, quoteCmdArg(tempvideo))
|
---|
68 | 473c503
|
---|
69 | < command = path_mplex[0] + " -f 8 -v 0 -o '%s' '%s' '%s'" % (tempmovie, tempvideo, music)
|
---|
70 | ---
|
---|
71 | > command = quoteCmdArg(path_mplex[0]) + " -f 8 -v 0 -o %s %s %s" % (quoteCmdArg(tempmovie), quoteCmdArg(tempvideo), quoteCmdArg(music))
|
---|
72 | 479c509
|
---|
73 | < command = path_spumux[0] + " -m dvd -s 0 '%s' < '%s' > '%s'" % (xmlfile, tempmovie, finaloutput)
|
---|
74 | ---
|
---|
75 | > command = quoteCmdArg(path_spumux[0]) + " -m dvd -s 0 %s < %s > %s" % (quoteCmdArg(xmlfile), quoteCmdArg(tempmovie), quoteCmdArg(finaloutput))
|
---|
76 | 1434c1464
|
---|
77 | < print "Node = %s, Data = %s" % (k, v)
|
---|
78 | ---
|
---|
79 | > write( "Node = %s, Data = %s" % (k, v))
|
---|
80 | 1436c1466,1472
|
---|
81 | < node.appendChild(infoDOM.createTextNode(str(v)))
|
---|
82 | ---
|
---|
83 | > # v may be either an integer. Therefore we have to
|
---|
84 | > # convert it to an unicode-string
|
---|
85 | > # If it is already a string it is not encoded as all
|
---|
86 | > # strings in this script are unicode. As no
|
---|
87 | > # encoding-argument is supplied to unicode() it does
|
---|
88 | > # nothing in this case.
|
---|
89 | > node.appendChild(infoDOM.createTextNode(unicode(v)))
|
---|
90 | 1500c1536
|
---|
91 | < cmd += "-i '%s' -f ac3 -ab 192k -ar 48000 '%s'" % (sourcefile, destinationfile)
|
---|
92 | ---
|
---|
93 | > cmd += "-i %s -f ac3 -ab 192k -ar 48000 %s" % (quoteCmdArg(sourcefile), quoteCmdArg(destinationfile))
|
---|
94 | 1594c1630
|
---|
95 | < command = os.path.join(scriptpath, "testsubtitlepngs.sh") + " %s/stream.d/spumux.xml" % (os.path.dirname(destination))
|
---|
96 | ---
|
---|
97 | > command = quoteCmdArg(os.path.join(scriptpath, "testsubtitlepngs.sh")) + " " + quoteCmdArg(os.path.dirname(destination) + "/stream.d/spumux.xml")
|
---|
98 | 1600c1636
|
---|
99 | < command = path_spumux[0] + " -P %s/stream.d/spumux.xml <%s >%s" % (os.path.dirname(destination), destination, os.path.splitext(destination)[0] + "-sub.mpg")
|
---|
100 | ---
|
---|
101 | > command = quoteCmdArg(path_spumux[0]) + " -P %s <%s >%s" % (quoteCmdArg(os.path.dirname(destination) + "/stream.d/spumux.xml"), quoteCmdArg(destination), quoteCmdArg(os.path.splitext(destination)[0] + "-sub.mpg"))
|
---|
102 | 1618,1619c1654,1656
|
---|
103 | < filename = quoteFilename(filename)
|
---|
104 | < command = "mytharchivehelper -q -q --getfileinfo --infile %s --outfile %s --method %d" % (filename, xmlFilename, lenMethod)
|
---|
105 | ---
|
---|
106 | >
|
---|
107 | > command = "mytharchivehelper -q -q --getfileinfo --infile %s --outfile %s --method %d" % (quoteCmdArg(filename), quoteCmdArg(xmlFilename), lenMethod)
|
---|
108 | >
|
---|
109 | 1629c1666
|
---|
110 | < write("streaminfo.xml :-\n" + infoDOM.toprettyxml(" ", ""), False)
|
---|
111 | ---
|
---|
112 | > write(xmlFilename + ":-\n" + infoDOM.toprettyxml(" ", ""), False)
|
---|
113 | 1675c1712
|
---|
114 | < command = "mythtranscode --mpeg2 --honorcutlist %s --infile %s --outfile %s" % (cutlist_s, localfile, destination)
|
---|
115 | ---
|
---|
116 | > command = "mythtranscode --mpeg2 --honorcutlist %s --infile %s --outfile %s" % (cutlist_s, quoteCmdArg(localfile), quoteCmdArg(destination))
|
---|
117 | 1677c1714
|
---|
118 | < command = "mythtranscode --mpeg2 -i %s -o %s" % (localfile, destination)
|
---|
119 | ---
|
---|
120 | > command = "mythtranscode --mpeg2 --infile %s --outfile %s" % (quoteCmdArg(localfile), quoteCmdArg(destination))
|
---|
121 | 1680c1717
|
---|
122 | < command = "mythtranscode --mpeg2 --honorcutlist --chanid %s --starttime %s --outfile %s" % (chanid, starttime, destination)
|
---|
123 | ---
|
---|
124 | > command = "mythtranscode --mpeg2 --honorcutlist --chanid %s --starttime %s --outfile %s" % (chanid, starttime, quoteCmdArg(destination))
|
---|
125 | 1682c1719
|
---|
126 | < command = "mythtranscode --mpeg2 --chanid %s --starttime %s --outfile %s" % (chanid, starttime, destination)
|
---|
127 | ---
|
---|
128 | > command = "mythtranscode --mpeg2 --chanid %s --starttime %s --outfile %s" % (chanid, starttime, quoteCmdArg(destination))
|
---|
129 | 1739,1740d1775
|
---|
130 | < pxbasename = os.path.splitext(os.path.basename(file))[0]
|
---|
131 | <
|
---|
132 | 1745,1751c1780
|
---|
133 | <
|
---|
134 | < qdestdir = quoteFilename(folder)
|
---|
135 | < qpxbasename = quoteFilename(pxbasename)
|
---|
136 | < qfile = quoteFilename(file)
|
---|
137 | < qcutlist = os.path.join(folder, "cutlist_x.txt")
|
---|
138 | <
|
---|
139 | < command = path_projectx[0] + " -id %s" % getStreamList(folder)
|
---|
140 | ---
|
---|
141 | > command = quoteCmdArg(path_projectx[0]) + " %s -id '%s' -set ExternPanel.appendPidToFileName=1 -out %s -name stream" % (quoteCmdArg(file), getStreamList(folder), quoteCmdArg(folder))
|
---|
142 | 1753,1756c1782
|
---|
143 | < command += " -cut %s -out %s -name %s %s" % (qcutlist, qdestdir, qpxbasename, qfile)
|
---|
144 | < else:
|
---|
145 | < command += " -out %s -name %s %s" % (qdestdir, qpxbasename, qfile)
|
---|
146 | <
|
---|
147 | ---
|
---|
148 | > command += " -cut %s" % quoteCmdArg(os.path.join(folder, "cutlist_x.txt"))
|
---|
149 | 1758d1783
|
---|
150 | <
|
---|
151 | 1768c1793,1849
|
---|
152 | < renameProjectXFiles(folder, pxbasename)
|
---|
153 | ---
|
---|
154 | > video, audio1, audio2 = selectStreams(folder)
|
---|
155 | > if addSubtitles:
|
---|
156 | > subtitles = selectSubtitleStream(folder)
|
---|
157 | >
|
---|
158 | > videoID_hex = "0x%x" % video[VIDEO_ID]
|
---|
159 | > if audio1[AUDIO_ID] != -1:
|
---|
160 | > audio1ID_hex = "0x%x" % audio1[AUDIO_ID]
|
---|
161 | > else:
|
---|
162 | > audio1ID_hex = ""
|
---|
163 | > if audio2[AUDIO_ID] != -1:
|
---|
164 | > audio2ID_hex = "0x%x" % audio2[AUDIO_ID]
|
---|
165 | > else:
|
---|
166 | > audio2ID_hex = ""
|
---|
167 | > if addSubtitles and subtitles[SUBTITLE_ID] != -1:
|
---|
168 | > subtitlesID_hex = "0x%x" % subtitles[SUBTITLE_ID]
|
---|
169 | > else:
|
---|
170 | > subtitlesID_hex = ""
|
---|
171 | >
|
---|
172 | >
|
---|
173 | > files = os.listdir(folder)
|
---|
174 | > for file in files:
|
---|
175 | > if file[0:9] == "stream{0x": # don't rename files that have already been renamed
|
---|
176 | > PID = file[7:13]
|
---|
177 | > SubID = file[19:23]
|
---|
178 | > if PID == videoID_hex or SubID == videoID_hex:
|
---|
179 | > os.rename(os.path.join(folder, file), os.path.join(folder, "stream.mv2"))
|
---|
180 | > elif PID == audio1ID_hex or SubID == audio1ID_hex:
|
---|
181 | > os.rename(os.path.join(folder, file), os.path.join(folder, "stream0." + file[-3:]))
|
---|
182 | > elif PID == audio2ID_hex or SubID == audio2ID_hex:
|
---|
183 | > os.rename(os.path.join(folder, file), os.path.join(folder, "stream1." + file[-3:]))
|
---|
184 | > elif PID == subtitlesID_hex or SubID == subtitlesID_hex:
|
---|
185 | > if file[-3:] == "sup":
|
---|
186 | > os.rename(os.path.join(folder, file), os.path.join(folder, "stream.sup"))
|
---|
187 | > else:
|
---|
188 | > os.rename(os.path.join(folder, file), os.path.join(folder, "stream.sup.IFO"))
|
---|
189 | >
|
---|
190 | >
|
---|
191 | > # Fallback if assignment and renaming by ID failed
|
---|
192 | >
|
---|
193 | > files = os.listdir(folder)
|
---|
194 | > for file in files:
|
---|
195 | > if file[0:9] == "stream{0x": # don't rename files that have already been renamed
|
---|
196 | > if not os.path.exists(os.path.join(folder, "stream.mv2")) and file[-3:] == "m2v":
|
---|
197 | > os.rename(os.path.join(folder, file), os.path.join(folder, "stream.mv2"))
|
---|
198 | > elif not (os.path.exists(os.path.join(folder, "stream0.ac3")) or os.path.exists(os.path.join(folder, "stream0.mp2"))) and file[-3:] == "ac3":
|
---|
199 | > os.rename(os.path.join(folder, file), os.path.join(folder, "stream0.ac3"))
|
---|
200 | > elif not (os.path.exists(os.path.join(folder, "stream0.ac3")) or os.path.exists(os.path.join(folder, "stream0.mp2"))) and file[-3:] == "mp2":
|
---|
201 | > os.rename(os.path.join(folder, file), os.path.join(folder, "stream0.mp2"))
|
---|
202 | > elif not (os.path.exists(os.path.join(folder, "stream1.ac3")) or os.path.exists(os.path.join(folder, "stream1.mp2"))) and file[-3:] == "ac3":
|
---|
203 | > os.rename(os.path.join(folder, file), os.path.join(folder, "stream1.ac3"))
|
---|
204 | > elif not (os.path.exists(os.path.join(folder, "stream1.ac3")) or os.path.exists(os.path.join(folder, "stream1.mp2"))) and file[-3:] == "mp2":
|
---|
205 | > os.rename(os.path.join(folder, file), os.path.join(folder, "stream1.mp2"))
|
---|
206 | > elif not os.path.exists(os.path.join(folder, "stream.sup")) and file[-3:] == "sup":
|
---|
207 | > os.rename(os.path.join(folder, file), os.path.join(folder, "stream.sup"))
|
---|
208 | > elif not os.path.exists(os.path.join(folder, "stream.sup.IFO")) and file[-3:] == "IFO":
|
---|
209 | > os.rename(os.path.join(folder, file), os.path.join(folder, "stream.sup.IFO"))
|
---|
210 | >
|
---|
211 | 1777c1858
|
---|
212 | < command += " --infile %s --ifofile %s --delay 0" % (os.path.join(folder, "stream.sup"), os.path.join(folder, "stream.sup.IFO"))
|
---|
213 | ---
|
---|
214 | > command += " --infile %s --ifofile %s --delay 0" % (quoteCmdArg(os.path.join(folder, "stream.sup")), quoteCmdArg(os.path.join(folder, "stream.sup.IFO")))
|
---|
215 | 1792,1912d1872
|
---|
216 | < # find the required stream files and rename them
|
---|
217 | <
|
---|
218 | < def renameProjectXFiles(folder, pxbasename):
|
---|
219 | <
|
---|
220 | < write("renameProjectXFiles start -----------------------------------------", False)
|
---|
221 | < logf = open(os.path.join(folder, pxbasename + "_log.txt"))
|
---|
222 | < logdata = logf.readlines()
|
---|
223 | < logf.close()
|
---|
224 | <
|
---|
225 | < # find stream PIDs and Files
|
---|
226 | < streamIds = []
|
---|
227 | < streamFiles = []
|
---|
228 | < for line in logdata:
|
---|
229 | < tokens = line.split()
|
---|
230 | < if len(tokens) > 0:
|
---|
231 | < if tokens[0] == "++>":
|
---|
232 | < # From ProjectX/resources/pjxresources_en.properties:
|
---|
233 | < if tokens[1] == "Mpg":
|
---|
234 | < if tokens[2] == "Video:":
|
---|
235 | < write("found MPEG video stream %s" % tokens[4], False)
|
---|
236 | < streamIds.append(int(tokens[4], 16))
|
---|
237 | < if tokens[2] == "Audio:":
|
---|
238 | < write("found MPEG audio stream %s" % tokens[4], False)
|
---|
239 | < streamIds.append(int(tokens[4], 16))
|
---|
240 | < if tokens[1] == "AC3/DTS":
|
---|
241 | < write("found AC3/DTS audio stream %s" % tokens[4], False)
|
---|
242 | < streamIds.append(int(tokens[4], 16))
|
---|
243 | < if tokens[1] == "LPCM":
|
---|
244 | < write("found LPCM audio stream %s" % tokens[4], False)
|
---|
245 | < streamIds.append(int(tokens[4], 16))
|
---|
246 | < if tokens[1] == "Teletext:":
|
---|
247 | < write("found Teletext stream %s" % tokens[3], False)
|
---|
248 | < streamIds.append(int(tokens[3], 16))
|
---|
249 | < if tokens[1] == "Subpicture:":
|
---|
250 | < write("found Subpicture stream %s" % tokens[3], False)
|
---|
251 | < streamIds.append(int(tokens[3], 16))
|
---|
252 | < if tokens[1] == "Generic_VBI:":
|
---|
253 | < write("found Generic_VBI stream %s" % tokens[3], False)
|
---|
254 | < streamIds.append(int(tokens[3], 16))
|
---|
255 | < if tokens[0] == "--->":
|
---|
256 | < if tokens[1] == "new":
|
---|
257 | < if tokens[2] == "File:":
|
---|
258 | < write("found file for stream 0x%x, %s" % (streamIds[len(streamIds)-1], tokens[3]), False)
|
---|
259 | < streamFiles.append(tokens[3].replace("'","")) # let's hope the path never has a space in it
|
---|
260 | < if tokens[0] == "-->":
|
---|
261 | < if tokens[1] == "stream":
|
---|
262 | < if tokens[2] == "omitted":
|
---|
263 | < write("stream 0x%x omitted" % streamIds[len(streamIds)-1], False)
|
---|
264 | < streamFiles.append("")
|
---|
265 | <
|
---|
266 | < write("streadmIds=%s" % streamIds)
|
---|
267 | < write("streamFiles=%s" % streamFiles)
|
---|
268 | <
|
---|
269 | < # choose which streams we need
|
---|
270 | < video, audio1, audio2 = selectStreams(folder)
|
---|
271 | <
|
---|
272 | < if getFileType(folder) == "mpeg":
|
---|
273 | < videoID = video[VIDEO_ID] & 255
|
---|
274 | < audio1ID = audio1[AUDIO_ID] & 255
|
---|
275 | < audio2ID = audio2[AUDIO_ID] & 255
|
---|
276 | < else:
|
---|
277 | < videoID = video[VIDEO_ID]
|
---|
278 | < audio1ID = audio1[AUDIO_ID]
|
---|
279 | < audio2ID = audio2[AUDIO_ID]
|
---|
280 | <
|
---|
281 | < # sanity check - we should have a file for each ID
|
---|
282 | < if len(streamIds) == len(streamFiles):
|
---|
283 | < # loop thought the available streams looking for the ones we want
|
---|
284 | < for stream in streamIds:
|
---|
285 | < write("got stream: %d" % stream, False)
|
---|
286 | < if stream == videoID:
|
---|
287 | < write("found video streamID", False)
|
---|
288 | < if os.path.exists(streamFiles[streamIds.index(stream)]):
|
---|
289 | < write("found video stream file", False)
|
---|
290 | < os.rename(streamFiles[streamIds.index(stream)], os.path.join(folder, "stream.mv2"))
|
---|
291 | <
|
---|
292 | < if stream == audio1ID:
|
---|
293 | < write("found audio1 streamID", False)
|
---|
294 | < if os.path.exists(streamFiles[streamIds.index(stream)]):
|
---|
295 | < write("found audio1 stream file", False)
|
---|
296 | < if audio1[AUDIO_CODEC] == "AC3":
|
---|
297 | < os.rename(streamFiles[streamIds.index(stream)], os.path.join(folder, "stream0.ac3"))
|
---|
298 | < else:
|
---|
299 | < os.rename(streamFiles[streamIds.index(stream)], os.path.join(folder, "stream0.mp2"))
|
---|
300 | <
|
---|
301 | < if stream == audio2ID:
|
---|
302 | < write("found audio2 streamID", False)
|
---|
303 | < if os.path.exists(streamFiles[streamIds.index(stream)]):
|
---|
304 | < write("found audio2 stream file", False)
|
---|
305 | < if audio2[AUDIO_CODEC] == "AC3":
|
---|
306 | < os.rename(streamFiles[streamIds.index(stream)], os.path.join(folder, "stream1.ac3"))
|
---|
307 | < else:
|
---|
308 | < os.rename(streamFiles[streamIds.index(stream)], os.path.join(folder, "stream1.mp2"))
|
---|
309 | <
|
---|
310 | < # final chance to find the correct stream files
|
---|
311 | < if not os.path.exists(os.path.join(folder, "stream.mv2")):
|
---|
312 | < if os.path.exists(os.path.join(folder, pxbasename + ".m2v")):
|
---|
313 | < os.rename(os.path.join(folder, pxbasename + ".m2v"), os.path.join(folder, "stream.mv2"))
|
---|
314 | <
|
---|
315 | < if not os.path.exists(os.path.join(folder, "stream0.mp2")) or not os.path.exists(os.path.join(folder, "stream0.ac3")):
|
---|
316 | < if os.path.exists(os.path.join(folder, pxbasename + ".mp2")):
|
---|
317 | < os.rename(os.path.join(folder, pxbasename + ".mp2"), os.path.join(folder, "stream0.mp2"))
|
---|
318 | < if os.path.exists(os.path.join(folder, pxbasename + ".ac3")):
|
---|
319 | < os.rename(os.path.join(folder, pxbasename + ".ac3"), os.path.join(folder, "stream0.ac3"))
|
---|
320 | <
|
---|
321 | < if not os.path.exists(os.path.join(folder, "stream1.mp2")) or not os.path.exists(os.path.join(folder, "stream1.ac3")):
|
---|
322 | < if os.path.exists(os.path.join(folder, pxbasename + "[1].mp2")):
|
---|
323 | < os.rename(os.path.join(folder, pxbasename + "[1].mp2"), os.path.join(folder, "stream1.mp2"))
|
---|
324 | < if os.path.exists(os.path.join(folder, pxbasename + "[1].ac3")):
|
---|
325 | < os.rename(os.path.join(folder, pxbasename + "[1].ac3"), os.path.join(folder, "stream1.ac3"))
|
---|
326 | <
|
---|
327 | < # do we have any subtitle files
|
---|
328 | < if os.path.exists(os.path.join(folder, pxbasename + ".sup")):
|
---|
329 | < os.rename(os.path.join(folder, pxbasename + ".sup"), os.path.join(folder, "stream.sup"))
|
---|
330 | <
|
---|
331 | < if os.path.exists(os.path.join(folder, pxbasename + ".sup.IFO")):
|
---|
332 | < os.rename(os.path.join(folder, pxbasename + ".sup.IFO"), os.path.join(folder, "stream.sup.IFO"))
|
---|
333 | <
|
---|
334 | < write("renameProjectXFiles end -----------------------------------------", False)
|
---|
335 | <
|
---|
336 | < #############################################################
|
---|
337 | 1983,1985c1943
|
---|
338 | < source = quoteFilename(source)
|
---|
339 | <
|
---|
340 | < command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (source, seconds, destination)
|
---|
341 | ---
|
---|
342 | > command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (quoteCmdArg(source), seconds, quoteCmdArg(destination))
|
---|
343 | 2008,2010c1966,1967
|
---|
344 | < source = quoteFilename(source)
|
---|
345 | <
|
---|
346 | < command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (source, thumbList, destination)
|
---|
347 | ---
|
---|
348 | > command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (quoteCmdArg(source), thumbList, quoteCmdArg(destination))
|
---|
349 | > write(command)
|
---|
350 | 2039c1996
|
---|
351 | < value = quoteFilename(source)
|
---|
352 | ---
|
---|
353 | > value = quoteCmdArg(source)
|
---|
354 | 2041c1998
|
---|
355 | < value = quoteFilename(destvideofile)
|
---|
356 | ---
|
---|
357 | > value = quoteCmdArg(destvideofile)
|
---|
358 | 2095c2052
|
---|
359 | < pass1 = string.replace(pass1, "%passlogfile", passLog)
|
---|
360 | ---
|
---|
361 | > pass1 = string.replace(pass1, "%passlogfile", quoteCmdArg(passLog))
|
---|
362 | 2217c2174
|
---|
363 | < command += "-f s16le -ar %s -ac %s -i %s " % (samplerate, channels, os.path.join(folder, "audout"))
|
---|
364 | ---
|
---|
365 | > command += "-f s16le -ar %s -ac %s -i %s " % (samplerate, channels, quoteCmdArg(os.path.join(folder, "audout")))
|
---|
366 | 2219c2176
|
---|
367 | < command += "-i %s " % os.path.join(folder, "vidout")
|
---|
368 | ---
|
---|
369 | > command += "-i %s " % quoteCmdArg(os.path.join(folder, "vidout"))
|
---|
370 | 2227c2184
|
---|
371 | < command += "-f dvd %s" % quoteFilename(destvideofile)
|
---|
372 | ---
|
---|
373 | > command += "-f dvd %s" % quoteCmdArg(destvideofile)
|
---|
374 | 2264,2267c2221,2224
|
---|
375 | < command = path_mkisofs[0] + ' -dvd-video '
|
---|
376 | < command += ' -V ' + quoteFilename(title)
|
---|
377 | < command += ' -o ' + os.path.join(getTempPath(), 'mythburn.iso')
|
---|
378 | < command += " " + os.path.join(getTempPath(),'dvd')
|
---|
379 | ---
|
---|
380 | > command = quoteCmdArg(path_mkisofs[0]) + ' -dvd-video '
|
---|
381 | > command += ' -V ' + quoteCmdArg(title)
|
---|
382 | > command += ' -o ' + quoteCmdArg(os.path.join(getTempPath(), 'mythburn.iso'))
|
---|
383 | > command += " " + quoteCmdArg(os.path.join(getTempPath(),'dvd'))
|
---|
384 | 2282d2238
|
---|
385 | < checkCancelFlag()
|
---|
386 | 2284,2286c2240
|
---|
387 | < finished = False
|
---|
388 | < tries = 0
|
---|
389 | < while not finished and tries < 10:
|
---|
390 | ---
|
---|
391 | > def drivestatus():
|
---|
392 | 2288c2242
|
---|
393 | < drivestatus = ioctl(f,CDROM.CDROM_DRIVE_STATUS, 0)
|
---|
394 | ---
|
---|
395 | > return ioctl(f,CDROM.CDROM_DRIVE_STATUS, 0)
|
---|
396 | 2289a2244,2285
|
---|
397 | > def displayneededdisktype():
|
---|
398 | > if mediatype == DVD_SL:
|
---|
399 | > write("Please insert an empty single-layer disc (DVD+R or DVD-R).")
|
---|
400 | > if mediatype == DVD_DL:
|
---|
401 | > write("Please insert an empty double-layer disc (DVD+R DL or DVD-R DL).")
|
---|
402 | > if mediatype == DVD_RW:
|
---|
403 | > write("Please insert a rewritable disc (DVD+RW or DVD-RW).")
|
---|
404 | > def opendrive(drivepath):
|
---|
405 | > # Open the Tray, if there is one.
|
---|
406 | > result = runCommand('eject ' + quoteCmdArg(drivepath))
|
---|
407 | > if result == 0:
|
---|
408 | > return True
|
---|
409 | > else:
|
---|
410 | > # try another method
|
---|
411 | > try:
|
---|
412 | > f = os.open(drivepath, os.O_RDONLY | os.O_NONBLOCK)
|
---|
413 | > r = ioctl(f,CDROM.CDROMEJECT, 0)
|
---|
414 | > os.close(f)
|
---|
415 | > return True
|
---|
416 | > except:
|
---|
417 | > write("Failed to eject the disc!")
|
---|
418 | > return False
|
---|
419 | > def waitForDrive():
|
---|
420 | > tries = 0
|
---|
421 | > while drivestatus() == CDROM.CDS_DRIVE_NOT_READY:
|
---|
422 | > write("Waiting for drive")
|
---|
423 | > time.sleep(5)
|
---|
424 | > tries += 1
|
---|
425 | > if tries > 6:
|
---|
426 | > # Try a hard reset if the device is still not ready
|
---|
427 | > write("Trying a hard-reset of the device")
|
---|
428 | > f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK)
|
---|
429 | > ioctl(f,CDROM.CDROMEJECT, 0)
|
---|
430 | > os.close(f);
|
---|
431 | > tries = 0
|
---|
432 | > checkCancelFlag()
|
---|
433 | >
|
---|
434 | >
|
---|
435 | > finished = False
|
---|
436 | > while not finished:
|
---|
437 | > # Maybe the user has no appropriate medium or something alike. Give her the chance to cancel.
|
---|
438 | > checkCancelFlag()
|
---|
439 | 2291c2287,2290
|
---|
440 | < if drivestatus == CDROM.CDS_DISC_OK or drivestatus == CDROM.CDS_NO_INFO:
|
---|
441 | ---
|
---|
442 | > # If drive needs some time (for example to close the tray) give it to it
|
---|
443 | > waitForDrive()
|
---|
444 | >
|
---|
445 | > if drivestatus() == CDROM.CDS_DISC_OK or drivestatus() == CDROM.CDS_NO_INFO:
|
---|
446 | 2295c2294
|
---|
447 | < runCommand("pumount " + dvddrivepath);
|
---|
448 | ---
|
---|
449 | > runCommand("pumount " + quoteCmdArg(dvddrivepath));
|
---|
450 | 2297,2309d2295
|
---|
451 | < if mediatype == DVD_RW and erasedvdrw == True:
|
---|
452 | < command = path_growisofs[0] + " -dvd-compat "
|
---|
453 | < if drivespeed != 0:
|
---|
454 | < command += "-speed=%d " % drivespeed
|
---|
455 | < command += " -use-the-force-luke -Z " + dvddrivepath
|
---|
456 | < command += " -dvd-video -V '" + title.replace("'", "'\\''") + "' "
|
---|
457 | < command += os.path.join(getTempPath(),'dvd')
|
---|
458 | < else:
|
---|
459 | < command = path_growisofs[0] + " -dvd-compat "
|
---|
460 | < if drivespeed != 0:
|
---|
461 | < command += "-speed=%d " % drivespeed
|
---|
462 | < command += " -Z " + dvddrivepath + " -dvd-video -V '" + title.replace("'", "'\\''") + "' "
|
---|
463 | < command += os.path.join(getTempPath(),'dvd')
|
---|
464 | 2310a2297,2302
|
---|
465 | > command = quoteCmdArg(path_growisofs[0]) + " -dvd-compat"
|
---|
466 | > if drivespeed != 0:
|
---|
467 | > command += " -speed=%d" % drivespeed
|
---|
468 | > if mediatype == DVD_RW and erasedvdrw == True:
|
---|
469 | > command += " -use-the-force-luke"
|
---|
470 | > command += " -Z " + quoteCmdArg(dvddrivepath) + " -dvd-video -V " + quoteCmdArg(title) + " " + quoteCmdArg(os.path.join(getTempPath(),'dvd'))
|
---|
471 | 2315,2323c2307,2339
|
---|
472 | < if result != 0:
|
---|
473 | < write("-"*60)
|
---|
474 | < write("ERROR: Failed while running growisofs.")
|
---|
475 | < write("Result %d, Command was: %s" % (result, command))
|
---|
476 | < write("Please check the troubleshooting section of the README for ways to fix this error")
|
---|
477 | < write("-"*60)
|
---|
478 | < write("")
|
---|
479 | < sys.exit(1)
|
---|
480 | < finished = True
|
---|
481 | ---
|
---|
482 | > if result == 0:
|
---|
483 | > finished = True
|
---|
484 | > else:
|
---|
485 | > if result == 252:
|
---|
486 | > write("-"*60)
|
---|
487 | > write("You probably inserted a medium of wrong type.")
|
---|
488 | > elif (result == 156):
|
---|
489 | > write("-"*60)
|
---|
490 | > write("You probably inserted a non-empty, corrupt or too small medium.")
|
---|
491 | > elif (result == 144):
|
---|
492 | > write("-"*60)
|
---|
493 | > write("You inserted a non-empty medium.")
|
---|
494 | > else:
|
---|
495 | > write("-"*60)
|
---|
496 | > write("ERROR: Failed while running growisofs.")
|
---|
497 | > write("Result %d, Command was: %s" % (result, command))
|
---|
498 | > write("Please check mythburn.log for further information")
|
---|
499 | > write("-"*60)
|
---|
500 | > write("")
|
---|
501 | > write("Going to try it again until canceled by user:")
|
---|
502 | > write("-"*60)
|
---|
503 | > write("")
|
---|
504 | > displayneededdisktype()
|
---|
505 | >
|
---|
506 | > # eject the disc
|
---|
507 | > waitForDrive()
|
---|
508 | > if os.path.ismount(dvddrivepath):
|
---|
509 | > try:
|
---|
510 | > runCommand("pumount " + quoteCmdArg(dvddrivepath));
|
---|
511 | > except:
|
---|
512 | > write("Failed to unmount the disc! "
|
---|
513 | > "Maybe the media monitor has mounted it")
|
---|
514 | > opendrive(dvddrivepath)
|
---|
515 | 2325,2332d2340
|
---|
516 | < try:
|
---|
517 | < # eject the burned disc
|
---|
518 | < f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK)
|
---|
519 | < r = ioctl(f,CDROM.CDROMEJECT, 0)
|
---|
520 | < os.close(f)
|
---|
521 | < except:
|
---|
522 | < write("Failed to eject the disc! "
|
---|
523 | < "Maybe the media monitor has mounted it")
|
---|
524 | 2334,2335c2342,2343
|
---|
525 | < elif drivestatus == CDROM.CDS_TRAY_OPEN:
|
---|
526 | < # Give the user 10secs to close the Tray
|
---|
527 | ---
|
---|
528 | > elif drivestatus() == CDROM.CDS_TRAY_OPEN:
|
---|
529 | > displayneededdisktype()
|
---|
530 | 2337,2355c2345,2351
|
---|
531 | < time.sleep(10)
|
---|
532 | < elif drivestatus == CDROM.CDS_NO_DISC:
|
---|
533 | < # Open the Tray, if there is one.
|
---|
534 | < write("Opening tray to get it fed with a DVD.")
|
---|
535 | < f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK)
|
---|
536 | < ioctl(f,CDROM.CDROMEJECT, 0)
|
---|
537 | < os.close(f);
|
---|
538 | < elif drivestatus == CDROM.CDS_DRIVE_NOT_READY:
|
---|
539 | < # Try a hard reset
|
---|
540 | < write("Trying a hard-reset of the device")
|
---|
541 | < f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK)
|
---|
542 | < ioctl(f,CDROM.CDROMEJECT, 0)
|
---|
543 | < os.close(f);
|
---|
544 | <
|
---|
545 | < time.sleep(1)
|
---|
546 | < tries += 1
|
---|
547 | <
|
---|
548 | < if not finished:
|
---|
549 | < fatalError("Tried 10 times to get a good status from DVD drive - Giving up!")
|
---|
550 | ---
|
---|
551 | > # Wait until user closes tray or cancels
|
---|
552 | > while drivestatus() == CDROM.CDS_TRAY_OPEN:
|
---|
553 | > checkCancelFlag()
|
---|
554 | > time.sleep(5)
|
---|
555 | > elif drivestatus() == CDROM.CDS_NO_DISC:
|
---|
556 | > displayneededdisktype()
|
---|
557 | > opendrive(dvddrivepath)
|
---|
558 | 2366c2362
|
---|
559 | < command = "mythreplex --demux --fix_sync -t TS -o %s " % (folder + "/stream")
|
---|
560 | ---
|
---|
561 | > command = "mythreplex --demux --fix_sync -t TS -o %s " % quoteCmdArg(folder + "/stream")
|
---|
562 | 2386c2382
|
---|
563 | < command = "mythreplex --demux --fix_sync -o %s " % (folder + "/stream")
|
---|
564 | ---
|
---|
565 | > command = "mythreplex --demux --fix_sync -o %s " % quoteCmdArg(folder + "/stream")
|
---|
566 | 2406c2402
|
---|
567 | < mediafile = quoteFilename(mediafile)
|
---|
568 | ---
|
---|
569 | > mediafile = quoteCmdArg(mediafile)
|
---|
570 | 2423c2419
|
---|
571 | < command = path_M2VRequantiser[0]
|
---|
572 | ---
|
---|
573 | > command = quoteCmdArg(path_M2VRequantiser[0])
|
---|
574 | 2426,2427c2422,2423
|
---|
575 | < command += " < %s " % source
|
---|
576 | < command += " > %s " % destination
|
---|
577 | ---
|
---|
578 | > command += " < %s " % quoteCmdArg(source)
|
---|
579 | > command += " > %s " % quoteCmdArg(destination)
|
---|
580 | 2430a2427,2428
|
---|
581 | > if result<>0:
|
---|
582 | > fatalError("Failed while running M2VRequantiser. Command was %s" % command)
|
---|
583 | 2437,2439d2434
|
---|
584 | <
|
---|
585 | < if result<>0:
|
---|
586 | < fatalError("Failed while running M2VRequantiser. Command was %s" % command)
|
---|
587 | 3198c3193
|
---|
588 | < command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile '%s' --framecount %d" % (inputfile, starttime, outputfile, frames)
|
---|
589 | ---
|
---|
590 | > command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s --framecount %d" % (quoteCmdArg(inputfile), starttime, quoteCmdArg(outputfile), frames)
|
---|
591 | 4064c4059
|
---|
592 | < # 5. if there are more that one stream with the chosen language we use the one with the lowest PID
|
---|
593 | ---
|
---|
594 | > # 5. if there are more than one stream with the chosen language we use the one with the lowest PID
|
---|
595 | 4788c4783
|
---|
596 | < res = runCommand("mytharchivehelper -q -q --isremote --infile " + quoteFilename(tmpfile))
|
---|
597 | ---
|
---|
598 | > res = runCommand("mytharchivehelper -q -q --isremote --infile " + quoteCmdArg(tmpfile))
|
---|
599 | 4853,4855d4847
|
---|
600 | < #Ensure the destination dvd folder is empty
|
---|
601 | < if doesFileExist(os.path.join(getTempPath(),"dvd")):
|
---|
602 | < deleteAllFilesInFolder(os.path.join(getTempPath(),"dvd"))
|
---|
603 | 4865c4857
|
---|
604 | < deleteAllFilesInFolder(getTempPath())
|
---|
605 | ---
|
---|
606 | > deleteEverythingInFolder(getTempPath())
|
---|
607 | 4871,4876d4862
|
---|
608 | < #If it already exists destroy it to remove previous debris
|
---|
609 | < if os.path.exists(localCopyFolder):
|
---|
610 | < #Remove all the files first
|
---|
611 | < deleteAllFilesInFolder(localCopyFolder)
|
---|
612 | < #Remove the folder
|
---|
613 | < os.rmdir (localCopyFolder)
|
---|
614 | 4890,4903d4875
|
---|
615 | < #If it already exists destroy it to remove previous debris
|
---|
616 | < if os.path.exists(folder):
|
---|
617 | < #Remove all the files first
|
---|
618 | < deleteAllFilesInFolder(folder)
|
---|
619 | < subtitlefolder = os.path.join(folder, "stream.d")
|
---|
620 | < if os.path.exists(subtitlefolder):
|
---|
621 | < deleteAllFilesInFolder(subtitlefolder)
|
---|
622 | < os.rmdir(subtitlefolder)
|
---|
623 | < previewfolder = os.path.join(folder, "preview")
|
---|
624 | < if os.path.exists(previewfolder):
|
---|
625 | < deleteAllFilesInFolder(previewfolder)
|
---|
626 | < os.rmdir(previewfolder)
|
---|
627 | < #Remove the folder
|
---|
628 | < os.rmdir (folder)
|
---|
629 | 4990,4992c4962,4976
|
---|
630 | < # convert to ascii and truncate to 32 chars
|
---|
631 | < title = unicodedata.normalize('NFKD', title).encode('ASCII', 'ignore')
|
---|
632 | < title = title[:32]
|
---|
633 | ---
|
---|
634 | > # replace all non-ascii-cahracters
|
---|
635 | > title.encode('ascii', 'replace').decode('ascii', 'replace')
|
---|
636 | > title.strip()
|
---|
637 | > # replace not-allowed characters
|
---|
638 | > index = 0
|
---|
639 | > title_new = ''
|
---|
640 | > while (index < len(title)) and (index<=7):
|
---|
641 | > if title[index].isalnum and title[index] != ' ':
|
---|
642 | > title_new += title[index]
|
---|
643 | > else:
|
---|
644 | > title_new += '_'
|
---|
645 | > index = index + 1
|
---|
646 | > title = title_new.upper()
|
---|
647 | > if len(title) < 1:
|
---|
648 | > title = 'UNNAMED'
|
---|