1a2 > # -*- coding: utf-8 -*- 33c34 < # ProjectX - 0.90.4.00 --- > # ProjectX - >=0.91 38a40,45 > > # All strings in this file should be unicode, not byte string!! They get converted to utf-8 only > > > > 258a266,267 > > text = text.encode("utf-8", "replace") 272a282 > write("See mythburn.log for more information.") 307c317 < """return the number of CPU's""" --- > """return the number of CPUs""" 341c351 < # Escape quotes in a filename --- > # Escape quotes in a command line argument 343,346c353,356 < def quoteFilename(filename): < filename = filename.replace('"', '\\"') < filename = filename.replace('`', '\\`') < return '"%s"' % filename --- > def quoteCmdArg(arg): > arg = arg.replace('"', '\\"') > arg = arg.replace('`', '\\`') > return '"%s"' % arg 417a428,440 > # Romoves all the objects from a directory > > def deleteEverythingInFolder(folder): > for root, dirs, files in os.walk(folder, topdown=False): > for name in files: > os.remove(os.path.join(root, name)) > for name in dirs: > if os.path.islink(os.path.join(root, name)): > os.remove(os.path.join(root, name)) > else: > os.rmdir(os.path.join(root, name)) > > ############################################################# 436c459,466 < result = os.system(command) --- > # mytharchivehelper needes this locale to work correctly > try: > oldlocale = os.environ["LC_ALL"] > except: > oldlocale = "" > os.putenv("LC_ALL", "en_US.UTF-8") > result = os.system(command.encode('utf-8')) > os.putenv("LC_ALL", oldlocale) 467,468c497,498 < command = path_jpeg2yuv[0] + " -n %s -v0 -I p -f %s -j '%s' | %s -b 5000 -a %s -v 1 -f 8 -o '%s'" \ < % (totalframes, framespersecond, background, path_mpeg2enc[0], aspectratio, tempvideo) --- > 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" \ > % (totalframes, framespersecond, quoteCmdArg(background), quoteCmdArg(path_mpeg2enc[0]), aspectratio, quoteCmdArg(tempvideo)) 473c503 < command = path_mplex[0] + " -f 8 -v 0 -o '%s' '%s' '%s'" % (tempmovie, tempvideo, music) --- > command = quoteCmdArg(path_mplex[0]) + " -f 8 -v 0 -o %s %s %s" % (quoteCmdArg(tempmovie), quoteCmdArg(tempvideo), quoteCmdArg(music)) 479c509 < command = path_spumux[0] + " -m dvd -s 0 '%s' < '%s' > '%s'" % (xmlfile, tempmovie, finaloutput) --- > command = quoteCmdArg(path_spumux[0]) + " -m dvd -s 0 %s < %s > %s" % (quoteCmdArg(xmlfile), quoteCmdArg(tempmovie), quoteCmdArg(finaloutput)) 1434c1464 < print "Node = %s, Data = %s" % (k, v) --- > write( "Node = %s, Data = %s" % (k, v)) 1436c1466,1472 < node.appendChild(infoDOM.createTextNode(str(v))) --- > # v may be either an integer. Therefore we have to > # convert it to an unicode-string > # If it is already a string it is not encoded as all > # strings in this script are unicode. As no > # encoding-argument is supplied to unicode() it does > # nothing in this case. > node.appendChild(infoDOM.createTextNode(unicode(v))) 1500c1536 < cmd += "-i '%s' -f ac3 -ab 192k -ar 48000 '%s'" % (sourcefile, destinationfile) --- > cmd += "-i %s -f ac3 -ab 192k -ar 48000 %s" % (quoteCmdArg(sourcefile), quoteCmdArg(destinationfile)) 1594c1630 < command = os.path.join(scriptpath, "testsubtitlepngs.sh") + " %s/stream.d/spumux.xml" % (os.path.dirname(destination)) --- > command = quoteCmdArg(os.path.join(scriptpath, "testsubtitlepngs.sh")) + " " + quoteCmdArg(os.path.dirname(destination) + "/stream.d/spumux.xml") 1600c1636 < command = path_spumux[0] + " -P %s/stream.d/spumux.xml <%s >%s" % (os.path.dirname(destination), destination, os.path.splitext(destination)[0] + "-sub.mpg") --- > 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")) 1618,1619c1654,1656 < filename = quoteFilename(filename) < command = "mytharchivehelper -q -q --getfileinfo --infile %s --outfile %s --method %d" % (filename, xmlFilename, lenMethod) --- > > command = "mytharchivehelper -q -q --getfileinfo --infile %s --outfile %s --method %d" % (quoteCmdArg(filename), quoteCmdArg(xmlFilename), lenMethod) > 1629c1666 < write("streaminfo.xml :-\n" + infoDOM.toprettyxml(" ", ""), False) --- > write(xmlFilename + ":-\n" + infoDOM.toprettyxml(" ", ""), False) 1675c1712 < command = "mythtranscode --mpeg2 --honorcutlist %s --infile %s --outfile %s" % (cutlist_s, localfile, destination) --- > command = "mythtranscode --mpeg2 --honorcutlist %s --infile %s --outfile %s" % (cutlist_s, quoteCmdArg(localfile), quoteCmdArg(destination)) 1677c1714 < command = "mythtranscode --mpeg2 -i %s -o %s" % (localfile, destination) --- > command = "mythtranscode --mpeg2 --infile %s --outfile %s" % (quoteCmdArg(localfile), quoteCmdArg(destination)) 1680c1717 < command = "mythtranscode --mpeg2 --honorcutlist --chanid %s --starttime %s --outfile %s" % (chanid, starttime, destination) --- > command = "mythtranscode --mpeg2 --honorcutlist --chanid %s --starttime %s --outfile %s" % (chanid, starttime, quoteCmdArg(destination)) 1682c1719 < command = "mythtranscode --mpeg2 --chanid %s --starttime %s --outfile %s" % (chanid, starttime, destination) --- > command = "mythtranscode --mpeg2 --chanid %s --starttime %s --outfile %s" % (chanid, starttime, quoteCmdArg(destination)) 1739,1740d1775 < pxbasename = os.path.splitext(os.path.basename(file))[0] < 1745,1751c1780 < < qdestdir = quoteFilename(folder) < qpxbasename = quoteFilename(pxbasename) < qfile = quoteFilename(file) < qcutlist = os.path.join(folder, "cutlist_x.txt") < < command = path_projectx[0] + " -id %s" % getStreamList(folder) --- > command = quoteCmdArg(path_projectx[0]) + " %s -id '%s' -set ExternPanel.appendPidToFileName=1 -out %s -name stream" % (quoteCmdArg(file), getStreamList(folder), quoteCmdArg(folder)) 1753,1756c1782 < command += " -cut %s -out %s -name %s %s" % (qcutlist, qdestdir, qpxbasename, qfile) < else: < command += " -out %s -name %s %s" % (qdestdir, qpxbasename, qfile) < --- > command += " -cut %s" % quoteCmdArg(os.path.join(folder, "cutlist_x.txt")) 1758d1783 < 1768c1793,1849 < renameProjectXFiles(folder, pxbasename) --- > video, audio1, audio2 = selectStreams(folder) > if addSubtitles: > subtitles = selectSubtitleStream(folder) > > videoID_hex = "0x%x" % video[VIDEO_ID] > if audio1[AUDIO_ID] != -1: > audio1ID_hex = "0x%x" % audio1[AUDIO_ID] > else: > audio1ID_hex = "" > if audio2[AUDIO_ID] != -1: > audio2ID_hex = "0x%x" % audio2[AUDIO_ID] > else: > audio2ID_hex = "" > if addSubtitles and subtitles[SUBTITLE_ID] != -1: > subtitlesID_hex = "0x%x" % subtitles[SUBTITLE_ID] > else: > subtitlesID_hex = "" > > > files = os.listdir(folder) > for file in files: > if file[0:9] == "stream{0x": # don't rename files that have already been renamed > PID = file[7:13] > SubID = file[19:23] > if PID == videoID_hex or SubID == videoID_hex: > os.rename(os.path.join(folder, file), os.path.join(folder, "stream.mv2")) > elif PID == audio1ID_hex or SubID == audio1ID_hex: > os.rename(os.path.join(folder, file), os.path.join(folder, "stream0." + file[-3:])) > elif PID == audio2ID_hex or SubID == audio2ID_hex: > os.rename(os.path.join(folder, file), os.path.join(folder, "stream1." + file[-3:])) > elif PID == subtitlesID_hex or SubID == subtitlesID_hex: > if file[-3:] == "sup": > os.rename(os.path.join(folder, file), os.path.join(folder, "stream.sup")) > else: > os.rename(os.path.join(folder, file), os.path.join(folder, "stream.sup.IFO")) > > > # Fallback if assignment and renaming by ID failed > > files = os.listdir(folder) > for file in files: > if file[0:9] == "stream{0x": # don't rename files that have already been renamed > if not os.path.exists(os.path.join(folder, "stream.mv2")) and file[-3:] == "m2v": > os.rename(os.path.join(folder, file), os.path.join(folder, "stream.mv2")) > 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": > os.rename(os.path.join(folder, file), os.path.join(folder, "stream0.ac3")) > 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": > os.rename(os.path.join(folder, file), os.path.join(folder, "stream0.mp2")) > 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": > os.rename(os.path.join(folder, file), os.path.join(folder, "stream1.ac3")) > 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": > os.rename(os.path.join(folder, file), os.path.join(folder, "stream1.mp2")) > elif not os.path.exists(os.path.join(folder, "stream.sup")) and file[-3:] == "sup": > os.rename(os.path.join(folder, file), os.path.join(folder, "stream.sup")) > elif not os.path.exists(os.path.join(folder, "stream.sup.IFO")) and file[-3:] == "IFO": > os.rename(os.path.join(folder, file), os.path.join(folder, "stream.sup.IFO")) > 1777c1858 < command += " --infile %s --ifofile %s --delay 0" % (os.path.join(folder, "stream.sup"), os.path.join(folder, "stream.sup.IFO")) --- > command += " --infile %s --ifofile %s --delay 0" % (quoteCmdArg(os.path.join(folder, "stream.sup")), quoteCmdArg(os.path.join(folder, "stream.sup.IFO"))) 1792,1912d1872 < # find the required stream files and rename them < < def renameProjectXFiles(folder, pxbasename): < < write("renameProjectXFiles start -----------------------------------------", False) < logf = open(os.path.join(folder, pxbasename + "_log.txt")) < logdata = logf.readlines() < logf.close() < < # find stream PIDs and Files < streamIds = [] < streamFiles = [] < for line in logdata: < tokens = line.split() < if len(tokens) > 0: < if tokens[0] == "++>": < # From ProjectX/resources/pjxresources_en.properties: < if tokens[1] == "Mpg": < if tokens[2] == "Video:": < write("found MPEG video stream %s" % tokens[4], False) < streamIds.append(int(tokens[4], 16)) < if tokens[2] == "Audio:": < write("found MPEG audio stream %s" % tokens[4], False) < streamIds.append(int(tokens[4], 16)) < if tokens[1] == "AC3/DTS": < write("found AC3/DTS audio stream %s" % tokens[4], False) < streamIds.append(int(tokens[4], 16)) < if tokens[1] == "LPCM": < write("found LPCM audio stream %s" % tokens[4], False) < streamIds.append(int(tokens[4], 16)) < if tokens[1] == "Teletext:": < write("found Teletext stream %s" % tokens[3], False) < streamIds.append(int(tokens[3], 16)) < if tokens[1] == "Subpicture:": < write("found Subpicture stream %s" % tokens[3], False) < streamIds.append(int(tokens[3], 16)) < if tokens[1] == "Generic_VBI:": < write("found Generic_VBI stream %s" % tokens[3], False) < streamIds.append(int(tokens[3], 16)) < if tokens[0] == "--->": < if tokens[1] == "new": < if tokens[2] == "File:": < write("found file for stream 0x%x, %s" % (streamIds[len(streamIds)-1], tokens[3]), False) < streamFiles.append(tokens[3].replace("'","")) # let's hope the path never has a space in it < if tokens[0] == "-->": < if tokens[1] == "stream": < if tokens[2] == "omitted": < write("stream 0x%x omitted" % streamIds[len(streamIds)-1], False) < streamFiles.append("") < < write("streadmIds=%s" % streamIds) < write("streamFiles=%s" % streamFiles) < < # choose which streams we need < video, audio1, audio2 = selectStreams(folder) < < if getFileType(folder) == "mpeg": < videoID = video[VIDEO_ID] & 255 < audio1ID = audio1[AUDIO_ID] & 255 < audio2ID = audio2[AUDIO_ID] & 255 < else: < videoID = video[VIDEO_ID] < audio1ID = audio1[AUDIO_ID] < audio2ID = audio2[AUDIO_ID] < < # sanity check - we should have a file for each ID < if len(streamIds) == len(streamFiles): < # loop thought the available streams looking for the ones we want < for stream in streamIds: < write("got stream: %d" % stream, False) < if stream == videoID: < write("found video streamID", False) < if os.path.exists(streamFiles[streamIds.index(stream)]): < write("found video stream file", False) < os.rename(streamFiles[streamIds.index(stream)], os.path.join(folder, "stream.mv2")) < < if stream == audio1ID: < write("found audio1 streamID", False) < if os.path.exists(streamFiles[streamIds.index(stream)]): < write("found audio1 stream file", False) < if audio1[AUDIO_CODEC] == "AC3": < os.rename(streamFiles[streamIds.index(stream)], os.path.join(folder, "stream0.ac3")) < else: < os.rename(streamFiles[streamIds.index(stream)], os.path.join(folder, "stream0.mp2")) < < if stream == audio2ID: < write("found audio2 streamID", False) < if os.path.exists(streamFiles[streamIds.index(stream)]): < write("found audio2 stream file", False) < if audio2[AUDIO_CODEC] == "AC3": < os.rename(streamFiles[streamIds.index(stream)], os.path.join(folder, "stream1.ac3")) < else: < os.rename(streamFiles[streamIds.index(stream)], os.path.join(folder, "stream1.mp2")) < < # final chance to find the correct stream files < if not os.path.exists(os.path.join(folder, "stream.mv2")): < if os.path.exists(os.path.join(folder, pxbasename + ".m2v")): < os.rename(os.path.join(folder, pxbasename + ".m2v"), os.path.join(folder, "stream.mv2")) < < if not os.path.exists(os.path.join(folder, "stream0.mp2")) or not os.path.exists(os.path.join(folder, "stream0.ac3")): < if os.path.exists(os.path.join(folder, pxbasename + ".mp2")): < os.rename(os.path.join(folder, pxbasename + ".mp2"), os.path.join(folder, "stream0.mp2")) < if os.path.exists(os.path.join(folder, pxbasename + ".ac3")): < os.rename(os.path.join(folder, pxbasename + ".ac3"), os.path.join(folder, "stream0.ac3")) < < if not os.path.exists(os.path.join(folder, "stream1.mp2")) or not os.path.exists(os.path.join(folder, "stream1.ac3")): < if os.path.exists(os.path.join(folder, pxbasename + "[1].mp2")): < os.rename(os.path.join(folder, pxbasename + "[1].mp2"), os.path.join(folder, "stream1.mp2")) < if os.path.exists(os.path.join(folder, pxbasename + "[1].ac3")): < os.rename(os.path.join(folder, pxbasename + "[1].ac3"), os.path.join(folder, "stream1.ac3")) < < # do we have any subtitle files < if os.path.exists(os.path.join(folder, pxbasename + ".sup")): < os.rename(os.path.join(folder, pxbasename + ".sup"), os.path.join(folder, "stream.sup")) < < if os.path.exists(os.path.join(folder, pxbasename + ".sup.IFO")): < os.rename(os.path.join(folder, pxbasename + ".sup.IFO"), os.path.join(folder, "stream.sup.IFO")) < < write("renameProjectXFiles end -----------------------------------------", False) < < ############################################################# 1983,1985c1943 < source = quoteFilename(source) < < command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (source, seconds, destination) --- > command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (quoteCmdArg(source), seconds, quoteCmdArg(destination)) 2008,2010c1966,1967 < source = quoteFilename(source) < < command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (source, thumbList, destination) --- > command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (quoteCmdArg(source), thumbList, quoteCmdArg(destination)) > write(command) 2039c1996 < value = quoteFilename(source) --- > value = quoteCmdArg(source) 2041c1998 < value = quoteFilename(destvideofile) --- > value = quoteCmdArg(destvideofile) 2095c2052 < pass1 = string.replace(pass1, "%passlogfile", passLog) --- > pass1 = string.replace(pass1, "%passlogfile", quoteCmdArg(passLog)) 2217c2174 < command += "-f s16le -ar %s -ac %s -i %s " % (samplerate, channels, os.path.join(folder, "audout")) --- > command += "-f s16le -ar %s -ac %s -i %s " % (samplerate, channels, quoteCmdArg(os.path.join(folder, "audout"))) 2219c2176 < command += "-i %s " % os.path.join(folder, "vidout") --- > command += "-i %s " % quoteCmdArg(os.path.join(folder, "vidout")) 2227c2184 < command += "-f dvd %s" % quoteFilename(destvideofile) --- > command += "-f dvd %s" % quoteCmdArg(destvideofile) 2264,2267c2221,2224 < command = path_mkisofs[0] + ' -dvd-video ' < command += ' -V ' + quoteFilename(title) < command += ' -o ' + os.path.join(getTempPath(), 'mythburn.iso') < command += " " + os.path.join(getTempPath(),'dvd') --- > command = quoteCmdArg(path_mkisofs[0]) + ' -dvd-video ' > command += ' -V ' + quoteCmdArg(title) > command += ' -o ' + quoteCmdArg(os.path.join(getTempPath(), 'mythburn.iso')) > command += " " + quoteCmdArg(os.path.join(getTempPath(),'dvd')) 2282d2238 < checkCancelFlag() 2284,2286c2240 < finished = False < tries = 0 < while not finished and tries < 10: --- > def drivestatus(): 2288,2289c2242,2286 < drivestatus = ioctl(f,CDROM.CDROM_DRIVE_STATUS, 0) < os.close(f); --- > status = ioctl(f,CDROM.CDROM_DRIVE_STATUS, 0) > os.close(f) > return status > def displayneededdisktype(): > if mediatype == DVD_SL: > write("Please insert an empty single-layer disc (DVD+R or DVD-R).") > if mediatype == DVD_DL: > write("Please insert an empty double-layer disc (DVD+R DL or DVD-R DL).") > if mediatype == DVD_RW: > write("Please insert a rewritable disc (DVD+RW or DVD-RW).") > def opendrive(drivepath): > # Open the Tray, if there is one. > result = runCommand('eject ' + quoteCmdArg(drivepath)) > if result == 0: > return True > else: > # try another method > try: > f = os.open(drivepath, os.O_RDONLY | os.O_NONBLOCK) > r = ioctl(f,CDROM.CDROMEJECT, 0) > os.close(f) > return True > except: > write("Failed to eject the disc!") > return False > def waitForDrive(): > tries = 0 > while drivestatus() == CDROM.CDS_DRIVE_NOT_READY: > write("Waiting for drive") > time.sleep(5) > tries += 1 > if tries > 6: > # Try a hard reset if the device is still not ready > write("Trying a hard-reset of the device") > f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK) > ioctl(f,CDROM.CDROMEJECT, 0) > os.close(f); > tries = 0 > checkCancelFlag() > > > finished = False > while not finished: > # Maybe the user has no appropriate medium or something alike. Give her the chance to cancel. > checkCancelFlag() 2291c2288,2291 < if drivestatus == CDROM.CDS_DISC_OK or drivestatus == CDROM.CDS_NO_INFO: --- > # If drive needs some time (for example to close the tray) give it to it > waitForDrive() > > if drivestatus() == CDROM.CDS_DISC_OK or drivestatus() == CDROM.CDS_NO_INFO: 2295c2295 < runCommand("pumount " + dvddrivepath); --- > runCommand("pumount " + quoteCmdArg(dvddrivepath)); 2297,2309d2296 < if mediatype == DVD_RW and erasedvdrw == True: < command = path_growisofs[0] + " -dvd-compat " < if drivespeed != 0: < command += "-speed=%d " % drivespeed < command += " -use-the-force-luke -Z " + dvddrivepath < command += " -dvd-video -V '" + title.replace("'", "'\\''") + "' " < command += os.path.join(getTempPath(),'dvd') < else: < command = path_growisofs[0] + " -dvd-compat " < if drivespeed != 0: < command += "-speed=%d " % drivespeed < command += " -Z " + dvddrivepath + " -dvd-video -V '" + title.replace("'", "'\\''") + "' " < command += os.path.join(getTempPath(),'dvd') 2310a2298,2303 > command = quoteCmdArg(path_growisofs[0]) + " -dvd-compat" > if drivespeed != 0: > command += " -speed=%d" % drivespeed > if mediatype == DVD_RW and erasedvdrw == True: > command += " -use-the-force-luke" > command += " -Z " + quoteCmdArg(dvddrivepath) + " -dvd-video -V " + quoteCmdArg(title) + " " + quoteCmdArg(os.path.join(getTempPath(),'dvd')) 2315,2323c2308,2340 < if result != 0: < write("-"*60) < write("ERROR: Failed while running growisofs.") < write("Result %d, Command was: %s" % (result, command)) < write("Please check the troubleshooting section of the README for ways to fix this error") < write("-"*60) < write("") < sys.exit(1) < finished = True --- > if result == 0: > finished = True > else: > if result == 252: > write("-"*60) > write("You probably inserted a medium of wrong type.") > elif (result == 156): > write("-"*60) > write("You probably inserted a non-empty, corrupt or too small medium.") > elif (result == 144): > write("-"*60) > write("You inserted a non-empty medium.") > else: > write("-"*60) > write("ERROR: Failed while running growisofs.") > write("Result %d, Command was: %s" % (result, command)) > write("Please check mythburn.log for further information") > write("-"*60) > write("") > write("Going to try it again until canceled by user:") > write("-"*60) > write("") > displayneededdisktype() > > # eject the disc > waitForDrive() > if os.path.ismount(dvddrivepath): > try: > runCommand("pumount " + quoteCmdArg(dvddrivepath)); > except: > write("Failed to unmount the disc! " > "Maybe the media monitor has mounted it") > opendrive(dvddrivepath) 2325,2332d2341 < try: < # eject the burned disc < f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK) < r = ioctl(f,CDROM.CDROMEJECT, 0) < os.close(f) < except: < write("Failed to eject the disc! " < "Maybe the media monitor has mounted it") 2334,2335c2343,2344 < elif drivestatus == CDROM.CDS_TRAY_OPEN: < # Give the user 10secs to close the Tray --- > elif drivestatus() == CDROM.CDS_TRAY_OPEN: > displayneededdisktype() 2337,2355c2346,2352 < time.sleep(10) < elif drivestatus == CDROM.CDS_NO_DISC: < # Open the Tray, if there is one. < write("Opening tray to get it fed with a DVD.") < f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK) < ioctl(f,CDROM.CDROMEJECT, 0) < os.close(f); < elif drivestatus == CDROM.CDS_DRIVE_NOT_READY: < # Try a hard reset < write("Trying a hard-reset of the device") < f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK) < ioctl(f,CDROM.CDROMEJECT, 0) < os.close(f); < < time.sleep(1) < tries += 1 < < if not finished: < fatalError("Tried 10 times to get a good status from DVD drive - Giving up!") --- > # Wait until user closes tray or cancels > while drivestatus() == CDROM.CDS_TRAY_OPEN: > checkCancelFlag() > time.sleep(5) > elif drivestatus() == CDROM.CDS_NO_DISC: > displayneededdisktype() > opendrive(dvddrivepath) 2366c2363 < command = "mythreplex --demux --fix_sync -t TS -o %s " % (folder + "/stream") --- > command = "mythreplex --demux --fix_sync -t TS -o %s " % quoteCmdArg(folder + "/stream") 2386c2383 < command = "mythreplex --demux --fix_sync -o %s " % (folder + "/stream") --- > command = "mythreplex --demux --fix_sync -o %s " % quoteCmdArg(folder + "/stream") 2406c2403 < mediafile = quoteFilename(mediafile) --- > mediafile = quoteCmdArg(mediafile) 2423c2420 < command = path_M2VRequantiser[0] --- > command = quoteCmdArg(path_M2VRequantiser[0]) 2426,2427c2423,2424 < command += " < %s " % source < command += " > %s " % destination --- > command += " < %s " % quoteCmdArg(source) > command += " > %s " % quoteCmdArg(destination) 2430a2428,2429 > if result<>0: > fatalError("Failed while running M2VRequantiser. Command was %s" % command) 2437,2439d2435 < < if result<>0: < fatalError("Failed while running M2VRequantiser. Command was %s" % command) 3198c3194 < command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile '%s' --framecount %d" % (inputfile, starttime, outputfile, frames) --- > command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s --framecount %d" % (quoteCmdArg(inputfile), starttime, quoteCmdArg(outputfile), frames) 4064c4060 < # 5. if there are more that one stream with the chosen language we use the one with the lowest PID --- > # 5. if there are more than one stream with the chosen language we use the one with the lowest PID 4788c4784 < res = runCommand("mytharchivehelper -q -q --isremote --infile " + quoteFilename(tmpfile)) --- > res = runCommand("mytharchivehelper -q -q --isremote --infile " + quoteCmdArg(tmpfile)) 4853,4855d4848 < #Ensure the destination dvd folder is empty < if doesFileExist(os.path.join(getTempPath(),"dvd")): < deleteAllFilesInFolder(os.path.join(getTempPath(),"dvd")) 4865c4858 < deleteAllFilesInFolder(getTempPath()) --- > deleteEverythingInFolder(getTempPath()) 4871,4876d4863 < #If it already exists destroy it to remove previous debris < if os.path.exists(localCopyFolder): < #Remove all the files first < deleteAllFilesInFolder(localCopyFolder) < #Remove the folder < os.rmdir (localCopyFolder) 4890,4903d4876 < #If it already exists destroy it to remove previous debris < if os.path.exists(folder): < #Remove all the files first < deleteAllFilesInFolder(folder) < subtitlefolder = os.path.join(folder, "stream.d") < if os.path.exists(subtitlefolder): < deleteAllFilesInFolder(subtitlefolder) < os.rmdir(subtitlefolder) < previewfolder = os.path.join(folder, "preview") < if os.path.exists(previewfolder): < deleteAllFilesInFolder(previewfolder) < os.rmdir(previewfolder) < #Remove the folder < os.rmdir (folder) 4990,4992c4963,4977 < # convert to ascii and truncate to 32 chars < title = unicodedata.normalize('NFKD', title).encode('ASCII', 'ignore') < title = title[:32] --- > # replace all non-ascii-cahracters > title.encode('ascii', 'replace').decode('ascii', 'replace') > title.strip() > # replace not-allowed characters > index = 0 > title_new = '' > while (index < len(title)) and (index<=7): > if title[index].isalnum and title[index] != ' ': > title_new += title[index] > else: > title_new += '_' > index = index + 1 > title = title_new.upper() > if len(title) < 1: > title = 'UNNAMED'