Ejemplo n.º 1
0
	def run(self, callback):
		self.callback = callback
		try:
			self.conduct()
			Task.processFinished(self, 0)
		except Exception:
			Task.processFinished(self, 1)
Ejemplo n.º 2
0
 def run(self, callback):
     self.callback = callback
     try:
         self.conduct()
         Task.processFinished(self, 0)
     except Exception:
         Task.processFinished(self, 1)
Ejemplo n.º 3
0
	def conduct(self):
		from Tools.XMLTools import stringToXML
		dl = ['<?xml version="1.0" encoding="utf-8" ?>']
		dl.append('<disclib xmlns="urn:BDA:bdmv;disclib" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:BDA:bdmv;disclib disclib.xsd">')
		dl.append('\t<di:discinfo xmlns:di="urn:BDA:bdmv;discinfo">')
		dl.append(strftime("\t<di:date>%Y-%m-%d</di:date>"))
		dl.append('\t\t<di:creator>Dream Multimedia Enigma2</di:creator>')
		dl.append('\t\t<di:title>')
		dl.append('\t\t\t<di:name>'+stringToXML(self.project.settings.name.value)+'</di:name>')
		dl.append('\t\t\t<di:numSets>1</di:numSets>')
		dl.append('\t\t\t<di:setNumber>1</di:setNumber>')
		dl.append('\t\t</di:title>')
		dl.append('\t\t<di:description>')
		dl.append('\t\t\t<di:tableOfContents>')
		for title_no, title in enumerate(self.job.titles):
			dl.append('\t\t\t\t<di:titleName titleNumber="%d">%s</di:titleName>' % (title_no, stringToXML(title.properties.menutitle.value)))
		dl.append('\t\t\t</di:tableOfContents>')
		for title_no in range(len(self.job.titles)):
			dl.append('\t\t\t<di:thumbnail href="thumb_%05d.png" />' % title_no)
		dl.append('\t\t</di:description>')
		dl.append('\t\t<di:language>'+stringToXML(self.languageCode)+'</di:language>')
		dl.append('\t</di:discinfo>')
		dl.append('</disclib>')

		filename = self.job.workspace+'BDMV/META/DL/bdmt_%s.xml' % self.languageCode
		try:
			file = open(filename, "w")
			for line in dl:
				file.write(line+'\n')
			file.close()
		except:
			Task.processFinished(self, 1)
		Task.processFinished(self, 0)
		self.project.finished_burning = True
Ejemplo n.º 4
0
 def http_finished(self, string=""):
     print "[http_finished]" + str(string)
     Task.processFinished(self, 0)
     try:
         filetitle = os_path.basename(self.local)
     except:
         filetile = ''
Ejemplo n.º 5
0
	def run(self, callback):
		self.callback = callback
		failed_preconditions = self.checkPreconditions(True) + self.checkPreconditions(False)
		if len(failed_preconditions):
			callback(self, failed_preconditions)
			return
		Task.processFinished(self, 0)
	def downloadFailed(self, failure_instance=None, error_message=''):
		print '[YouTube] Video download failed'
		if error_message == '' and failure_instance is not None:
			error_message = failure_instance.getErrorMessage()
			print '[YouTube]', str(error_message)
		Task.processFinished(self, 1)
		self.downloadStop()
Ejemplo n.º 7
0
	def conduct(self):
		from Tools.XMLTools import stringToXML
		dl = ['<?xml version="1.0" encoding="utf-8" ?>']
		dl.append('<disclib xmlns="urn:BDA:bdmv;disclib" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:BDA:bdmv;disclib disclib.xsd">')
		dl.append('\t<di:discinfo xmlns:di="urn:BDA:bdmv;discinfo">')
		dl.append(strftime("\t<di:date>%Y-%m-%d</di:date>"))
		dl.append('\t\t<di:creator>Dream Multimedia Enigma2</di:creator>')
		dl.append('\t\t<di:title>')
		dl.append('\t\t\t<di:name>'+stringToXML(self.project.settings.name.value)+'</di:name>')
		dl.append('\t\t\t<di:numSets>1</di:numSets>')
		dl.append('\t\t\t<di:setNumber>1</di:setNumber>')
		dl.append('\t\t</di:title>')
		dl.append('\t\t<di:description>')
		dl.append('\t\t\t<di:tableOfContents>')
		for title_no, title in enumerate(self.job.titles):
			dl.append('\t\t\t\t<di:titleName titleNumber="%d">%s</di:titleName>' % (title_no, stringToXML(title.properties.menutitle.value)))
		dl.append('\t\t\t</di:tableOfContents>')
		for title_no in range(len(self.job.titles)):
			dl.append('\t\t\t<di:thumbnail href="thumb_%05d.png" />' % title_no)
		dl.append('\t\t</di:description>')
		dl.append('\t\t<di:language>'+stringToXML(self.languageCode)+'</di:language>')
		dl.append('\t</di:discinfo>')
		dl.append('</disclib>')

		filename = self.job.workspace+'BDMV/META/DL/bdmt_%s.xml' % self.languageCode
		try:	
			file = open(filename, "w")
			for line in dl:
				file.write(line+'\n')
			file.close()
		except:
			Task.processFinished(self, 1)
		Task.processFinished(self, 0)
		self.project.finished_burning = True
Ejemplo n.º 8
0
 def http_failed(self, failure_instance=None, error_message=""):
     if error_message == "" and failure_instance is not None:
         error_message = failure_instance.getErrorMessage()
         print "[http_failed] " + error_message
         Task.processFinished(self, 1)
         try:
             filetitle = os_path.basename(self.local)
         except:
             filetile = ''
	def downloadFinished(self, result):
		Task.processFinished(self, 0)
		self.downloadStop()
		if '_suburi.mp4' in self.outputfile and \
			config.plugins.YouTube.mergeFiles.value and \
			os.path.exists('%s.m4a' % self.outputfile[:-11]) and \
			not os.path.exists('%s.mkv' % self.outputfile[:-11]):
			from Components.Console import Console
			Console().ePopen('ffmpeg -i "%s" -i "%s.m4a" -c copy "%s.mkv"' % (self.outputfile,
				self.outputfile[:-11], self.outputfile[:-11]), self.mergeCompleted)
Ejemplo n.º 10
0
 def conduct(self):
     for directory in [
             'BDMV', 'BDMV/AUXDATA', 'BDMV/BACKUP', 'BDMV/BACKUP/BDJO',
             'BDMV/BACKUP/CLIPINF', 'BDMV/BACKUP/JAR',
             'BDMV/BACKUP/PLAYLIST', 'BDMV/BDJO', 'BDMV/CLIPINF',
             'BDMV/JAR', 'BDMV/META', 'BDMV/META/DL', 'BDMV/PLAYLIST',
             'BDMV/STREAM'
     ]:
         if not createDir(self.job.workspace + directory):
             Task.processFinished(self, 1)
	def downloadFinished(self, result):
		Task.processFinished(self, 0)
		self.downloadStop()
		if '_suburi.mp4' in self.outputfile and \
			config.plugins.YouTube.mergeFiles.value and \
			os.path.exists('%s.m4a' % self.outputfile[:-11]) and \
			not os.path.exists('%s.mkv' % self.outputfile[:-11]):
			from Components.Console import Console
			Console().ePopen('ffmpeg -i "%s" -i "%s.m4a" -c copy "%s.mkv"' % (self.outputfile,
				self.outputfile[:-11], self.outputfile[:-11]), self.mergeCompleted)
Ejemplo n.º 12
0
 def http_failed(self, failure_instance=None, error_message=''):
     if error_message == '' and failure_instance is not None:
         error_message = failure_instance.getErrorMessage()
         print '[http_failed] ' + error_message
         Task.processFinished(self, 1)
         try:
             filetitle = os_path.basename(self.local)
         except:
             filetile = ''
     if '_update.zip' in self.local:
         return
Ejemplo n.º 13
0
    def processOutputLine(self, line):
        if line.startswith("entrypoint:"):
            values = line[:-1].split(' ')
            (spn, pts) = (int(values[1]), int(values[2]))
            if spn > 0 and pts > 0:
                self.title.entrypoints.append((spn, pts))
                print "[bdremux] added new entrypoint", self.title.entrypoints[
                    -1]
            self.progress = spn
        elif line.startswith("linked:"):
            words = line[:-1].split(' ')
            pid = int(words[5].split('_')[1])
            self.title.addStream(pid)
            print "[bdremux] added stream with pid", pid
        elif line.find("has CAPS:") > 0:
            words = line[:-1].split(' ')
            pid = int(words[0].split('_')[1])
            stype = words[3][:-1]
            if words[3].find("mpeg") > 0:
                stype = words[3] + ' ' + words[4][:-1]

            stream = self.title.getStreamByPID(pid)
            if stream == None:
                print "[bdremux] invalid stream!"
                return

            sdict = {}
            if stype.startswith("audio"):
                sdict = AUDIO_TYPES
            elif stype.startswith("video"):
                sdict = VIDEO_TYPES
            if stype in sdict:
                stream.streamType = sdict[stype]

            for field in words[4:]:
                key, val = field.split('=')
                m = re.search('\(int\)(\d*).*', val)
                if m and m.groups() > 1:
                    v = int(m.group(1))
                    if key == "rate":
                        stream.setAudioRate(v)
                    elif key == "channels":
                        stream.setAudioPresentation(v)
            print "[bdremux] discovered caps for pid %i (%s)" % (pid, stype)
        elif line.startswith("ERROR:"):
            self.error_text = line[7:-1]
            print "[bdremux] error:", self.error_text
            Task.processFinished(self, 1)
        else:
            print "[bdremux]", line[:-1]
Ejemplo n.º 14
0
 def http_failed(self, failure_instance = None, error_message = ''):
     if error_message == '' and failure_instance is not None:
         error_message = failure_instance.getErrorMessage()
         print '[http_failed] ' + error_message
         Task.processFinished(self, 1)
         try:
             filetitle = os_path.basename(self.local)
         except:
             filetile = ''
     if  '_update.zip'  in self.local:
       return 
     try:Notifications.AddNotification(MessageBox, _('Failed to download '+filetitle), MessageBox.TYPE_INFO, timeout=10)
     except:pass
     return
Ejemplo n.º 15
0
	def conduct(self):
		try:
			from ImageFont import truetype
			from Image import open as Image_open
			s = self.job.project.menutemplate.settings
			(width, height) = s.dimensions.value
			self.Menus.im_bg_orig = Image_open(s.menubg.value)
			if self.Menus.im_bg_orig.size != (width, height):
				self.Menus.im_bg_orig = self.Menus.im_bg_orig.resize((width, height))
			self.Menus.fontsizes = [s.fontsize_headline.value, s.fontsize_title.value, s.fontsize_subtitle.value]
			self.Menus.fonts = [(truetype(s.fontface_headline.value, self.Menus.fontsizes[0])), (truetype(s.fontface_title.value, self.Menus.fontsizes[1])),(truetype(s.fontface_subtitle.value, self.Menus.fontsizes[2]))]
			Task.processFinished(self, 0)
		except:
			Task.processFinished(self, 1)
Ejemplo n.º 16
0
	def processOutputLine(self, line):
		if line.startswith("entrypoint:"):
			values = line[:-1].split(' ')
			(spn, pts) = (int(values[1]), int(values[2]))
			if spn > 0 and pts > 0:
				self.title.entrypoints.append((spn, pts))
				print "[bdremux] added new entrypoint", self.title.entrypoints[-1]
			self.progress = spn
		elif line.startswith("linked:"):
			words = line[:-1].split(' ')
			pid = int(words[5].split('_')[1])
			self.title.addStream(pid)
			print "[bdremux] added stream with pid", pid
		elif line.find("has CAPS:") > 0:
			words = line[:-1].split(' ')
			pid = int(words[0].split('_')[1])
			stype = words[3][:-1]
			if words[3].find("mpeg") > 0:
				stype = words[3]+' '+words[4][:-1]

			stream = self.title.getStreamByPID(pid)
			if stream == None:
				print "[bdremux] invalid stream!"
				return

			sdict = {}
			if stype.startswith("audio"):
				sdict = AUDIO_TYPES
			elif stype.startswith("video"):
				sdict = VIDEO_TYPES
			if stype in sdict:
				stream.streamType = sdict[stype]

			for field in words[4:]:
				key, val = field.split('=')
				m = re.search('\(int\)(\d*).*', val)
				if m and m.groups() > 1:
					v = int(m.group(1))
					if key == "rate":
						stream.setAudioRate(v)
					elif key == "channels":
						stream.setAudioPresentation(v)
			print "[bdremux] discovered caps for pid %i (%s)" % (pid, stype)
		elif line.startswith("ERROR:"):
			self.error_text = line[7:-1]
			print "[bdremux] error:", self.error_text
			Task.processFinished(self, 1)
		else:
			print "[bdremux]", line[:-1]
Ejemplo n.º 17
0
    def http_finished(self, string=''):
        print '[http_finished]' + str(string), self.local
        Task.processFinished(self, 0)
        try:
            filetitle = os_path.basename(self.local)
        except:
            filetile = ''
        if not '_update.zip' in self.local:

            return
        if '_plugin.' in self.local or '_update.zip' in self.local:

            return
        if self.local.endswith(
                ".zip"
        ) and not "-et" in self.local and "-vu" not in self.local:

            return
Ejemplo n.º 18
0
 def http_finished(self, string = ''):
     print '[http_finished]' + str(string), self.local
     Task.processFinished(self, 0)
     
     
     try:
         filetitle = os_path.basename(self.local)
     except:
         filetile = ''
     if not '_update.zip'  in self.local:
        
        try:Notifications.AddNotification(MessageBox, _(filetitle+' successfully transfered to your HDD!'), MessageBox.TYPE_INFO, timeout=10)
        except:pass
     if '_plugin.' in self.local or '_update.zip' in self.local:
         self.deflatezip(self.local)
         return
    
     if self.local.endswith(".zip") and not "-et" in self.local and "-vu" not in self.local:
        self.deflatezip(self.local)
Ejemplo n.º 19
0
	def download_finished(self, string=""):
		if self.aborted:
			self.finish(aborted = True)
		else:
			Task.processFinished(self, 0)
Ejemplo n.º 20
0
	def download_failed(self, failure_instance=None, error_message=""):
		self.error_message = error_message
		if error_message == "" and failure_instance is not None:
			self.error_message = failure_instance.getErrorMessage()
		Task.processFinished(self, 1)
Ejemplo n.º 21
0
 def run(self, callback):
     self.callback = callback
     self.conduct()
     Task.processFinished(self, 0)
Ejemplo n.º 22
0
 def http_finished(self, string = ''):
     Task.processFinished(self, 0)
Ejemplo n.º 23
0
 def http_finished(self, string=""):
     print "[DownloadTask].http_finished " + str(string)
     Task.processFinished(self, 0)
Ejemplo n.º 24
0
 def http_failed(self, failure_instance=None, error_message=""):
     print "[DownloadTask].http_failed"
     if error_message == "" and failure_instance is not None:
         error_message = failure_instance.getErrorMessage()
         print "[DownloadTask].http_failed " + error_message
         Task.processFinished(self, 1)
Ejemplo n.º 25
0
 def http_failed(self, failure_instance = None, error_message = ''):
     if error_message == '' and failure_instance is not None:
         error_message = failure_instance.getErrorMessage()
         Task.processFinished(self, 1)
	def downloadFinished(self, result):
		Task.processFinished(self, 0)
		self.downloadStop()
Ejemplo n.º 27
0
	def http_failed(self, failure_instance=None, error_message=""):
		print "[DownloadTask].http_failed"
		if error_message == "" and failure_instance is not None:
			error_message = failure_instance.getErrorMessage()
			print "[DownloadTask].http_failed " + error_message
			Task.processFinished(self, 1)
Ejemplo n.º 28
0
 def download_failed(self, failure_instance=None, error_message=""):
     self.error_message = error_message
     if error_message == "" and failure_instance is not None:
         self.error_message = failure_instance.getErrorMessage()
     Task.processFinished(self, 1)
Ejemplo n.º 29
0
	def http_finished(self, string=""):
		print "[DownloadTask].http_finished " + str(string)
		Task.processFinished(self, 0)
Ejemplo n.º 30
0
 def http_failed(self, failure_instance=None, error_message=''):
     if error_message == '' and failure_instance is not None:
         error_message = failure_instance.getErrorMessage()
         Task.processFinished(self, 1)
Ejemplo n.º 31
0
 def download_finished(self, string=""):
     if self.aborted:
         self.finish(aborted=True)
     else:
         Task.processFinished(self, 0)
Ejemplo n.º 32
0
	def conduct(self):
		for directory in ['BDMV','BDMV/AUXDATA','BDMV/BACKUP','BDMV/BACKUP/BDJO','BDMV/BACKUP/CLIPINF','BDMV/BACKUP/JAR','BDMV/BACKUP/PLAYLIST','BDMV/BDJO','BDMV/CLIPINF','BDMV/JAR','BDMV/META','BDMV/META/DL','BDMV/PLAYLIST','BDMV/STREAM']:
			if not createDir(self.job.workspace+directory):
				Task.processFinished(self, 1)
Ejemplo n.º 33
0
	def closedCB(self, answer):
		if answer:
			Task.processFinished(self, 0)
		else:
			Task.processFinished(self, 1)
Ejemplo n.º 34
0
 def http_finished(self, string=''):
     Task.processFinished(self, 0)
Ejemplo n.º 35
0
	def run(self, callback):
		self.callback = callback
		#try:
		import ImageDraw, Image

		s = self.job.project.menutemplate.settings
		s_top = s.margin_top.value
		s_bottom = s.margin_bottom.value
		s_left = s.margin_left.value
		s_right = s.margin_right.value
		s_rows = s.space_rows.value
		s_cols = s.space_cols.value
		nr_cols = s.cols.value
		nr_rows = s.rows.value
		thumb_size = s.thumb_size.value
		if thumb_size[0]:
			from Image import open as Image_open
		(s_width, s_height) = s.dimensions.value
		fonts = self.Menus.fonts
		im_bg = self.Menus.im_bg_orig.copy()
		im_high = Image.new("P", (s_width, s_height), 0)
		im_high.putpalette(self.Menus.spu_palette)
		draw_bg = ImageDraw.Draw(im_bg)
		draw_high = ImageDraw.Draw(im_high)
		if self.menu_count == 1:
			headlineText = self.job.project.settings.name.value.decode("utf-8")
			headlinePos = self.getPosition(s.offset_headline.value, 0, 0, s_width, s_top, draw_bg.textsize(headlineText, font=fonts[0]))
			draw_bg.text(headlinePos, headlineText, fill=self.Menus.color_headline, font=fonts[0])
		spuxml = """<?xml version="1.0" encoding="utf-8"?>
	<subpictures>
	<stream>
	<spu
	highlight="%s"
	transparent="%02x%02x%02x"
	start="00:00:00.00"
	force="yes" >""" % (self.highlightpngfilename, self.Menus.spu_palette[0], self.Menus.spu_palette[1], self.Menus.spu_palette[2])
		#rowheight = (self.Menus.fontsizes[1]+self.Menus.fontsizes[2]+thumb_size[1]+s_rows)
		menu_start_title = (self.menu_count-1)*self.job.titles_per_menu + 1
		menu_end_title = self.menu_count *self.job.titles_per_menu + 1
		nr_titles = len(self.job.project.titles)
		if menu_end_title > nr_titles:
			menu_end_title = nr_titles+1
		col = 1
		row = 1
		for title_no in range( menu_start_title , menu_end_title ):
			title = self.job.project.titles[title_no-1]
			col_width  = ( s_width  - s_left - s_right  ) / nr_cols
			row_height = ( s_height - s_top  - s_bottom ) / nr_rows
			left =   s_left + ( (col-1) * col_width ) + s_cols/2
			right =    left + col_width - s_cols
			top =     s_top + ( (row-1) * row_height) + s_rows/2
			bottom =    top + row_height - s_rows
			width = right - left
			height = bottom - top

			if bottom > s_height:
				bottom = s_height
			#draw_bg.rectangle((left, top, right, bottom), outline=(255,0,0))
			im_cell_bg = Image.new("RGBA", (width, height),(0,0,0,0))
			draw_cell_bg = ImageDraw.Draw(im_cell_bg)
			im_cell_high = Image.new("P", (width, height), 0)
			im_cell_high.putpalette(self.Menus.spu_palette)
			draw_cell_high = ImageDraw.Draw(im_cell_high)

			if thumb_size[0]:
				thumbPos = self.getPosition(s.offset_thumb.value, 0, 0, width, height, thumb_size)
				box = (thumbPos[0], thumbPos[1], thumbPos[0]+thumb_size[0], thumbPos[1]+thumb_size[1])
				try:
					thumbIm = Image_open(title.inputfile.rsplit('.',1)[0] + ".png")
					im_cell_bg.paste(thumbIm,thumbPos)
				except:
					draw_cell_bg.rectangle(box, fill=(64,127,127,127))
				border = s.thumb_border.value
				if border:
					draw_cell_high.rectangle(box, fill=1)
					draw_cell_high.rectangle((box[0]+border, box[1]+border, box[2]-border, box[3]-border), fill=0)

			titleText = title.formatDVDmenuText(s.titleformat.value, title_no).decode("utf-8")
			titlePos = self.getPosition(s.offset_title.value, 0, 0, width, height, draw_bg.textsize(titleText, font=fonts[1]))

			draw_cell_bg.text(titlePos, titleText, fill=self.Menus.color_button, font=fonts[1])
			draw_cell_high.text(titlePos, titleText, fill=1, font=self.Menus.fonts[1])

			subtitleText = title.formatDVDmenuText(s.subtitleformat.value, title_no).decode("utf-8")
			subtitlePos = self.getPosition(s.offset_subtitle.value, 0, 0, width, height, draw_cell_bg.textsize(subtitleText, font=fonts[2]))
			draw_cell_bg.text(subtitlePos, subtitleText, fill=self.Menus.color_button, font=fonts[2])

			del draw_cell_bg
			del draw_cell_high
			im_bg.paste(im_cell_bg,(left, top, right, bottom), mask=im_cell_bg)
			im_high.paste(im_cell_high,(left, top, right, bottom))

			spuxml += """
	<button name="button%s" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (str(title_no).zfill(2),left,right,top,bottom )
			if col < nr_cols:
				col += 1
			else:
				col = 1
				row += 1

		top = s_height - s_bottom - s_rows/2
		if self.menu_count < self.job.nr_menus:
			next_page_text = s.next_page_text.value.decode("utf-8")
			textsize = draw_bg.textsize(next_page_text, font=fonts[1])
			pos = ( s_width-textsize[0]-s_right, top )
			draw_bg.text(pos, next_page_text, fill=self.Menus.color_button, font=fonts[1])
			draw_high.text(pos, next_page_text, fill=1, font=fonts[1])
			spuxml += """
	<button name="button_next" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (pos[0],pos[0]+textsize[0],pos[1],pos[1]+textsize[1])
		if self.menu_count > 1:
			prev_page_text = s.prev_page_text.value.decode("utf-8")
			textsize = draw_bg.textsize(prev_page_text, font=fonts[1])
			pos = ( (s_left+s_cols/2), top )
			draw_bg.text(pos, prev_page_text, fill=self.Menus.color_button, font=fonts[1])
			draw_high.text(pos, prev_page_text, fill=1, font=fonts[1])
			spuxml += """
	<button name="button_prev" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (pos[0],pos[0]+textsize[0],pos[1],pos[1]+textsize[1])
		del draw_bg
		del draw_high
		fd=open(self.menubgpngfilename,"w")
		im_bg.save(fd,"PNG")
		fd.close()
		fd=open(self.highlightpngfilename,"w")
		im_high.save(fd,"PNG")
		fd.close()
		spuxml += """
	</spu>
	</stream>
	</subpictures>"""

		f = open(self.spuxmlfilename, "w")
		f.write(spuxml)
		f.close()
		Task.processFinished(self, 0)
Ejemplo n.º 36
0
	def run(self, callback):
		self.callback = callback
		self.conduct()
		Task.processFinished(self, 0)