1 import DVDProject, TitleList, TitleCutter, TitleProperties, ProjectSettings, DVDToolbox, Process
2 from Screens.Screen import Screen
3 from Screens.ChoiceBox import ChoiceBox
4 from Screens.InputBox import InputBox
5 from Screens.MessageBox import MessageBox
6 from Screens.HelpMenu import HelpableScreen
7 from Screens.TaskView import JobView
8 from Components.Task import job_manager
9 from Components.ActionMap import HelpableActionMap, ActionMap
10 from Components.Sources.List import List
11 from Components.Sources.StaticText import StaticText
12 from Components.Sources.Progress import Progress
13 from Components.MultiContent import MultiContentEntryText
14 from enigma import gFont, RT_HALIGN_LEFT, RT_HALIGN_RIGHT
15 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
17 class TitleList(Screen, HelpableScreen):
19 <screen name="TitleList" position="center,center" size="560,445" title="DVD Tool" >
20 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
21 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
22 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
23 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
24 <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
25 <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
26 <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
27 <widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
28 <widget source="title_label" render="Label" position="10,48" size="540,38" font="Regular;18" transparent="1" />
29 <widget source="error_label" render="Label" position="10,48" size="540,395" zPosition="3" font="Regular;20" transparent="1" />
30 <widget source="titles" render="Listbox" scrollbarMode="showOnDemand" position="10,86" size="540,312" zPosition="3" transparent="1" >
31 <convert type="TemplatedMultiContent">
33 MultiContentEntryText(pos = (0, 0), size = (420, 20), font = 0, flags = RT_HALIGN_LEFT, text = 1), # index 1 Title,
34 MultiContentEntryText(pos = (0, 20), size = (328, 17), font = 1, flags = RT_HALIGN_LEFT, text = 2), # index 2 description,
35 MultiContentEntryText(pos = (420, 6), size = (120, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 3), # index 3 begin time,
36 MultiContentEntryText(pos = (328, 20), size = (154, 17), font = 1, flags = RT_HALIGN_RIGHT, text = 4), # index 4 channel,
37 MultiContentEntryText(pos = (482, 20), size = (58, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 5), # index 4 channel,
39 "fonts": [gFont("Regular", 20), gFont("Regular", 14)],
44 <widget source="space_bar" render="Progress" position="10,410" size="540,26" borderWidth="1" backgroundColor="#254f7497" />
45 <widget source="space_label" render="Label" position="40,414" size="480,22" zPosition="2" font="Regular;18" halign="center" transparent="1" foregroundColor="#000000" />
48 def __init__(self, session, project = None):
49 Screen.__init__(self, session)
50 HelpableScreen.__init__(self)
52 self["titleactions"] = HelpableActionMap(self, "DVDTitleList",
54 "addTitle": (self.addTitle, _("Add a new title"), _("Add title")),
55 "titleProperties": (self.titleProperties, _("Properties of current title"), _("Title properties")),
56 "removeCurrentTitle": (self.removeCurrentTitle, _("Remove currently selected title"), _("Remove title")),
57 "settings": (self.settings, _("Collection settings"), _("Settings")),
58 "burnProject": (self.askBurnProject, _("Burn DVD"), _("Burn DVD")),
61 self["MovieSelectionActions"] = HelpableActionMap(self, "MovieSelectionActions",
63 "contextMenu": (self.showMenu, _("menu")),
66 self["actions"] = ActionMap(["OkCancelActions"],
71 self["key_red"] = StaticText()
72 self["key_green"] = StaticText(_("Add title"))
73 self["key_yellow"] = StaticText()
74 self["key_blue"] = StaticText(_("Settings"))
76 self["title_label"] = StaticText()
77 self["error_label"] = StaticText()
78 self["space_label"] = StaticText()
79 self["space_bar"] = Progress()
81 if project is not None:
82 self.project = project
86 self["titles"] = List([])
87 self.updateTitleList()
88 self.previous_size = 0
89 self.onLayoutFinish.append(self.layoutFinished)
91 def layoutFinished(self):
92 self.setTitle(_("DVD Titlelist"))
94 def checkBackgroundJobs(self):
95 for job in job_manager.getPendingJobs():
96 print "type(job):", type(job)
97 print "Process.DVDJob:", Process.DVDJob
98 if type(job) == Process.DVDJob:
99 self.backgroundJob = job
101 self.backgroundJob = None
105 self.checkBackgroundJobs()
106 if self.backgroundJob:
107 j = self.backgroundJob
108 menu.append(("%s: %s (%d%%)" % (j.getStatustext(), j.name, int(100*j.progress/float(j.end))), self.showBackgroundJob))
109 menu.append((_("DVD media toolbox"), self.toolbox))
110 menu.append((_("Preview menu"), self.previewMenu))
111 if self.project.settings.output.getValue() == "dvd":
112 if len(self["titles"].list):
113 menu.append((_("Burn DVD"), self.burnProject))
114 elif self.project.settings.output.getValue() == "iso":
115 menu.append((_("Create DVD-ISO"), self.burnProject))
116 menu.append((_("Burn existing image to DVD"), self.selectImage))
117 menu.append((_("Edit chapters of current title"), self.editTitle))
118 menu.append((_("Reset and renumerate title names"), self.resetTitles))
119 menu.append((_("Exit"), self.leave))
120 self.session.openWithCallback(self.menuCallback, ChoiceBox, title="", list=menu)
122 def menuCallback(self, choice):
126 def showBackgroundJob(self):
127 job_manager.in_background = False
128 self.session.openWithCallback(self.JobViewCB, JobView, self.backgroundJob)
129 self.backgroundJob = None
131 def titleProperties(self):
132 if self.getCurrentTitle():
133 self.session.openWithCallback(self.updateTitleList, TitleProperties.TitleProperties, self, self.project, self["titles"].getIndex())
135 def selectImage(self):
136 self.session.openWithCallback(self.burnISO, ProjectSettings.FileBrowser, "image", self.project.settings)
138 def newProject(self):
139 self.project = DVDProject.DVDProject()
140 if self.loadTemplate():
141 self.project.session = self.session
145 from Screens.MovieSelection import MovieSelection
146 from Components.ActionMap import HelpableActionMap
147 class DVDMovieSelection(MovieSelection):
148 skin = """<screen name="DVDMovieSelection" position="center,center" size="560,445" title="Select a movie">
149 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
150 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
151 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
152 <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
153 <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
154 <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
155 <widget name="waitingtext" position="0,45" size="560,395" zPosition="4" font="Regular;22" halign="center" valign="center" />
156 <widget name="list" position="5,40" size="550,375" zPosition="2" scrollbarMode="showOnDemand" />
157 <widget name="DescriptionBorder" pixmap="skin_default/border_eventinfo.png" position="0,316" zPosition="1" size="560,103" transparent="1" alphatest="on" />
158 <widget source="Service" render="Label" position="5,318" zPosition="1" size="480,35" font="Regular;17" foregroundColor="#cccccc">
159 <convert type="MovieInfo">ShortDescription</convert>
161 <widget source="Service" render="Label" position="495,318" zPosition="1" size="60,22" font="Regular;17" halign="right">
162 <convert type="ServiceTime">Duration</convert>
163 <convert type="ClockToText">AsLength</convert>
165 <widget source="Service" render="Label" position="380,337" zPosition="2" size="175,22" font="Regular;17" halign="right">
166 <convert type="MovieInfo">RecordServiceName</convert>
168 <widget source="Service" render="Label" position="5,357" zPosition="1" size="550,58" font="Regular;19">
169 <convert type="EventName">ExtendedDescription</convert>
171 <widget name="freeDiskSpace" position="10,425" size="540,20" font="Regular;19" valign="center" halign="right" />
173 def __init__(self, session):
174 MovieSelection.__init__(self, session)
175 self["key_red"] = StaticText(_("Close"))
176 self["key_green"] = StaticText(_("Add"))
177 self["key_yellow"] = StaticText(_("Edit title"))
178 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
180 "red": (self.close, _("Close title selection")),
181 "green": (self.insertWithoutEdit, ("insert without cutlist editor")),
182 "yellow": (self.movieSelected, _("Add a new title"))
184 def updateTags(self):
187 print "context menu forbidden inside DVDBurn to prevent calling multiple instances"
188 def insertWithoutEdit(self):
189 current = self.getCurrent()
190 if current is not None:
193 def movieSelected(self):
194 current = self.getCurrent()
195 if current is not None:
198 self.session.openWithCallback(self.selectedSource, DVDMovieSelection)
200 def selectedSource(self, source):
203 if not source.getPath().endswith(".ts"):
204 self.session.open(MessageBox,text = _("You can only burn Dreambox recordings!"), type = MessageBox.TYPE_ERROR)
206 t = self.project.addService(source)
209 except AttributeError:
211 self.editTitle(t, editor)
213 def removeCurrentTitle(self):
214 title = self.getCurrentTitle()
215 self.removeTitle(title)
217 def removeTitle(self, title):
218 if title is not None:
219 self.project.titles.remove(title)
220 self.updateTitleList()
223 self.session.open(DVDToolbox.DVDToolbox)
226 self.session.openWithCallback(self.settingsCB, ProjectSettings.ProjectSettings, self.project)
228 def settingsCB(self, update=True):
231 self["title_label"].text = _("Table of content for collection") + " \"" + self.project.settings.name.getValue() + "\":"
233 def loadTemplate(self):
234 filename = resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/DreamboxDVD.ddvdp.xml"
235 if self.project.load(filename):
236 self["error_label"].setText("")
239 self["error_label"].setText(self.project.error)
242 def askBurnProject(self):
243 if len(self["titles"].list):
244 self.session.openWithCallback(self.burnProject,MessageBox,text = _("Do you want to burn this collection to DVD medium?"), type = MessageBox.TYPE_YESNO)
246 def burnProject(self, answer=True):
249 if self.project.settings.authormode.getValue() == "data_ts":
250 job = Process.DVDdataJob(self.project)
251 job_manager.AddJob(job)
252 job_manager.in_background = False
253 self.session.openWithCallback(self.JobViewCB, JobView, job)
255 job = Process.DVDJob(self.project)
256 job_manager.AddJob(job)
257 job_manager.in_background = False
258 self.session.openWithCallback(self.JobViewCB, JobView, job)
260 def burnISO(self, path, scope, configRef):
262 job = Process.DVDisoJob(self.project, path)
263 job_manager.AddJob(job)
264 job_manager.in_background = False
265 self.session.openWithCallback(self.JobViewCB, JobView, job)
267 def JobViewCB(self, in_background):
268 job_manager.in_background = in_background
270 def previewMenu(self):
271 job = Process.DVDJob(self.project, menupreview=True)
272 job_manager.in_background = False
273 job_manager.AddJob(job)
275 def updateTitleList(self):
277 for title in self.project.titles:
278 list.append((title, title.properties.menutitle.getValue(), title.properties.menusubtitle.getValue(), title.DVBchannel, title.formatDVDmenuText("$D.$M.$Y, $T", 0), title.formatDVDmenuText("$l", 0)))
279 self["titles"].list = list
282 self["key_red"].text = _("Remove title")
283 self["key_yellow"].text = _("Title properties")
285 self["key_red"].text = ""
286 self["key_yellow"].text = ""
288 def updateSize(self):
289 size = self.project.size/(1024*1024)
290 MAX_DL = self.project.MAX_DL-100
291 MAX_SL = self.project.MAX_SL-100
292 print "updateSize:", size, "MAX_DL:", MAX_DL, "MAX_SL:", MAX_SL
294 percent = 100 * size / float(MAX_DL)
295 self["space_label"].text = "%d MB - " % size + _("exceeds dual layer medium!") + " (%.2f%% " % (100-percent) + _("free") + ")"
296 self["space_bar"].value = int(percent)
297 if self.previous_size < MAX_DL:
298 self.session.open(MessageBox,text = _("exceeds dual layer medium!"), type = MessageBox.TYPE_ERROR)
300 percent = 100 * size / float(MAX_DL)
301 self["space_label"].text = "%d MB " % size + _("of a DUAL layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")"
302 self["space_bar"].value = int(percent)
303 if self.previous_size < MAX_SL:
304 self.session.open(MessageBox,text = _("Your collection exceeds the size of a single layer medium, you will need a blank dual layer DVD!"), type = MessageBox.TYPE_INFO)
306 percent = 100 * size / float(MAX_SL)
307 self["space_label"].text = "%d MB " % size + _("of a SINGLE layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")"
308 self["space_bar"].value = int(percent)
309 self.previous_size = size
311 def getCurrentTitle(self):
312 t = self["titles"].getCurrent()
315 def editTitle(self, title = None, editor = True):
316 t = title or self.getCurrentTitle()
318 self.current_edit_title = t
320 self.session.openWithCallback(self.titleEditDone, TitleCutter.TitleCutter, t)
322 self.session.openWithCallback(self.titleEditDone, TitleCutter.CutlistReader, t)
324 def titleEditDone(self, cutlist):
325 t = self.current_edit_title
326 t.initDVDmenuText(self.project,len(self.project.titles))
328 t.produceFinalCuesheet()
330 self.session.openWithCallback(self.DVDformatCB,MessageBox,text = _("The DVD standard doesn't support H.264 (HDTV) video streams. Do you want to create a Dreambox format data DVD (which will not play in stand-alone DVD players) instead?"), type = MessageBox.TYPE_YESNO)
332 self.updateTitleList()
334 def resetTitles(self):
336 for title in self.project.titles:
338 title.initDVDmenuText(self.project,count)
339 self.updateTitleList()
341 def DVDformatCB(self, answer):
342 t = self.current_edit_title
344 self.project.settings.authormode.setValue("data_ts")
345 self.updateTitleList()