fix cuesheets, add multiple menu pages support, add preview support, add project...
[enigma2.git] / lib / python / Plugins / Extensions / DVDBurn / DVDProject.py
1 from Tools.Directories import resolveFilename, fileExists, SCOPE_FONTS, SCOPE_PLUGINS, SCOPE_SKIN
2 class DVDProject:
3         def __init__(self):
4                 self.titles = [ ]
5                 self.target = None
6                 self.name = _("Dreambox DVD record")
7                 self.vmgm = resolveFilename(SCOPE_PLUGINS,"Extensions/DVDBurn/dreamvmgm.mpg")
8                 self.menuaudio = resolveFilename(SCOPE_PLUGINS,"Extensions/DVDBurn/silence.mp2")
9                 self.menubg = resolveFilename(SCOPE_SKIN, "dreamdvd_02.jpg")
10                 # tuples with R, G, B values
11                 self.color_button       = ( 0x08, 0x00, 0x00 )
12                 self.color_highlight    = ( 0x00, 0xC0, 0xC0 )
13                 self.color_headline     = ( 0x00, 0x00, 0x80 )
14                 self.font_face = resolveFilename(SCOPE_FONTS, "nmsbd.ttf")
15                 # tuple with three pixel values ( headline, title, subtitle )
16                 self.font_size = ( 48, 28, 16 )
17                 # please supply even numbers for all dimensions
18                 self.space_left = 30
19                 self.space_top = 120
20                 self.space_rows = 36
21
22         def addService(self, service):
23                 import DVDTitle
24                 title = DVDTitle.DVDTitle()
25                 title.addService(service)
26                 self.titles.append(title)
27                 return title
28         
29         def saveProject(self, path):
30                 import xml.dom.minidom
31                 from Tools.XMLTools import elementsWithTag, mergeText, stringToXML
32                 list = []
33                 list.append('<?xml version="1.0" encoding="utf-8" ?>\n')
34                 list.append('<DreamDVDBurnerProject>\n')
35                 list.append('\t<config')
36                 list.append(' name="' + self.name + '"')
37                 list.append(' vmgm="' + self.vmgm + '"')
38                 list.append(' />\n')
39                 list.append('\t<menu')
40                 list.append(' bg="' + self.menubg + '"')
41                 list.append(' audio="' + self.menuaudio + '"')
42                 list.append(' color_button="' + str(self.color_button) + '"')
43                 list.append(' color_highlight="' + str(self.color_highlight) + '"')
44                 list.append(' color_headline="' + str(self.color_headline) + '"')
45                 list.append(' font_face="' + self.font_face + '"')
46                 list.append(' font_size="' + str(self.font_size) + '"')
47                 list.append(' space_left="' + str(self.space_left) + '"')
48                 list.append(' space_top="' + str(self.space_top) + '"')
49                 list.append(' space_rows="' + str(self.space_rows) + '"')
50                 list.append(' />\n')
51                 list.append('\t<titles>\n')
52                 for title in self.titles:
53                         list.append('\t\t<path>')
54                         list.append(stringToXML(title.source.getPath()))
55                         list.append('</path>\n')
56                 list.append('\t</titles>\n')
57                 list.append('</DreamDVDBurnerProject>\n')
58
59                 i = 0
60                 filename = path + "/" + self.name + ".ddvdp.xml"
61                 while fileExists(filename):
62                         i = i+1
63                         filename = path + "/" + self.name + str(i).zfill(3) + ".ddvdp.xml"
64                                 
65                 file = open(filename, "w")
66                 for x in list:
67                         file.write(x)
68                 file.close()