Пример #1
0
    def show_final_time(self):
        if (self.erase_temp):
            self.eraser.delete_xml()

        self.window.hide()
        self.window.destroy()
        if (self.global_vars["shutdown_after_disc"]):
            print "\n\nApago el ordenador\n\n"
            failure = False

            # First, try with ConsoleKit
            try:
                bus = dbus.SystemBus()
                bus_object = bus.get_object(
                    "org.freedesktop.ConsoleKit",
                    "/org/freedesktop/ConsoleKit/Manager")
                bus_object.Stop(
                    dbus_interface="org.freedesktop.ConsoleKit.Manager")
            except:
                failure = True
            if (failure):
                failure = False

                # If it fails, try with HAL
                try:
                    bus = dbus.SystemBus()
                    bus_object = bus.get_object(
                        "org.freedesktop.Hal",
                        "/org/freedesktop/Hal/devices/computer")
                    bus_object.Shutdown(
                        dbus_interface=
                        "org.freedesktop.Hal.Device.SystemPowerManagement")
                except:
                    failure = True

            if (failure == False):
                gtk.main_quit()

        newtree = devede_other.create_tree(self, "wend_dialog", self.gladefile,
                                           False)
        label = newtree.get_object("elapsed")
        tiempo2 = devede_other.return_time(time.time() - self.tiempo, True)
        label.set_text(tiempo2)
        window = newtree.get_object("wend_dialog")
        burn = newtree.get_object("burn_button")
        # only enable button if k3b is available
        # TODO: support other burners

        if (self.k3b_available == False) and (self.brasero_available == False):
            burn.set_sensitive(False)

        burn.connect('clicked', self.burn)
        window.show()
        window.run()
        window.hide()
        window.destroy()
        window = None
        newtree = None
        gc.collect()
        (self.main_window_callback)()
Пример #2
0
	def show_final_time(self):
		if (self.erase_temp):
			self.eraser.delete_xml()

		self.window.hide()
		self.window.destroy()
		newtree=devede_other.create_tree(self,"wend_dialog",self.gladefile,False)
		label=newtree.get_object("elapsed")
		tiempo2=devede_other.return_time(time.time()-self.tiempo,True)
		label.set_text(tiempo2)
		window=newtree.get_object("wend_dialog")
		burn = newtree.get_object("button11")
		# only enable button if k3b is available
		# TODO: support other burners
		if 127==devede_other.check_program("k3b -v"):
			burn.set_sensitive(False)
		burn.connect('clicked', self.burn)
		window.show()
		window.run()
		window.hide()
		window.destroy()
		window = None
		newtree = None
		gc.collect()
		(self.main_window_callback)()
Пример #3
0
    def show_final_time(self):
        if (self.erase_temp):
            self.eraser.delete_xml()

        self.window.hide()
        self.window.destroy()
        newtree = devede_other.create_tree(self, "wend_dialog", self.gladefile,
                                           False)
        label = newtree.get_object("elapsed")
        tiempo2 = devede_other.return_time(time.time() - self.tiempo, True)
        label.set_text(tiempo2)
        window = newtree.get_object("wend_dialog")
        burn = newtree.get_object("button11")
        # only enable button if k3b is available
        # TODO: support other burners
        if 127 == devede_other.check_program("k3b -v"):
            burn.set_sensitive(False)
        burn.connect('clicked', self.burn)
        window.show()
        window.run()
        window.hide()
        window.destroy()
        window = None
        newtree = None
        gc.collect()
        (self.main_window_callback)()
Пример #4
0
	def show_final_time(self):
		if (self.erase_temp):
			self.eraser.delete_xml()

		self.window.hide()
		self.window.destroy()
		if (self.global_vars["shutdown_after_disc"]):
			print "\n\nApago el ordenador\n\n"
			failure=False
			
			# First, try with ConsoleKit
			try:
				bus = dbus.SystemBus()
				bus_object = bus.get_object("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager")
				bus_object.Stop(dbus_interface="org.freedesktop.ConsoleKit.Manager")
			except:
				failure=True
			if (failure):
				failure=False
				
				# If it fails, try with HAL
				try:
					bus = dbus.SystemBus()
					bus_object = bus.get_object("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer")
					bus_object.Shutdown(dbus_interface="org.freedesktop.Hal.Device.SystemPowerManagement")
				except:
					failure=True

			if (failure==False):
				Gtk.main_quit()

		newtree=devede_other.create_tree(self,"wend_dialog",self.gladefile,False)
		label=newtree.get_object("elapsed")
		tiempo2=devede_other.return_time(time.time()-self.tiempo,True)
		label.set_text(tiempo2)
		window=newtree.get_object("wend_dialog")
		burn = newtree.get_object("burn_button")
		# only enable button if k3b is available
		# TODO: support other burners
		
		if (self.k3b_available==False) and (self.brasero_available==False):
			burn.set_sensitive(False)
		
		burn.connect('clicked', self.burn)
		window.show()
		window.run()
		window.hide()
		window.destroy()
		window = None
		newtree = None
		gc.collect()
		(self.main_window_callback)()
Пример #5
0
	def show_final_time(self):
		if (self.erase_temp):
			self.eraser.delete_xml()

		self.window.hide()
		self.window.destroy()
		newtree=devede_other.create_tree(self,"wend_dialog",self.gladefile,False)
		label=newtree.get_object("elapsed")
		tiempo2=devede_other.return_time(time.time()-self.tiempo,True)
		label.set_text(tiempo2)
		window=newtree.get_object("wend_dialog")
		window.show()
		window.run()
		window.hide()
		window.destroy()
		window = None
		newtree = None
		gc.collect()
		(self.main_window_callback)()
Пример #6
0
    def create_xml(self):

        """ Creates the XML file for DVDAuthor """

        # calculate the position for each title

        title_list = []
        counter = 1
        for element in self.structure:
            title_list.append(counter)
            counter += (len(element)) - 1

        try:
            fichero = open(self.filefolder + self.filename + ".xml", "w")
            fichero.write('<dvdauthor dest="' + self.expand_xml(self.filefolder + self.filename) + '">\n')

            if self.onlyone:
                fichero.write("\t<vmgm />\n")
            else:

                fichero.write("\t<vmgm>\n")

                # MENU

                # in the FPC we do a jump to the first menu in the first titleset if we wanted MENU
                # or we jump to the second titleset if we didn't want MENU at startup

                fichero.write("\t\t<fpc>\n")
                fichero.write("\t\t\tg0=100;\n")
                if self.do_menu and self.with_menu:
                    fichero.write("\t\t\tg1=0;\n")
                else:
                    fichero.write("\t\t\tg1=100;\n")
                fichero.write("\t\t\tg2=1024;\n")
                fichero.write("\t\t\tjump menu 1;\n")
                fichero.write("\t\t</fpc>\n")

                # in the VMGM menu we create a code to jump to the title specified in G0
                # but if the title is 100, we jump to the menus. There we show the menu number
                # contained in G1

                fichero.write("\t\t<menus>\n")

                fichero.write('\t\t\t<video format="')
                if self.menu_PAL:
                    fichero.write("pal")
                else:
                    fichero.write("ntsc")
                fichero.write('" aspect="4:3"> </video>\n')

                fichero.write("\t\t\t<pgc>\n")
                fichero.write("\t\t\t\t<pre>\n")

                counter = 1
                for element in self.structure:
                    for element2 in element[1:]:
                        fichero.write("\t\t\t\t\tif (g0 eq " + str(counter) + ") {\n")
                        fichero.write("\t\t\t\t\t\tjump titleset " + str(1 + counter) + " menu;\n")
                        fichero.write("\t\t\t\t\t}\n")
                        counter += 1
                fichero.write("\t\t\t\t\tif (g0 eq 100) {\n")
                fichero.write("\t\t\t\t\t\tg2=1024;\n")
                fichero.write("\t\t\t\t\t\tjump titleset 1 menu;\n")
                fichero.write("\t\t\t\t\t}\n")
                fichero.write("\t\t\t\t</pre>\n")
                # fake video (one black picture with one second of sound) to ensure 100% compatibility
                fichero.write('\t\t\t\t<vob file="')
                if self.menu_PAL:
                    fichero.write(self.expand_xml(str(os.path.join(self.installpath, "base_pal.mpg"))))
                else:
                    fichero.write(self.expand_xml(str(os.path.join(self.installpath, "base_ntsc.mpg"))))
                fichero.write('"></vob>\n')
                fichero.write("\t\t\t</pgc>\n")
                fichero.write("\t\t</menus>\n")
                fichero.write("\t</vmgm>\n")

                fichero.write("\n")

                # the first titleset contains all the menus. G1 allows us to jump to the desired menu

                fichero.write("\t<titleset>\n")
                fichero.write("\t\t<menus>\n")
                fichero.write('\t\t\t<video format="')
                if self.menu_PAL:
                    fichero.write("pal")
                else:
                    fichero.write("ntsc")
                fichero.write('" aspect="4:3"> </video>\n')

                button_counter = 0
                for menu_number in range(self.nmenues):
                    fichero.write("\t\t\t<pgc>\n")
                    fichero.write("\t\t\t\t<pre>\n")
                    # first we recover the currently selected button
                    fichero.write("\t\t\t\t\ts8=g2;\n")
                    if menu_number == 0:  # here we add some code to jump to each menu
                        for menu2 in range(self.nmenues - 1):
                            fichero.write("\t\t\t\t\tif (g1 eq " + str(menu2 + 1) + ") {\n")
                            fichero.write("\t\t\t\t\t\tjump menu " + str(menu2 + 2) + ";\n")
                            fichero.write("\t\t\t\t\t}\n")

                            # this code is to fix a bug in some players
                        fichero.write("\t\t\t\t\tif (g1 eq 100) {\n")
                        fichero.write("\t\t\t\t\t\tjump title 1;\n")  # menu '+str(self.nmenues+1)+';\n')
                        fichero.write("\t\t\t\t\t}\n")

                    fichero.write("\t\t\t\t</pre>\n")
                    fichero.write('\t\t\t\t<vob file="')
                    if self.with_menu:
                        fichero.write(
                            self.expand_xml(str(os.path.join(self.filefolder, self.filename)))
                            + "_menu2_"
                            + str(menu_number)
                            + '.mpg"'
                        )
                    else:
                        if self.menu_PAL:
                            fichero.write(self.expand_xml(str(os.path.join(self.installpath, "base_pal.mpg"))) + '"')
                        else:
                            fichero.write(self.expand_xml(str(os.path.join(self.installpath, "base_ntsc.mpg"))) + '"')
                    fichero.write("></vob>\n")

                    if self.with_menu:
                        cantidad = len(
                            self.structure[
                                self.elements_per_menu * menu_number : (menu_number + 1) * self.elements_per_menu
                            ]
                        )
                        for nbutton in range(cantidad):
                            fichero.write('\t\t\t\t<button name="boton')
                            fichero.write(str(menu_number))
                            fichero.write("x")
                            fichero.write(str(nbutton))
                            fichero.write('"> g0=' + str(title_list[button_counter]) + "; jump vmgm menu; </button>\n")
                            button_counter += 1

                        if menu_number != 0:
                            fichero.write('\t\t\t\t<button name="boton')
                            fichero.write(str(menu_number))
                            fichero.write('p"> g1=')
                            fichero.write(str(menu_number - 1))
                            fichero.write("; g2=1024; jump menu ")
                            fichero.write(str(menu_number))
                            fichero.write("; </button>\n")

                        if (menu_number != self.nmenues - 1) and (self.nmenues > 1):
                            fichero.write('\t\t\t\t<button name="boton')
                            fichero.write(str(menu_number))
                            fichero.write('n"> g1=')
                            fichero.write(str(menu_number + 1))
                            fichero.write("; g2=1024; jump menu ")
                            fichero.write(str(menu_number + 2))
                            fichero.write("; </button>\n")

                    fichero.write("\t\t\t\t<post>\n")
                    fichero.write("\t\t\t\t\tg2=s8;\n")
                    fichero.write("\t\t\t\t\tg1=" + str(menu_number) + ";\n")
                    fichero.write("\t\t\t\t\tjump menu " + str(menu_number + 1) + ";\n")
                    fichero.write("\t\t\t\t</post>\n")
                    fichero.write("\t\t\t</pgc>\n")

                fichero.write("\t\t</menus>\n")
                fichero.write("\t\t<titles>\n")
                fichero.write('\t\t\t<video format="')
                if self.menu_PAL:
                    fichero.write("pal")
                else:
                    fichero.write("ntsc")
                fichero.write('" aspect="4:3"> </video>\n')
                fichero.write("\t\t\t<pgc>\n")
                fichero.write('\t\t\t\t<vob file="')
                if self.menu_PAL:
                    fichero.write(self.expand_xml(str(os.path.join(self.installpath, "base_pal.mpg"))))
                else:
                    fichero.write(self.expand_xml(str(os.path.join(self.installpath, "base_ntsc.mpg"))))
                fichero.write('"></vob>\n')
                fichero.write("\t\t\t\t<post>\n")
                fichero.write("\t\t\t\t\tg0=1;\n")
                fichero.write("\t\t\t\t\tg1=0;\n")
                fichero.write("\t\t\t\t\tg2=1024;\n")
                fichero.write("\t\t\t\t\tcall vmgm menu entry title;\n")
                fichero.write("\t\t\t\t</post>\n")
                fichero.write("\t\t\t</pgc>\n")
                fichero.write("\t\t</titles>\n")
                fichero.write("\t</titleset>\n")

                fichero.write("\n")

                # Now we create the titleset for each video

            total_t = len(self.structure)
            titleset = 1
            titles = 0
            counter = 0
            for element in self.structure:
                files = 0
                num_chapters = len(element) - 1
                action = element[0]["jumpto"]
                for element2 in element[1:]:
                    fichero.write("\n")

                    if element2["ismpeg"]:

                        # if it's already an MPEG-2 compliant file, we use the original values
                        if element2["ofps"] == 25:
                            pal_ntsc = "pal"
                            ispal = True
                        else:
                            pal_ntsc = "ntsc"
                            ispal = False
                        if element2["oaspect"] > 1.6:
                            faspect = "16:9"
                            fwide = True
                        else:
                            faspect = "4:3"
                            fwide = False
                    else:
                        # but if we are converting it, we use the desired values
                        if element2["fps"] == 25:
                            pal_ntsc = "pal"
                            ispal = True
                        else:
                            pal_ntsc = "ntsc"
                            ispal = False
                        if element2["aspect"] > 1.6:
                            faspect = "16:9"
                            fwide = True
                        else:
                            faspect = "4:3"
                            fwide = False

                    fichero.write("\t<titleset>\n")
                    if not self.onlyone:
                        fichero.write("\t\t<menus>\n")
                        fichero.write('\t\t\t<video format="' + pal_ntsc + '" aspect="' + faspect + '"')
                        if fwide:
                            fichero.write(' widescreen="nopanscan"')
                        fichero.write("> </video>\n")

                        fichero.write("\t\t\t<pgc>\n")
                        fichero.write("\t\t\t\t<pre>\n")
                        fichero.write("\t\t\t\t\tif (g0 eq 100) {\n")
                        fichero.write("\t\t\t\t\t\tjump vmgm menu entry title;\n")
                        fichero.write("\t\t\t\t\t}\n")
                        fichero.write("\t\t\t\t\tg0=100;\n")
                        fichero.write("\t\t\t\t\tg1=" + str(titles / self.elements_per_menu) + ";\n")
                        fichero.write("\t\t\t\t\tjump title 1;\n")
                        fichero.write("\t\t\t\t</pre>\n")
                        # fake video to ensure compatibility
                        fichero.write('\t\t\t\t<vob file="')
                        if ispal:
                            fichero.write(self.expand_xml(str(os.path.join(self.installpath, "base_pal"))))
                        else:
                            fichero.write(self.expand_xml(str(os.path.join(self.installpath, "base_ntsc"))))
                        if fwide:
                            fichero.write("_wide")
                        fichero.write('.mpg"></vob>\n')
                        fichero.write("\t\t\t</pgc>\n")
                        fichero.write("\t\t</menus>\n")

                    fichero.write("\t\t<titles>\n")
                    fichero.write('\t\t\t<video format="' + pal_ntsc + '" aspect="' + faspect + '"')
                    if fwide:
                        fichero.write(' widescreen="nopanscan"')
                    fichero.write("> </video>\n")

                    for element3 in element2["sub_list"]:
                        fichero.write(
                            '\t\t\t<subpicture lang="'
                            + self.expand_xml(str(element3["sub_language"][:2].lower()))
                            + '" />\n'
                        )
                    fichero.write("\t\t\t<pgc>\n")
                    if (element2["force_subs"]) and (len(element2["sub_list"]) != 0):
                        fichero.write("\t\t\t\t<pre>\n")
                        fichero.write("\t\t\t\t\tsubtitle=64;\n")
                        fichero.write("\t\t\t\t</pre>\n")

                    currentfile = self.create_filename(self.filefolder + self.filename, titles + 1, files + 1, False)
                    fichero.write('\t\t\t\t<vob file="' + self.expand_xml(currentfile) + '" ')
                    fichero.write('chapters="0')
                    if element2["olength"] > 5:
                        if element2["lchapters"] != 0:  # add chapters
                            toadd = int(element2["lchapters"])
                            seconds = toadd * 60
                            while seconds < (element2["olength"] - 4):
                                thetime = devede_other.return_time(seconds, False)
                                fichero.write("," + thetime)
                                seconds += toadd * 60
                        fichero.write("," + devede_other.return_time((element2["olength"] - 2), False))
                    fichero.write('" />\n')

                    if not self.onlyone:
                        fichero.write("\t\t\t\t<post>\n")
                        files += 1
                        fichero.write("\t\t\t\t\tg1=" + str(titles / self.elements_per_menu) + ";\n")
                        if (files == num_chapters) and (action == "menu"):  # last chapter
                            fichero.write("\t\t\t\t\tg0=100;\n")
                            fichero.write("\t\t\t\t\tcall vmgm menu entry title;\n")
                        else:
                            fichero.write("\t\t\t\t\tg0=")
                            if files == num_chapters:  # last chapter; do ACTION
                                if action == "prev":
                                    if titles == 0:
                                        prev_t = total_t - 1
                                    else:
                                        prev_t = titles - 1
                                    fichero.write(str(title_list[prev_t]))
                                elif action == "loop":
                                    fichero.write(str(title_list[titles]))
                                elif action == "next":
                                    if titles == total_t - 1:
                                        next_t = 0
                                    else:
                                        next_t = titles + 1
                                    fichero.write(str(title_list[next_t]))
                                elif action == "last":
                                    fichero.write(str(title_list[total_t - 1]))
                                else:
                                    fichero.write("1")  # first
                            else:
                                # jump to next chapter in title
                                fichero.write(str(title_list[titles] + files))
                            fichero.write(";\n")
                            fichero.write("\t\t\t\t\tcall vmgm menu entry title;\n")
                        fichero.write("\t\t\t\t</post>\n")
                    fichero.write("\t\t\t</pgc>\n")
                    fichero.write("\t\t</titles>\n")
                    fichero.write("\t</titleset>\n")
                    counter += 1
                titles += 1
            fichero.write("</dvdauthor>")
            fichero.close()
            return False
        except IOError:
            return True
Пример #7
0
	def create_xml(self):

		""" Creates the XML file for DVDAuthor """

		# calculate the position for each title
		
		title_list=[]
		counter=1
		for element in self.structure:
			title_list.append(counter)
			counter+=((len(element))-1)

		try:
			fichero=open(self.filefolder+self.filename+".xml","w")
			fichero.write('<dvdauthor dest="'+self.expand_xml(self.filefolder+self.filename)+'">\n')
			
			if self.onlyone:
				fichero.write('\t<vmgm />\n')
			else:
			
				fichero.write('\t<vmgm>\n')
				
				# MENU
				
				# in the FPC we do a jump to the first menu in the first titleset if we wanted MENU
				# or we jump to the second titleset if we didn't want MENU at startup
				
				fichero.write('\t\t<fpc>\n')
				fichero.write('\t\t\tg0=100;\n')
				if self.do_menu and self.with_menu:
					fichero.write('\t\t\tg1=0;\n')
				else:
					fichero.write('\t\t\tg1=100;\n')
				fichero.write('\t\t\tg2=1024;\n')
				fichero.write('\t\t\tjump menu 1;\n')
				fichero.write('\t\t</fpc>\n')
				
				# in the VMGM menu we create a code to jump to the title specified in G0
				# but if the title is 100, we jump to the menus. There we show the menu number
				# contained in G1
				
				fichero.write("\t\t<menus>\n")
					
				fichero.write('\t\t\t<video format="')
				if self.menu_PAL:
					fichero.write("pal")
				else:
					fichero.write("ntsc")
				fichero.write('" aspect="4:3"> </video>\n')
	
				fichero.write('\t\t\t<pgc>\n')
				fichero.write('\t\t\t\t<pre>\n')
				
				counter=1
				for element in self.structure:
					for element2 in element[1:]:
						fichero.write('\t\t\t\t\tif (g0 eq '+str(counter)+') {\n')
						fichero.write('\t\t\t\t\t\tjump titleset '+str(1+counter)+' menu;\n')
						fichero.write('\t\t\t\t\t}\n')
						counter+=1
				fichero.write('\t\t\t\t\tif (g0 eq 100) {\n')
				fichero.write('\t\t\t\t\t\tg2=1024;\n')
				fichero.write('\t\t\t\t\t\tjump titleset 1 menu;\n')
				fichero.write('\t\t\t\t\t}\n')
				fichero.write('\t\t\t\t</pre>\n')
				# fake video (one black picture with one second of sound) to ensure 100% compatibility
				fichero.write('\t\t\t\t<vob file="')
				if self.menu_PAL:
					fichero.write(self.expand_xml(str(os.path.join(self.installpath,"base_pal.mpg"))))
				else:
					fichero.write(self.expand_xml(str(os.path.join(self.installpath,"base_ntsc.mpg"))))
				fichero.write('"></vob>\n')
				fichero.write('\t\t\t</pgc>\n')
				fichero.write('\t\t</menus>\n')
				fichero.write("\t</vmgm>\n")
				
				fichero.write("\n")
				
				# the first titleset contains all the menus. G1 allows us to jump to the desired menu
				
				fichero.write('\t<titleset>\n')
				fichero.write('\t\t<menus>\n')
				fichero.write('\t\t\t<video format="')
				if self.menu_PAL:
					fichero.write("pal")
				else:
					fichero.write("ntsc")
				fichero.write('" aspect="4:3"> </video>\n')
				
				button_counter=0
				for menu_number in range(self.nmenues):
					fichero.write('\t\t\t<pgc>\n')
					fichero.write('\t\t\t\t<pre>\n')
					# first we recover the currently selected button
					fichero.write('\t\t\t\t\ts8=g2;\n')
					if menu_number==0: # here we add some code to jump to each menu
						for menu2 in range(self.nmenues-1):
							fichero.write('\t\t\t\t\tif (g1 eq '+str(menu2+1)+') {\n')
							fichero.write('\t\t\t\t\t\tjump menu '+str(menu2+2)+';\n')
							fichero.write('\t\t\t\t\t}\n')
						
						# this code is to fix a bug in some players
						fichero.write('\t\t\t\t\tif (g1 eq 100) {\n')
						fichero.write('\t\t\t\t\t\tjump title 1;\n')#menu '+str(self.nmenues+1)+';\n')
						fichero.write('\t\t\t\t\t}\n')
						
					fichero.write('\t\t\t\t</pre>\n')
					fichero.write('\t\t\t\t<vob file="')
					if self.with_menu:
						fichero.write(self.expand_xml(str(os.path.join(self.filefolder,self.filename)))+'_menu2_'+str(menu_number)+'.mpg"')
					else:
						if self.menu_PAL:
							fichero.write(self.expand_xml(str(os.path.join(self.installpath,"base_pal.mpg")))+'"')
						else:
							fichero.write(self.expand_xml(str(os.path.join(self.installpath,"base_ntsc.mpg")))+'"')
					fichero.write('></vob>\n')
					
					if self.with_menu:
						cantidad=len(self.structure[self.elements_per_menu*menu_number:(menu_number+1)*self.elements_per_menu])
						for nbutton in range(cantidad):
							fichero.write('\t\t\t\t<button name="boton')
							fichero.write(str(menu_number))
							fichero.write('x')
							fichero.write(str(nbutton))
							fichero.write('"> g0='+str(title_list[button_counter])+'; jump vmgm menu; </button>\n')
							button_counter+=1
							
						if (menu_number!=0):
							fichero.write('\t\t\t\t<button name="boton')
							fichero.write(str(menu_number))
							fichero.write('p"> g1=')
							fichero.write(str(menu_number-1))
							fichero.write('; g2=1024; jump menu ')
							fichero.write(str(menu_number))
							fichero.write('; </button>\n')
							
						if (menu_number!=self.nmenues-1) and (self.nmenues>1):
							fichero.write('\t\t\t\t<button name="boton')
							fichero.write(str(menu_number))
							fichero.write('n"> g1=')
							fichero.write(str(menu_number+1))
							fichero.write('; g2=1024; jump menu ')
							fichero.write(str(menu_number+2))
							fichero.write('; </button>\n')
					
					fichero.write('\t\t\t\t<post>\n')
					fichero.write('\t\t\t\t\tg2=s8;\n')
					fichero.write('\t\t\t\t\tg1='+str(menu_number)+';\n')
					fichero.write('\t\t\t\t\tjump menu '+str(menu_number+1)+';\n')
					fichero.write('\t\t\t\t</post>\n')
					fichero.write('\t\t\t</pgc>\n')
				
				fichero.write('\t\t</menus>\n')
				fichero.write('\t\t<titles>\n')
				fichero.write('\t\t\t<video format="')
				if self.menu_PAL:
					fichero.write("pal")
				else:
					fichero.write("ntsc")
				fichero.write('" aspect="4:3"> </video>\n')
				fichero.write('\t\t\t<pgc>\n')
				fichero.write('\t\t\t\t<vob file="')
				if self.menu_PAL:
					fichero.write(self.expand_xml(str(os.path.join(self.installpath,"base_pal.mpg"))))
				else:
					fichero.write(self.expand_xml(str(os.path.join(self.installpath,"base_ntsc.mpg"))))
				fichero.write('"></vob>\n')
				fichero.write('\t\t\t\t<post>\n')
				fichero.write('\t\t\t\t\tg0=1;\n')
				fichero.write('\t\t\t\t\tg1=0;\n')
				fichero.write('\t\t\t\t\tg2=1024;\n')
				fichero.write('\t\t\t\t\tcall vmgm menu entry title;\n')
				fichero.write('\t\t\t\t</post>\n')
				fichero.write('\t\t\t</pgc>\n')
				fichero.write('\t\t</titles>\n')
				fichero.write("\t</titleset>\n")
	
				fichero.write("\n")
				
			# Now we create the titleset for each video
			
			total_t=len(self.structure)
			titleset=1
			titles=0
			counter=0
			for element in self.structure:
				files=0
				num_chapters=len(element)-1
				action=element[0]["jumpto"]
				for element2 in element[1:]:
					fichero.write("\n")
					
					if element2["ismpeg"]:

						# if it's already an MPEG-2 compliant file, we use the original values
						if element2["ofps"]==25:
							pal_ntsc="pal"
							ispal=True
						else:
							pal_ntsc="ntsc"
							ispal=False
						if element2["oaspect"]>1.6:
							faspect='16:9'
							fwide=True
						else:
							faspect='4:3'
							fwide=False
					else:
						# but if we are converting it, we use the desired values
						if element2["fps"]==25:
							pal_ntsc="pal"
							ispal=True
						else:
							pal_ntsc="ntsc"
							ispal=False
						if element2["aspect"]>1.6:
							faspect='16:9'
							fwide=True
						else:
							faspect='4:3'
							fwide=False
					
					fichero.write("\t<titleset>\n")
					if not self.onlyone:
						fichero.write("\t\t<menus>\n")
						fichero.write('\t\t\t<video format="'+pal_ntsc+'" aspect="'+faspect+'"')
						if fwide:
							fichero.write(' widescreen="nopanscan"')
						fichero.write('> </video>\n')
						
						fichero.write("\t\t\t<pgc>\n")
						fichero.write("\t\t\t\t<pre>\n")
						fichero.write('\t\t\t\t\tif (g0 eq 100) {\n')
						fichero.write('\t\t\t\t\t\tjump vmgm menu entry title;\n')
						fichero.write('\t\t\t\t\t}\n')
						fichero.write('\t\t\t\t\tg0=100;\n')
						fichero.write('\t\t\t\t\tg1='+str(titles/self.elements_per_menu)+';\n')
						fichero.write('\t\t\t\t\tjump title 1;\n')
						fichero.write('\t\t\t\t</pre>\n')
						# fake video to ensure compatibility
						fichero.write('\t\t\t\t<vob file="')
						if ispal:
							fichero.write(self.expand_xml(str(os.path.join(self.installpath,"base_pal"))))
						else:
							fichero.write(self.expand_xml(str(os.path.join(self.installpath,"base_ntsc"))))
						if fwide:
							fichero.write("_wide")
						fichero.write('.mpg"></vob>\n')
						fichero.write("\t\t\t</pgc>\n")
						fichero.write("\t\t</menus>\n")

					fichero.write("\t\t<titles>\n")
					fichero.write('\t\t\t<video format="'+pal_ntsc+'" aspect="'+faspect+'"')
					if fwide:
						fichero.write(' widescreen="nopanscan"')
					fichero.write('> </video>\n')
					
					for element3 in element2["sub_list"]:
						fichero.write('\t\t\t<subpicture lang="'+self.expand_xml(str(element3["sub_language"][:2].lower()))+'" />\n')
					fichero.write('\t\t\t<pgc>\n')
					if (element2["force_subs"]) and (len(element2["sub_list"])!=0):
						fichero.write('\t\t\t\t<pre>\n')
						fichero.write('\t\t\t\t\tsubtitle=64;\n')
						fichero.write('\t\t\t\t</pre>\n')

					currentfile=self.create_filename(self.filefolder+self.filename,titles+1,files+1,False)
					fichero.write('\t\t\t\t<vob file="'+self.expand_xml(currentfile)+'" ')
					fichero.write('chapters="0')
					if (element2["olength"]>5):
						if (element2["lchapters"]!=0): # add chapters
							toadd=int(element2["lchapters"])
							seconds=toadd*60
							while seconds<(element2["olength"]-4):
								thetime=devede_other.return_time(seconds,False)
								fichero.write(","+thetime)
								seconds+=(toadd*60)
						fichero.write(','+devede_other.return_time((element2["olength"]-2),False))
					fichero.write('" />\n')
					
					if not self.onlyone:
						fichero.write('\t\t\t\t<post>\n')
						files+=1
						fichero.write('\t\t\t\t\tg1='+str(titles/self.elements_per_menu)+';\n')
						if (files==num_chapters) and (action=="menu"): # last chapter
							fichero.write('\t\t\t\t\tg0=100;\n')
							fichero.write('\t\t\t\t\tcall vmgm menu entry title;\n')
						else:
							fichero.write('\t\t\t\t\tg0=')
							if (files==num_chapters): # last chapter; do ACTION
								if action=="prev":
									if titles==0:
										prev_t=total_t-1
									else:
										prev_t=titles-1
									fichero.write(str(title_list[prev_t]))
								elif action=="loop":
									fichero.write(str(title_list[titles]))
								elif action=="next":
									if titles==total_t-1:
										next_t=0
									else:
										next_t=titles+1
									fichero.write(str(title_list[next_t]))
								elif action=="last":
									fichero.write(str(title_list[total_t-1]))
								else:
									fichero.write('1') # first
							else:
								 # jump to next chapter in title
								fichero.write(str(title_list[titles]+files))
							fichero.write(';\n')
							fichero.write('\t\t\t\t\tcall vmgm menu entry title;\n')
						fichero.write('\t\t\t\t</post>\n')
					fichero.write("\t\t\t</pgc>\n")
					fichero.write("\t\t</titles>\n")
					fichero.write("\t</titleset>\n")
					counter+=1
				titles+=1
			fichero.write("</dvdauthor>")
			fichero.close()
			return False
		except IOError:
			return True
Пример #8
0
	def create_xml(self,structure,do_menu,menu_PAL,menu_widescreen):

		""" Creates the XML file for DVDAuthor """

		try:
			fichero=open(self.filefolder+self.filename+".xml","w")
			fichero.write('<dvdauthor dest="'+self.filefolder+self.filename+'">\n')
			fichero.write("<vmgm>\n")
			fichero.write("</vmgm>\n")
			titles=0
			total_t=len(structure)
			fichero.write("<titleset>\n")
		
			if do_menu:
				fichero.write("<menus>\n")
				fichero.write('<video format="')
				if menu_PAL:
					fichero.write("pal")
				else:
					fichero.write("ntsc")
				fichero.write('" aspect="')
				if menu_widescreen:
					fichero.write("16:9")
				else:
					fichero.write("4:3")
				fichero.write('"> </video>\n')
				fichero.write('<pgc>\n')
				fichero.write('<vob file="'+self.filefolder+self.filename+'_menu2.mpg"></vob>\n')
				contador=0
				for elemento in structure:
					fichero.write('<button name="boton'+str(contador)+'">jump title '+str(contador+1)+';</button>\n')
					contador+=1
				fichero.write('</pgc>\n</menus>\n')
		
			fichero.write("<titles>\n")
			for elemento in structure:
				action=elemento[0]["jumpto"]
				titles+=1
				fichero.write("<pgc>\n")
				if len(elemento)>1:
					files=0
					for elemento2 in elemento[1:]:
						files+=1
						currentfile=self.create_filename(self.filefolder+self.filename,titles,files,False)
						fichero.write('<vob file="'+currentfile+'" ')
						fichero.write('chapters="0')
						if (elemento2["olength"]>5):
							if (elemento2["lchapters"]!=0): # add chapters
								toadd=int(elemento2["lchapters"])
								seconds=toadd*60
								while seconds<(elemento2["olength"]-4):
									thetime=devede_other.return_time(seconds,False)
									fichero.write(","+thetime)
									seconds+=(toadd*60)
							fichero.write(','+devede_other.return_time((elemento2["olength"]-2),False))
						fichero.write('" />\n')
					if action=="menu":
						if do_menu:
							fichero.write("<post>call menu;</post>\n")
					elif action=="first":
						fichero.write("<post>jump title 1;</post>\n")
					elif action=="prev":
						if titles==1:
							prev_t=total_t
						else:
							prev_t=titles-1
						fichero.write("<post>jump title "+str(prev_t)+";</post>\n")
					elif action=="loop":
						fichero.write("<post>jump title "+str(titles)+";</post>\n")
					elif action=="next":
						if titles==total_t:
							next_t=1
						else:
							next_t=titles+1
						fichero.write("<post>jump title "+str(next_t)+";</post>\n")
					elif action=="last":
						fichero.write("<post>jump title "+str(total_t)+";</post>\n")
					fichero.write("</pgc>\n")
			fichero.write("</titles>\n</titleset>\n")
			fichero.write("</dvdauthor>")
			fichero.close()
			return False
		except IOError:
			return True