コード例 #1
0
ファイル: archive.py プロジェクト: AdriSol/metagoofil
 def extract(self, tar):
     max_nb = maxNbFile(self)
     for index, field in enumerate(tar.array("file")):
         if max_nb is not None and max_nb <= index:
             self.warning("TAR archive contains many files, but only first %s files are processed" % max_nb)
             break
         meta = Metadata(self)
         self.extractFile(field, meta)
         if meta.has("filename"):
             title = _('File "%s"') % meta.getText('filename')
         else:
             title = _("File")
         self.addGroup(field.name, meta, title)
コード例 #2
0
ファイル: archive.py プロジェクト: AdriSol/metagoofil
 def useFile(self, field):
     meta = Metadata(self)
     meta.filename = field["filename"].value
     meta.file_size = field["filesize"].value
     meta.creation_date = field["timestamp"].value
     attr = field["attributes"].value
     if attr != "(none)":
         meta.file_attr = attr
     if meta.has("filename"):
         title = _("File \"%s\"") % meta.getText('filename')
     else:
         title = _("File")
     self.addGroup(field.name, meta, title)
コード例 #3
0
 def useFile(self, field):
     meta = Metadata(self)
     meta.filename = field["filename"].value
     meta.file_size = field["filesize"].value
     meta.creation_date = field["timestamp"].value
     attr = field["attributes"].value
     if attr != "(none)":
         meta.file_attr = attr
     if meta.has("filename"):
         title = _("File \"%s\"") % meta.getText('filename')
     else:
         title = _("File")
     self.addGroup(field.name, meta, title)
コード例 #4
0
    def extract(self, ogg):
        granule_quotient = None
        for index, page in enumerate(ogg.array("page")):
            if "segments" not in page:
                continue
            page = page["segments"]
            if "vorbis_hdr" in page:
                meta = Metadata(self)
                self.vorbisHeader(page["vorbis_hdr"], meta)
                self.addGroup("audio[]", meta, "Audio")
                if not granule_quotient and meta.has("sample_rate"):
                    granule_quotient = meta.get('sample_rate')
            if "theora_hdr" in page:
                meta = Metadata(self)
                self.theoraHeader(page["theora_hdr"], meta)
                self.addGroup("video[]", meta, "Video")
            if "video_hdr" in page:
                meta = Metadata(self)
                self.videoHeader(page["video_hdr"], meta)
                self.addGroup("video[]", meta, "Video")
                if not granule_quotient and meta.has("frame_rate"):
                    granule_quotient = meta.get('frame_rate')
            if "comment" in page:
                readVorbisComment(self, page["comment"])
            if 3 <= index:
                # Only process pages 0..3
                break

        # Compute duration
        if granule_quotient and QUALITY_NORMAL <= self.quality:
            page = ogg.createLastPage()
            if page and "abs_granule_pos" in page:
                try:
                    self.duration = timedelta(
                        seconds=float(page["abs_granule_pos"].value) /
                        granule_quotient)
                except OverflowError:
                    pass
コード例 #5
0
ファイル: audio.py プロジェクト: 1EDTHEMAN1/raspberry_pwn
    def extract(self, ogg):
        granule_quotient = None
        for index, page in enumerate(ogg.array("page")):
            if "segments" not in page:
                continue
            page = page["segments"]
            if "vorbis_hdr" in page:
                meta = Metadata(self)
                self.vorbisHeader(page["vorbis_hdr"], meta)
                self.addGroup("audio[]", meta, "Audio")
                if not granule_quotient and meta.has("sample_rate"):
                    granule_quotient = meta.get('sample_rate')
            if "theora_hdr" in page:
                meta = Metadata(self)
                self.theoraHeader(page["theora_hdr"], meta)
                self.addGroup("video[]", meta, "Video")
            if "video_hdr" in page:
                meta = Metadata(self)
                self.videoHeader(page["video_hdr"], meta)
                self.addGroup("video[]", meta, "Video")
                if not granule_quotient and meta.has("frame_rate"):
                    granule_quotient = meta.get('frame_rate')
            if "comment" in page:
                readVorbisComment(self, page["comment"])
            if 3 <= index:
                # Only process pages 0..3
                break

        # Compute duration
        if granule_quotient and QUALITY_NORMAL <= self.quality:
            page = ogg.createLastPage()
            if page and "abs_granule_pos" in page:
                try:
                    self.duration = timedelta(seconds=float(page["abs_granule_pos"].value) / granule_quotient)
                except OverflowError:
                    pass
コード例 #6
0
 def extract(self, tar):
     max_nb = maxNbFile(self)
     for index, field in enumerate(tar.array("file")):
         if max_nb is not None and max_nb <= index:
             self.warning(
                 "TAR archive contains many files, but only first %s files are processed"
                 % max_nb)
             break
         meta = Metadata(self)
         self.extractFile(field, meta)
         if meta.has("filename"):
             title = _('File "%s"') % meta.getText('filename')
         else:
             title = _("File")
         self.addGroup(field.name, meta, title)