Esempio n. 1
0
 def useHeader(self, gzip):
     self.compression = gzip["compression"].display
     if gzip["mtime"]:
         self.last_modification = gzip["mtime"].value
     self.os = gzip["os"].display
     if gzip["has_filename"].value:
         self.filename = getValue(gzip, "filename")
     if gzip["has_comment"].value:
         self.comment = getValue(gzip, "comment")
     self.compr_size = gzip["file"].size/8
     self.file_size = gzip["size"].value
Esempio n. 2
0
 def useStreamProp(self, stream, index):
     meta = Metadata(self)
     meta.comment = "Start: %s" % stream["stream_start"].value
     if getValue(stream, "mime_type") == "logical-fileinfo":
         for prop in stream.array("file_info/prop"):
             self.useFileInfoProp(prop)
     else:
         meta.bit_rate = stream["avg_bit_rate"].value
         meta.duration = timedelta(milliseconds=stream["duration"].value)
         meta.mime_type = getValue(stream, "mime_type")
     meta.title = getValue(stream, "desc")
     self.addGroup("stream[%u]" % index, meta, "Stream #%u" % (1+index))
Esempio n. 3
0
 def useAviHeader(self, header):
     microsec = header["microsec_per_frame"].value
     if microsec:
         self.frame_rate = 1000000.0 / microsec
         total_frame = getValue(header, "total_frame")
         if total_frame and not self.has("duration"):
             self.duration = timedelta(microseconds=total_frame * microsec)
     self.width = header["width"].value
     self.height = header["height"].value
Esempio n. 4
0
def readVorbisComment(metadata, comment):
    metadata.producer = getValue(comment, "vendor")
    for item in comment.array("metadata"):
        if "=" in item.value:
            key, value = item.value.split("=", 1)
            key = key.upper()
            if key in VORBIS_KEY_TO_ATTR:
                key = VORBIS_KEY_TO_ATTR[key]
                setattr(metadata, key, value)
            elif value:
                metadata.warning("Skip Vorbis comment %s: %s" % (key, value))
Esempio n. 5
0
 def useCommon(self, info):
     self.nb_channel = info["nb_channel"].value
     self.bits_per_sample = info["sample_size"].value
     self.sample_rate = getValue(info, "sample_rate")
     if self.has("sample_rate"):
         rate = self.get("sample_rate")
         if rate:
             sec = float(info["nb_sample"].value) / rate
             self.duration = timedelta(seconds=sec)
     if "codec" in info:
         self.compression = info["codec"].display
Esempio n. 6
0
    def extractPE(self, exe):
        # Read information from headers
        if "pe_header" in exe:
            self.usePE_Header(exe["pe_header"])
        if "pe_opt_header" in exe:
            self.usePE_OptHeader(exe["pe_opt_header"])

        # Use PE resource
        resource = exe.getResource()
        if resource and "version_info/node[0]" in resource:
            for node in resource.array("version_info/node[0]/node"):
                if getValue(node, "name") == "StringFileInfo" \
                and "node[0]" in node:
                    self.readVersionInfo(node["node[0]"])
Esempio n. 7
0
 def extract(self, riff):
     type = riff["type"].value
     if type == "WAVE":
         self.extractWAVE(riff)
         size = getValue(riff, "audio_data/size")
         if size:
             computeAudioComprRate(self, size * 8)
     elif type == "AVI ":
         if "headers" in riff:
             self.extractAVI(riff["headers"])
             self.extractInfo(riff["headers"])
     elif type == "ACON":
         self.extractAnim(riff)
     if "info" in riff:
         self.extractInfo(riff["info"])
Esempio n. 8
0
 def useRoot(self, real):
     self.bits_per_sample = 16   # FIXME: Is that correct?
     if real["version"].value != 3:
         self.sample_rate = real["sample_rate"].value
         self.nb_channel = real["channels"].value
     else:
         self.sample_rate = 8000
         self.nb_channel = 1
     fourcc = getValue(real, "FourCC")
     if fourcc:
         self.compression = fourcc
         try:
             self.bit_rate = self.FOURCC_TO_BITRATE[fourcc]
         except LookupError:
             pass
Esempio n. 9
0
 def extract(self, real):
     version = real["version"].value
     if "metadata" in real:
         self.useMetadata(real["metadata"])
     self.useRoot(real)
     self.format_version = "Real audio version %s" % version
     if version == 3:
         size = getValue(real, "data_size")
     elif "filesize" in real and "headersize" in real:
         size = (real["filesize"].value + 40) - (real["headersize"].value + 16)
     else:
         size = None
     if size:
         size *= 8
         if self.has("bit_rate"):
             sec = float(size) / self.get('bit_rate')
             self.duration = timedelta(seconds=sec)
         computeComprRate(self, size)