def _onMessageCb(self, bus, message): t = message.type if t == gst.MESSAGE_EOS: record.Record.log.debug("Greplay:MESSAGE_EOS") self.emit('coverart-found', None) self.pp.set_state(gst.STATE_NULL) return False elif t == gst.MESSAGE_ERROR: record.Record.log.debug("Greplay:MESSAGE_ERROR") self.emit('coverart-found', None) self.pp.set_state(gst.STATE_NULL) return False elif t == gst.MESSAGE_TAG: tags = message.parse_tag() for tag in tags.keys(): if (str(tag) == "extended-comment"): record.Record.log.debug("Found the tag!") #todo, check for tagname base64imgString = str(tags[tag])[len("coverart="):] pixbuf = utils.getPixbufFromString(base64imgString) self.pp.set_state(gst.STATE_NULL) self.emit('coverart-found', pixbuf) return False return True
def addMedia(self, lat, lon, datastoreOb): rec = Recorded() #default photo rec.type = Constants.TYPE_PHOTO if ((datastoreOb.metadata['mime_type'] == "video/ogg") or (datastoreOb.metadata['mime_type'] == "audio/ogg")): rec.type = Constants.TYPE_VIDEO rec.source = Recorded.SOURCE_DATASTORE rec.datastoreOb = datastoreOb rec.datastoreId = datastoreOb.object_id rec.tags = "" if (datastoreOb.metadata.has_key("tags")): rec.tags = datastoreOb.metadata['tags'] rec.latitude = lat rec.longitude = lon colors = datastoreOb.metadata['icon-color'] colorStroke, colorFill = colors.split(",") rec.colorStroke = Color() rec.colorStroke.init_hex(colorStroke) rec.colorFill = Color() rec.colorFill.init_hex(colorFill) thumbPixbuf = None if (datastoreOb.metadata.has_key("preview")): try: thumb = datastoreOb.metadata['preview'] if thumb[1:4] == 'PNG': pbl = gtk.gdk.PixbufLoader() pbl.write(thumb) pbl.close() thumbPixbuf = pbl.get_pixbuf() else: thumbPixbuf = utils.getPixbufFromString(thumb) except: pass if (thumbPixbuf == None): #try to create the thumbnail yourself... if (rec.type == Constants.TYPE_PHOTO): try: #load in the image, make a thumbnail thumbPixbuf = gtk.gdk.pixbuf_new_from_file_at_size( rec.getFilepath(), 320, 240) except: pass if (thumbPixbuf == None): #i give up. load in a blank image from the activity itself. thumbPath = os.path.join(self.ca.htmlPath, "1.jpg") thumbPixbuf = gtk.gdk.pixbuf_new_from_file(thumbPath) thumbFilepath = os.path.join(Instance.instancePath, "thumb.png") thumbFilepath = utils.getUniqueFilepath(thumbFilepath, 0) thumbPixbuf.save(thumbFilepath, "png", {}) rec.thumbFilename = os.path.basename(thumbFilepath) self.recs.append(rec) return rec
def fillRecdFromNode(recd, el): if el.getAttributeNode('type'): recd.type = int(el.getAttribute('type')) if el.getAttributeNode('title'): recd.title = el.getAttribute('title') if el.getAttributeNode('time'): recd.time = int(el.getAttribute('time')) if el.getAttributeNode('photographer'): recd.recorderName = el.getAttribute('photographer') if el.getAttributeNode('tags'): recd.tags = el.getAttribute('tags') else: recd.tags = "" if el.getAttributeNode('recorderHash'): recd.recorderHash = el.getAttribute('recorderHash') if el.getAttributeNode('colorStroke'): recd.colorStroke = el.getAttribute('colorStroke') if el.getAttributeNode('colorFill'): recd.colorFill = el.getAttribute('colorFill') if el.getAttributeNode('buddy'): recd.buddy = (el.getAttribute('buddy') == "True") if el.getAttributeNode('mediaMd5'): recd.mediaMd5 = el.getAttribute('mediaMd5') if el.getAttributeNode('thumbMd5'): recd.thumbMd5 = el.getAttribute('thumbMd5') if el.getAttributeNode('mediaBytes'): recd.mediaBytes = el.getAttribute('mediaBytes') if el.getAttributeNode('thumbBytes'): recd.thumbBytes = el.getAttribute('thumbBytes') bt = el.getAttributeNode('base64Thumb') if bt: try: thumbPath = os.path.join(Instance.instancePath, "datastoreThumb.jpg") thumbPath = utils.getUniqueFilepath(thumbPath, 0) thumbImg = utils.getPixbufFromString(bt.nodeValue) thumbImg.save(thumbPath, "jpeg", {"quality":"85"} ) recd.thumbFilename = os.path.basename(thumbPath) logger.debug("saved thumbFilename") except: logger.error("unable to getRecdBase64Thumb") ai = el.getAttributeNode('audioImage') if (not ai == None): try: audioImagePath = os.path.join(Instance.instancePath, "audioImage.png") audioImagePath = utils.getUniqueFilepath( audioImagePath, 0 ) audioImage = utils.getPixbufFromString( ai.nodeValue ) audioImage.save(audioImagePath, "png", {} ) recd.audioImageFilename = os.path.basename(audioImagePath) logger.debug("loaded audio image and set audioImageFilename") except: logger.error("unable to load audio image") datastoreNode = el.getAttributeNode('datastoreId') if datastoreNode: recd.datastoreId = datastoreNode.nodeValue return recd
def addMedia(self, lat, lon, datastoreOb): rec = Recorded() #default photo rec.type = Constants.TYPE_PHOTO if((datastoreOb.metadata['mime_type'] == "video/ogg") or (datastoreOb.metadata['mime_type'] == "audio/ogg")): rec.type = Constants.TYPE_VIDEO rec.source = Recorded.SOURCE_DATASTORE rec.datastoreOb = datastoreOb rec.datastoreId = datastoreOb.object_id rec.tags = "" if (datastoreOb.metadata.has_key("tags")): rec.tags = datastoreOb.metadata['tags'] rec.latitude = lat rec.longitude = lon colors = datastoreOb.metadata['icon-color'] colorStroke, colorFill = colors.split(",") rec.colorStroke = Color() rec.colorStroke.init_hex(colorStroke) rec.colorFill = Color() rec.colorFill.init_hex(colorFill) thumbPixbuf = None if (datastoreOb.metadata.has_key("preview")): try: thumb = datastoreOb.metadata['preview'] if thumb[1:4] == 'PNG': pbl = GdkPixbuf.PixbufLoader() pbl.write(thumb) pbl.close() thumbPixbuf = pbl.get_pixbuf() else: thumbPixbuf = utils.getPixbufFromString(thumb) except: pass if (thumbPixbuf == None): #try to create the thumbnail yourself... if (rec.type == Constants.TYPE_PHOTO): try: #load in the image, make a thumbnail thumbPixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(rec.getFilepath(), 320, 240) except: pass if (thumbPixbuf == None): #i give up. load in a blank image from the activity itself. thumbPath = os.path.join(self.ca.htmlPath, "1.jpg") thumbPixbuf = GdkPixbuf.Pixbuf.new_from_file(thumbPath) thumbFilepath = os.path.join(Instance.instancePath, "thumb.png") thumbFilepath = utils.getUniqueFilepath(thumbFilepath, 0) thumbPixbuf.save( thumbFilepath, "png", {} ) rec.thumbFilename = os.path.basename(thumbFilepath) self.recs.append(rec) return rec
def fillRecdFromNode(recd, el): if el.getAttributeNode('type'): recd.type = int(el.getAttribute('type')) if el.getAttributeNode('title'): recd.title = el.getAttribute('title') if el.getAttributeNode('time'): recd.time = int(el.getAttribute('time')) if el.getAttributeNode('photographer'): recd.recorderName = el.getAttribute('photographer') if el.getAttributeNode('tags'): recd.tags = el.getAttribute('tags') else: recd.tags = "" if el.getAttributeNode('recorderHash'): recd.recorderHash = el.getAttribute('recorderHash') if el.getAttributeNode('colorStroke'): recd.colorStroke = el.getAttribute('colorStroke') if el.getAttributeNode('colorFill'): recd.colorFill = el.getAttribute('colorFill') if el.getAttributeNode('buddy'): recd.buddy = (el.getAttribute('buddy') == "True") if el.getAttributeNode('mediaMd5'): recd.mediaMd5 = el.getAttribute('mediaMd5') if el.getAttributeNode('thumbMd5'): recd.thumbMd5 = el.getAttribute('thumbMd5') if el.getAttributeNode('mediaBytes'): recd.mediaBytes = el.getAttribute('mediaBytes') if el.getAttributeNode('thumbBytes'): recd.thumbBytes = el.getAttribute('thumbBytes') bt = el.getAttributeNode('base64Thumb') if bt: thumbPath = os.path.join(Instance.instancePath, "datastoreThumb.jpg") thumbPath = utils.getUniqueFilepath(thumbPath, 0) thumbImg = utils.getPixbufFromString(bt.nodeValue) thumbImg.savev(thumbPath, 'png', [], []) recd.thumbFilename = os.path.basename(thumbPath) ai = el.getAttributeNode('audioImage') if (ai is not None): audioImagePath = os.path.join(Instance.instancePath, "audioImage.png") audioImagePath = utils.getUniqueFilepath(audioImagePath, 0) audioImage = utils.getPixbufFromString(ai.nodeValue) audioImage.savev(audioImagePath, "png", [], []) recd.audioImageFilename = os.path.basename(audioImagePath) vi = el.getAttributeNode('videoImage') if (vi is not None): videoImagePath = os.path.join(Instance.instancePath, "videoImage.png") videoImagePath = utils.getUniqueFilepath(videoImagePath, 0) videoImage = utils.getPixbufFromString(vi.nodeValue) videoImage.savev(videoImagePath, "png", [], []) recd.videoImageFilename = os.path.basename(videoImagePath) datastoreNode = el.getAttributeNode('datastoreId') if datastoreNode: recd.datastoreId = datastoreNode.nodeValue return recd
def fillRecdFromNode( recd, el ): if (el.getAttributeNode(Constants.recdType) != None): typeInt = int(el.getAttribute(Constants.recdType)) recd.type = typeInt if (el.getAttributeNode(Constants.recdTitle) != None): recd.title = el.getAttribute(Constants.recdTitle) if (el.getAttributeNode(Constants.recdTime) != None): timeInt = int(el.getAttribute(Constants.recdTime)) recd.time = timeInt if (el.getAttributeNode(Constants.recdRecorderName) != None): recd.recorderName = el.getAttribute(Constants.recdRecorderName) if (el.getAttributeNode(Constants.recdTags) != None): recd.tags = el.getAttribute(Constants.recdTags) else: recd.tags = "" if (el.getAttributeNode(Constants.recdRecorderHash) != None): recd.recorderHash = el.getAttribute(Constants.recdRecorderHash) if (el.getAttributeNode(Constants.recdColorStroke) != None): try: colorStrokeHex = el.getAttribute(Constants.recdColorStroke) colorStroke = Color() colorStroke.init_hex(colorStrokeHex) recd.colorStroke = colorStroke except: record.Record.log.error("unable to load recd colorStroke") if (el.getAttributeNode(Constants.recdColorFill) != None): try: colorFillHex = el.getAttribute(Constants.recdColorFill) colorFill = Color() colorFill.init_hex( colorFillHex ) recd.colorFill = colorFill except: record.Record.log.error("unable to load recd colorFill") if (el.getAttributeNode(Constants.recdBuddy) != None): recd.buddy = (el.getAttribute(Constants.recdBuddy) == "True") if (el.getAttributeNode(Constants.recdMediaMd5) != None): recd.mediaMd5 = el.getAttribute(Constants.recdMediaMd5) if (el.getAttributeNode(Constants.recdThumbMd5) != None): recd.thumbMd5 = el.getAttribute(Constants.recdThumbMd5) if (el.getAttributeNode(Constants.recdMediaBytes) != None): recd.mediaBytes = el.getAttribute(Constants.recdMediaBytes) if (el.getAttributeNode(Constants.recdThumbBytes) != None): recd.thumbBytes = el.getAttribute(Constants.recdThumbBytes) bt = el.getAttributeNode(Constants.recdBase64Thumb) if (bt != None): try: thumbPath = os.path.join(Instance.instancePath, "datastoreThumb.jpg") thumbPath = utils.getUniqueFilepath( thumbPath, 0 ) thumbImg = utils.getPixbufFromString( bt.nodeValue ) thumbImg.save(thumbPath, "jpeg", {"quality":"85"} ) recd.thumbFilename = os.path.basename(thumbPath) record.Record.log.debug("saved thumbFilename") except: record.Record.log.error("unable to getRecdBase64Thumb") ai = el.getAttributeNode(Constants.recdAudioImage) if (not ai == None): try: audioImagePath = os.path.join(Instance.instancePath, "audioImage.png") audioImagePath = utils.getUniqueFilepath( audioImagePath, 0 ) audioImage = utils.getPixbufFromString( ai.nodeValue ) audioImage.save(audioImagePath, "png", {} ) recd.audioImageFilename = os.path.basename(audioImagePath) record.Record.log.debug("loaded audio image and set audioImageFilename") except: record.Record.log.error("unable to load audio image") datastoreNode = el.getAttributeNode(Constants.recdDatastoreId) if (datastoreNode != None): recd.datastoreId = datastoreNode.nodeValue return recd
def fillRecdFromNode(recd, el): if el.getAttributeNode('type'): recd.type = int(el.getAttribute('type')) if el.getAttributeNode('title'): recd.title = el.getAttribute('title') if el.getAttributeNode('time'): recd.time = int(el.getAttribute('time')) if el.getAttributeNode('photographer'): recd.recorderName = el.getAttribute('photographer') if el.getAttributeNode('tags'): recd.tags = el.getAttribute('tags') else: recd.tags = "" if el.getAttributeNode('recorderHash'): recd.recorderHash = el.getAttribute('recorderHash') if el.getAttributeNode('colorStroke'): recd.colorStroke = el.getAttribute('colorStroke') if el.getAttributeNode('colorFill'): recd.colorFill = el.getAttribute('colorFill') if el.getAttributeNode('buddy'): recd.buddy = (el.getAttribute('buddy') == "True") if el.getAttributeNode('mediaMd5'): recd.mediaMd5 = el.getAttribute('mediaMd5') if el.getAttributeNode('thumbMd5'): recd.thumbMd5 = el.getAttribute('thumbMd5') if el.getAttributeNode('mediaBytes'): recd.mediaBytes = el.getAttribute('mediaBytes') if el.getAttributeNode('thumbBytes'): recd.thumbBytes = el.getAttribute('thumbBytes') bt = el.getAttributeNode('base64Thumb') if bt: try: thumbPath = os.path.join(Instance.instancePath, "datastoreThumb.jpg") thumbPath = utils.getUniqueFilepath(thumbPath, 0) thumbImg = utils.getPixbufFromString(bt.nodeValue) thumbImg.save(thumbPath, "jpeg", {"quality": "85"}) recd.thumbFilename = os.path.basename(thumbPath) logger.debug("saved thumbFilename") except: logger.error("unable to getRecdBase64Thumb") ai = el.getAttributeNode('audioImage') if (not ai == None): try: audioImagePath = os.path.join(Instance.instancePath, "audioImage.png") audioImagePath = utils.getUniqueFilepath(audioImagePath, 0) audioImage = utils.getPixbufFromString(ai.nodeValue) audioImage.save(audioImagePath, "png", {}) recd.audioImageFilename = os.path.basename(audioImagePath) logger.debug("loaded audio image and set audioImageFilename") except: logger.error("unable to load audio image") datastoreNode = el.getAttributeNode('datastoreId') if datastoreNode: recd.datastoreId = datastoreNode.nodeValue return recd