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 | 2288,2289c2242,2276 |
---|
393 | < drivestatus = ioctl(f,CDROM.CDROM_DRIVE_STATUS, 0) |
---|
394 | < os.close(f); |
---|
395 | --- |
---|
396 | > status = ioctl(f,CDROM.CDROM_DRIVE_STATUS, 0) |
---|
397 | > os.close(f) |
---|
398 | > return status |
---|
399 | > def displayneededdisktype(): |
---|
400 | > if mediatype == DVD_SL: |
---|
401 | > write("Please insert an empty single-layer disc (DVD+R or DVD-R).") |
---|
402 | > if mediatype == DVD_DL: |
---|
403 | > write("Please insert an empty double-layer disc (DVD+R DL or DVD-R DL).") |
---|
404 | > if mediatype == DVD_RW: |
---|
405 | > write("Please insert a rewritable disc (DVD+RW or DVD-RW).") |
---|
406 | > def tray(action): |
---|
407 | > try: |
---|
408 | > f = os.open(drivepath, os.O_RDONLY | os.O_NONBLOCK) |
---|
409 | > r = ioctl(f,action, 0) |
---|
410 | > os.close(f) |
---|
411 | > return True |
---|
412 | > except: |
---|
413 | > write("Failed to eject the disc!") |
---|
414 | > return False |
---|
415 | > finally: |
---|
416 | > os.close(f) |
---|
417 | > def waitForDrive(): |
---|
418 | > tries = 0 |
---|
419 | > while drivestatus() == CDROM.CDS_DRIVE_NOT_READY: |
---|
420 | > write("Waiting for drive") |
---|
421 | > time.sleep(5) |
---|
422 | > tries += 1 |
---|
423 | > if tries > 10: |
---|
424 | > # Try a hard reset if the device is still not ready |
---|
425 | > write("Open and close drive to do a hard-reset of the device") |
---|
426 | > tray(CDROM.CDROMEJECT) |
---|
427 | > tray(CDROM.CDROMCLOSETRAY) |
---|
428 | > tries = 0 |
---|
429 | > checkCancelFlag() |
---|
430 | > |
---|
431 | 2291c2278,2286 |
---|
432 | < if drivestatus == CDROM.CDS_DISC_OK or drivestatus == CDROM.CDS_NO_INFO: |
---|
433 | --- |
---|
434 | > finished = False |
---|
435 | > while not finished: |
---|
436 | > # Maybe the user has no appropriate medium or something alike. Give her the chance to cancel. |
---|
437 | > checkCancelFlag() |
---|
438 | > |
---|
439 | > # If drive needs some time (for example to close the tray) give it to it |
---|
440 | > waitForDrive() |
---|
441 | > |
---|
442 | > if drivestatus() == CDROM.CDS_DISC_OK or drivestatus() == CDROM.CDS_NO_INFO: |
---|
443 | 2295c2290 |
---|
444 | < runCommand("pumount " + dvddrivepath); |
---|
445 | --- |
---|
446 | > runCommand("pumount " + quoteCmdArg(dvddrivepath)); |
---|
447 | 2297,2309d2291 |
---|
448 | < if mediatype == DVD_RW and erasedvdrw == True: |
---|
449 | < command = path_growisofs[0] + " -dvd-compat " |
---|
450 | < if drivespeed != 0: |
---|
451 | < command += "-speed=%d " % drivespeed |
---|
452 | < command += " -use-the-force-luke -Z " + dvddrivepath |
---|
453 | < command += " -dvd-video -V '" + title.replace("'", "'\\''") + "' " |
---|
454 | < command += os.path.join(getTempPath(),'dvd') |
---|
455 | < else: |
---|
456 | < command = path_growisofs[0] + " -dvd-compat " |
---|
457 | < if drivespeed != 0: |
---|
458 | < command += "-speed=%d " % drivespeed |
---|
459 | < command += " -Z " + dvddrivepath + " -dvd-video -V '" + title.replace("'", "'\\''") + "' " |
---|
460 | < command += os.path.join(getTempPath(),'dvd') |
---|
461 | 2310a2293,2298 |
---|
462 | > command = quoteCmdArg(path_growisofs[0]) + " -dvd-compat" |
---|
463 | > if drivespeed != 0: |
---|
464 | > command += " -speed=%d" % drivespeed |
---|
465 | > if mediatype == DVD_RW and erasedvdrw == True: |
---|
466 | > command += " -use-the-force-luke" |
---|
467 | > command += " -Z " + quoteCmdArg(dvddrivepath) + " -dvd-video -V " + quoteCmdArg(title) + " " + quoteCmdArg(os.path.join(getTempPath(),'dvd')) |
---|
468 | 2315,2323c2303,2335 |
---|
469 | < if result != 0: |
---|
470 | < write("-"*60) |
---|
471 | < write("ERROR: Failed while running growisofs.") |
---|
472 | < write("Result %d, Command was: %s" % (result, command)) |
---|
473 | < write("Please check the troubleshooting section of the README for ways to fix this error") |
---|
474 | < write("-"*60) |
---|
475 | < write("") |
---|
476 | < sys.exit(1) |
---|
477 | < finished = True |
---|
478 | --- |
---|
479 | > if result == 0: |
---|
480 | > finished = True |
---|
481 | > else: |
---|
482 | > if result == 252: |
---|
483 | > write("-"*60) |
---|
484 | > write("You probably inserted a medium of wrong type.") |
---|
485 | > elif (result == 156): |
---|
486 | > write("-"*60) |
---|
487 | > write("You probably inserted a non-empty, corrupt or too small medium.") |
---|
488 | > elif (result == 144): |
---|
489 | > write("-"*60) |
---|
490 | > write("You inserted a non-empty medium.") |
---|
491 | > else: |
---|
492 | > write("-"*60) |
---|
493 | > write("ERROR: Failed while running growisofs.") |
---|
494 | > write("Result %d, Command was: %s" % (result, command)) |
---|
495 | > write("Please check mythburn.log for further information") |
---|
496 | > write("-"*60) |
---|
497 | > write("") |
---|
498 | > write("Going to try it again until canceled by user:") |
---|
499 | > write("-"*60) |
---|
500 | > write("") |
---|
501 | > displayneededdisktype() |
---|
502 | > |
---|
503 | > # eject the disc |
---|
504 | > waitForDrive() |
---|
505 | > if os.path.ismount(dvddrivepath): |
---|
506 | > try: |
---|
507 | > runCommand("pumount " + quoteCmdArg(dvddrivepath)); |
---|
508 | > except: |
---|
509 | > write("Failed to unmount the disc! " |
---|
510 | > "Maybe the media monitor has mounted it") |
---|
511 | > tray(CDROM.CDROMEJECT) |
---|
512 | 2325,2332d2336 |
---|
513 | < try: |
---|
514 | < # eject the burned disc |
---|
515 | < f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK) |
---|
516 | < r = ioctl(f,CDROM.CDROMEJECT, 0) |
---|
517 | < os.close(f) |
---|
518 | < except: |
---|
519 | < write("Failed to eject the disc! " |
---|
520 | < "Maybe the media monitor has mounted it") |
---|
521 | 2334,2335c2338,2339 |
---|
522 | < elif drivestatus == CDROM.CDS_TRAY_OPEN: |
---|
523 | < # Give the user 10secs to close the Tray |
---|
524 | --- |
---|
525 | > elif drivestatus() == CDROM.CDS_TRAY_OPEN: |
---|
526 | > displayneededdisktype() |
---|
527 | 2337,2355c2341,2347 |
---|
528 | < time.sleep(10) |
---|
529 | < elif drivestatus == CDROM.CDS_NO_DISC: |
---|
530 | < # Open the Tray, if there is one. |
---|
531 | < write("Opening tray to get it fed with a DVD.") |
---|
532 | < f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK) |
---|
533 | < ioctl(f,CDROM.CDROMEJECT, 0) |
---|
534 | < os.close(f); |
---|
535 | < elif drivestatus == CDROM.CDS_DRIVE_NOT_READY: |
---|
536 | < # Try a hard reset |
---|
537 | < write("Trying a hard-reset of the device") |
---|
538 | < f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK) |
---|
539 | < ioctl(f,CDROM.CDROMEJECT, 0) |
---|
540 | < os.close(f); |
---|
541 | < |
---|
542 | < time.sleep(1) |
---|
543 | < tries += 1 |
---|
544 | < |
---|
545 | < if not finished: |
---|
546 | < fatalError("Tried 10 times to get a good status from DVD drive - Giving up!") |
---|
547 | --- |
---|
548 | > # Wait until user closes tray or cancels |
---|
549 | > while drivestatus() == CDROM.CDS_TRAY_OPEN: |
---|
550 | > checkCancelFlag() |
---|
551 | > time.sleep(5) |
---|
552 | > elif drivestatus() == CDROM.CDS_NO_DISC: |
---|
553 | > displayneededdisktype() |
---|
554 | > tray(CDROM.CDROMEJECT) |
---|
555 | 2366c2358 |
---|
556 | < command = "mythreplex --demux --fix_sync -t TS -o %s " % (folder + "/stream") |
---|
557 | --- |
---|
558 | > command = "mythreplex --demux --fix_sync -t TS -o %s " % quoteCmdArg(folder + "/stream") |
---|
559 | 2386c2378 |
---|
560 | < command = "mythreplex --demux --fix_sync -o %s " % (folder + "/stream") |
---|
561 | --- |
---|
562 | > command = "mythreplex --demux --fix_sync -o %s " % quoteCmdArg(folder + "/stream") |
---|
563 | 2406c2398 |
---|
564 | < mediafile = quoteFilename(mediafile) |
---|
565 | --- |
---|
566 | > mediafile = quoteCmdArg(mediafile) |
---|
567 | 2423c2415 |
---|
568 | < command = path_M2VRequantiser[0] |
---|
569 | --- |
---|
570 | > command = quoteCmdArg(path_M2VRequantiser[0]) |
---|
571 | 2426,2427c2418,2419 |
---|
572 | < command += " < %s " % source |
---|
573 | < command += " > %s " % destination |
---|
574 | --- |
---|
575 | > command += " < %s " % quoteCmdArg(source) |
---|
576 | > command += " > %s " % quoteCmdArg(destination) |
---|
577 | 2430a2423,2424 |
---|
578 | > if result<>0: |
---|
579 | > fatalError("Failed while running M2VRequantiser. Command was %s" % command) |
---|
580 | 2437,2439d2430 |
---|
581 | < |
---|
582 | < if result<>0: |
---|
583 | < fatalError("Failed while running M2VRequantiser. Command was %s" % command) |
---|
584 | 3198c3189 |
---|
585 | < command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile '%s' --framecount %d" % (inputfile, starttime, outputfile, frames) |
---|
586 | --- |
---|
587 | > command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s --framecount %d" % (quoteCmdArg(inputfile), starttime, quoteCmdArg(outputfile), frames) |
---|
588 | 4064c4055 |
---|
589 | < # 5. if there are more that one stream with the chosen language we use the one with the lowest PID |
---|
590 | --- |
---|
591 | > # 5. if there are more than one stream with the chosen language we use the one with the lowest PID |
---|
592 | 4788c4779 |
---|
593 | < res = runCommand("mytharchivehelper -q -q --isremote --infile " + quoteFilename(tmpfile)) |
---|
594 | --- |
---|
595 | > res = runCommand("mytharchivehelper -q -q --isremote --infile " + quoteCmdArg(tmpfile)) |
---|
596 | 4853,4855d4843 |
---|
597 | < #Ensure the destination dvd folder is empty |
---|
598 | < if doesFileExist(os.path.join(getTempPath(),"dvd")): |
---|
599 | < deleteAllFilesInFolder(os.path.join(getTempPath(),"dvd")) |
---|
600 | 4865c4853 |
---|
601 | < deleteAllFilesInFolder(getTempPath()) |
---|
602 | --- |
---|
603 | > deleteEverythingInFolder(getTempPath()) |
---|
604 | 4871,4876d4858 |
---|
605 | < #If it already exists destroy it to remove previous debris |
---|
606 | < if os.path.exists(localCopyFolder): |
---|
607 | < #Remove all the files first |
---|
608 | < deleteAllFilesInFolder(localCopyFolder) |
---|
609 | < #Remove the folder |
---|
610 | < os.rmdir (localCopyFolder) |
---|
611 | 4890,4903d4871 |
---|
612 | < #If it already exists destroy it to remove previous debris |
---|
613 | < if os.path.exists(folder): |
---|
614 | < #Remove all the files first |
---|
615 | < deleteAllFilesInFolder(folder) |
---|
616 | < subtitlefolder = os.path.join(folder, "stream.d") |
---|
617 | < if os.path.exists(subtitlefolder): |
---|
618 | < deleteAllFilesInFolder(subtitlefolder) |
---|
619 | < os.rmdir(subtitlefolder) |
---|
620 | < previewfolder = os.path.join(folder, "preview") |
---|
621 | < if os.path.exists(previewfolder): |
---|
622 | < deleteAllFilesInFolder(previewfolder) |
---|
623 | < os.rmdir(previewfolder) |
---|
624 | < #Remove the folder |
---|
625 | < os.rmdir (folder) |
---|
626 | 4990,4992c4958,4972 |
---|
627 | < # convert to ascii and truncate to 32 chars |
---|
628 | < title = unicodedata.normalize('NFKD', title).encode('ASCII', 'ignore') |
---|
629 | < title = title[:32] |
---|
630 | --- |
---|
631 | > # replace all non-ascii-cahracters |
---|
632 | > title.encode('ascii', 'replace').decode('ascii', 'replace') |
---|
633 | > title.strip() |
---|
634 | > # replace not-allowed characters |
---|
635 | > index = 0 |
---|
636 | > title_new = '' |
---|
637 | > while (index < len(title)) and (index<=7): |
---|
638 | > if title[index].isalnum and title[index] != ' ': |
---|
639 | > title_new += title[index] |
---|
640 | > else: |
---|
641 | > title_new += '_' |
---|
642 | > index = index + 1 |
---|
643 | > title = title_new.upper() |
---|
644 | > if len(title) < 1: |
---|
645 | > title = 'UNNAMED' |
---|