X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/3c066dfc061d51c59caf201e302cfb2301b5f0f7..8ab0666af66fdb08f955daa70b255a5841ea73fb:/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py diff --git a/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py b/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py index fe09642b..8d02cb22 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py +++ b/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py @@ -1,9 +1,53 @@ from Tools.Directories import fileExists +from Components.config import config, ConfigSubsection, ConfigInteger, ConfigYesNo, ConfigText, ConfigSelection, getConfigListEntry, ConfigSequence +class ConfigColor(ConfigSequence): + def __init__(self): + ConfigSequence.__init__(self, seperator = "#", limits = [(0,255),(0,255),(0,255)]) + +class ConfigPixelvals(ConfigSequence): + def __init__(self): + ConfigSequence.__init__(self, seperator = ",", limits = [(0,200),(0,200),(0,200)]) + +class ConfigPixelvals(ConfigSequence): + def __init__(self): + ConfigSequence.__init__(self, seperator = ",", limits = [(0,200),(0,200),(0,200)]) + +class ConfigFilename(ConfigText): + def __init__(self): + ConfigText.__init__(self, default = "", fixed_size = True, visible_width = False) + + def getMulti(self, selected): + filename = (self.text.rstrip("/").rsplit("/",1))[1].encode("utf-8")[:40] + " " + if self.allmarked: + mark = range(0, len(filename)) + else: + mark = [filename] + return ("mtext"[1-selected:], filename, mark) + class DVDProject: def __init__(self): self.titles = [ ] self.target = None + self.settings = ConfigSubsection() + self.settings.name = ConfigText(fixed_size = False, visible_width = 40) + self.settings.authormode = ConfigSelection(choices = [("menu_linked", _("Linked titles with a DVD menu")), ("just_linked", _("Direct playback of linked titles without menu")), ("menu_seperate", _("Seperate titles with a main menu")), ("data_ts", _("Dreambox format data DVD (HDTV compatible)"))]) + self.settings.output = ConfigSelection(choices = [("iso", _("Create DVD-ISO")), ("dvd", _("Burn DVD"))]) + self.settings.isopath = ConfigText(fixed_size = False, visible_width = 40) + self.settings.dataformat = ConfigSelection(choices = [("iso9660_1", ("ISO9660 Level 1")), ("iso9660_4", ("ISO9660 version 2")), ("udf", ("UDF"))]) + self.settings.menubg = ConfigFilename() + self.settings.menuaudio = ConfigFilename() + self.settings.titleformat = ConfigText(fixed_size = False, visible_width = 40) + self.settings.subtitleformat = ConfigText(fixed_size = False, visible_width = 40) + self.settings.color_headline = ConfigColor() + self.settings.color_highlight = ConfigColor() + self.settings.color_button = ConfigColor() + self.settings.font_face = ConfigFilename() + self.settings.font_size = ConfigPixelvals() + self.settings.space = ConfigPixelvals() + self.settings.vmgm = ConfigFilename() + self.settings.autochapter = ConfigInteger(default = 0, limits = (0, 99)) + self.filekeys = ["vmgm", "menubg", "menuaudio", "font_face", "isopath"] def addService(self, service): import DVDTitle @@ -18,26 +62,11 @@ class DVDProject: list = [] list.append('\n') list.append('\n') - list.append('\t\n') - list.append('\t\n') - list.append('\t\n') + list.append('\t\n') + list.append('\t\n') for title in self.titles: list.append('\t\t') list.append(stringToXML(title.source.getPath())) @@ -45,65 +74,60 @@ class DVDProject: list.append('\t\n') list.append('\n') + name = self.settings.name.getValue() i = 0 - filename = path + "/" + self.name + ".ddvdp.xml" + filename = path + name + ".ddvdp.xml" while fileExists(filename): i = i+1 - filename = path + "/" + self.name + str(i).zfill(3) + ".ddvdp.xml" - - file = open(filename, "w") - for x in list: - file.write(x) - file.close() + filename = path + name + str(i).zfill(3) + ".ddvdp.xml" + try: + file = open(filename, "w") + for x in list: + file.write(x) + file.close() + except: + return False + return filename def loadProject(self, filename): import xml.dom.minidom - print "[loadProject]", filename try: - if not fileExists(filename): - self.error = "file not found!" - raise AttributeError - else: - self.error = "" - file = open(filename, "r") - data = file.read().decode("utf-8").replace('&',"&").encode("ascii",'xmlcharrefreplace') - file.close() - projectfiledom = xml.dom.minidom.parseString(data) - for project in projectfiledom.childNodes[0].childNodes: - if project.nodeType == xml.dom.minidom.Element.nodeType: - if project.tagName == 'project': - self.name = project.getAttribute("name").encode("utf-8") - self.vmgm = project.getAttribute("vmgm").encode("utf-8") - if project.tagName == 'menu': - self.menu = eval(project.getAttribute("use")) - self.menubg = project.getAttribute("bg").encode("utf-8") - self.menuaudio = project.getAttribute("audio").encode("utf-8") - # tuples with R, G, B values - self.color_button = eval(project.getAttribute("color_button")) - self.color_highlight = eval(project.getAttribute("color_highlight")) - self.color_headline = eval(project.getAttribute("color_headline")) - self.font_face = project.getAttribute("font_face").encode("utf-8") - # tuple with three pixel sizes ( headline, title, subtitle ) - self.font_size = eval(project.getAttribute("font_size")) - # please supply even numbers for all dimensions - self.space_left = int(project.getAttribute("space_left")) - self.space_top = int(project.getAttribute("space_top")) - self.space_rows = int(project.getAttribute("space_rows")) - if project.tagName == 'titles': - self.linktitles = eval(project.getAttribute("link")) - if not fileExists(self.vmgm): - self.error += "\nvmgm '%s' not found" % self.vmgm - if not fileExists(self.menubg): - self.error += "\nmenu background '%s' not found" % self.menubg - if not fileExists(self.menuaudio): - self.error += "\nmenu audio '%s' not found" % self.menuaudio - if not fileExists(self.font_face): - self.error += "\nmenu font '%s' not found" % self.font_face - print "len(self.error):", len(self.error) - if len(self.error): - raise AttributeError - except: - print "len(self.error):, error", len(self.error), len(self.error) - self.error = ("error parsing project xml file '%s'" % filename) + self.error + if not fileExists(filename): + self.error = "xml file not found!" + raise AttributeError + else: + self.error = "" + file = open(filename, "r") + data = file.read().decode("utf-8").replace('&',"&").encode("ascii",'xmlcharrefreplace') + file.close() + projectfiledom = xml.dom.minidom.parseString(data) + for project in projectfiledom.childNodes[0].childNodes: + if project.nodeType == xml.dom.minidom.Element.nodeType: + if project.tagName == 'settings': + i = 0 + if project.attributes.length < 11: + self.error = "project attributes missing" + raise AttributeError + while i < project.attributes.length: + item = project.attributes.item(i) + key = item.name.encode("utf-8") + try: + val = eval(item.nodeValue) + except (NameError, SyntaxError): + val = item.nodeValue.encode("utf-8") + try: + self.settings.dict()[key].setValue(val) + except (KeyError): + self.error = "unknown attribute '%s'" % (key) + raise AttributeError + i += 1 + for key in self.filekeys: + val = self.settings.dict()[key].getValue() + if not fileExists(val): + self.error += "\n%s '%s' not found" % (key, val) + if len(self.error): + raise AttributeError + except AttributeError: + self.error += (" in project '%s'") % (filename) return False return True