class SWFTestCase(unittest.TestCase): def setUp(self): self.swf = SWF(cws_bytes) def testParseHeader(self): assert self.swf.signature == 'FWS' assert not self.swf.is_compressed() assert self.swf.version == 4 assert self.swf.filesize == 7031 assert self.swf.x_min == 0 assert self.swf.x_max == 240 assert self.swf.y_min == 0 assert self.swf.y_max == 240 assert self.swf.frame_rate == 10.0 assert self.swf.frame_count == 40 def testFilteringImageTags(self): assert isinstance(self.swf.images, SWFImages) assert len(self.swf.images) == 2 def testBuild(self): original = cws_bytes build = self.swf.build() build_header = self.swf.build_header() original_header = original[0:len(build_header)] assert len(build_header) == len(original_header) assert build_header == original_header assert len(build) == len(original) assert build == original
def setUp(self): self.swf = SWF(cws_bytes) self.tag_short = self.swf.tags[0] self.tag_long = self.swf.tags[1] tag_short_start = len(self.swf.build_header()) tag_short_end = tag_short_start + len(self.tag_short) self.tag_short_original_bytes = cws_bytes[ tag_short_start:tag_short_end] tag_long_start = tag_short_end tag_long_end = tag_long_start + len(self.tag_long) self.tag_long_original_bytes = cws_bytes[tag_long_start:tag_long_end]
class SWFTagTestCase(unittest.TestCase): def setUp(self): self.swf = SWF(cws_bytes) self.tag_short = self.swf.tags[0] self.tag_long = self.swf.tags[1] tag_short_start = len(self.swf.build_header()) tag_short_end = tag_short_start + len(self.tag_short) self.tag_short_original_bytes = cws_bytes[tag_short_start:tag_short_end] tag_long_start = tag_short_end tag_long_end = tag_long_start + len(self.tag_long) self.tag_long_original_bytes = cws_bytes[tag_long_start:tag_long_end] def testParseTagShort(self): assert isinstance(self.tag_short, swftag.SetBackgroundColor) assert len(self.tag_short) == 2 + 3 assert self.tag_short.build()[2 + 0] == '\xff' assert self.tag_short.build()[2 + 1] == '\xff' assert self.tag_short.build()[2 + 2] == '\xff' def testParseTagLong(self): assert isinstance(self.tag_long, swftag.DefineBitsJPEG2) assert len(self.tag_long) == 2 + 4 + 2276 assert self.tag_long.build() == self.tag_long_original_bytes def testBuildTagShort(self): assert self.tag_short.build() == self.tag_short_original_bytes def testBuildTagLong(self): build = self.tag_long.build() original = self.tag_long_original_bytes assert len(build) == len(original) assert build == original
class JPEGReplaceTestCase(unittest.TestCase): def setUp(self): self.swf = SWF(open(swf_path).read()) self.jpeg_tag = self.swf.find_tag(swftag.DefineBitsJPEG2) def testUpdateFileSize(self): assert True
def setUp(self): self.swf = SWF(cws_bytes) self.tag_short = self.swf.tags[0] self.tag_long = self.swf.tags[1] tag_short_start = len(self.swf.build_header()) tag_short_end = tag_short_start + len(self.tag_short) self.tag_short_original_bytes = cws_bytes[tag_short_start:tag_short_end] tag_long_start = tag_short_end tag_long_end = tag_long_start + len(self.tag_long) self.tag_long_original_bytes = cws_bytes[tag_long_start:tag_long_end]
def main(): if len(sys.argv) == 2: path = sys.argv[1] io = open(os.path.abspath(path)) base, ext = os.path.splitext(path) if ext == '.swf': from ppswf import SWF swf = SWF(io) print '---- Reading the file header ----' print swf.signature print 'File version ', swf.version print 'File size ', swf.filesize print 'Movie width ', swf.width print 'Movie height ', swf.height print 'Frame rate ', swf.frame_rate print 'Frame count ', swf.frame_count print '---- Reading movie details ----' for tag in swf.tags: print "%s header=%s" % (tag.__class__, BitString(bytes=tag.build_header())) elif ext in ('.jpg', '.jpeg'): import md5 from ppswf.jpeg import JPEG, chunk_names jpeg = JPEG(io) print jpeg for chunk in jpeg.chunks: dump = "%s:" % chunk_names.get(chunk['marker'], 'Unknown') if 'length' in chunk: dump += " length=%d" % chunk['length'] if 'data' in chunk: dump += "md5=%s" % md5.new(chunk['data']).hexdigest() print dump else: print "usage python swf.py <input.swf>"
class SWFTagTestCase(unittest.TestCase): def setUp(self): self.swf = SWF(cws_bytes) self.tag_short = self.swf.tags[0] self.tag_long = self.swf.tags[1] tag_short_start = len(self.swf.build_header()) tag_short_end = tag_short_start + len(self.tag_short) self.tag_short_original_bytes = cws_bytes[ tag_short_start:tag_short_end] tag_long_start = tag_short_end tag_long_end = tag_long_start + len(self.tag_long) self.tag_long_original_bytes = cws_bytes[tag_long_start:tag_long_end] def testParseTagShort(self): assert isinstance(self.tag_short, swftag.SetBackgroundColor) assert len(self.tag_short) == 2 + 3 assert self.tag_short.build()[2 + 0] == '\xff' assert self.tag_short.build()[2 + 1] == '\xff' assert self.tag_short.build()[2 + 2] == '\xff' def testParseTagLong(self): assert isinstance(self.tag_long, swftag.DefineBitsJPEG2) assert len(self.tag_long) == 2 + 4 + 2276 assert self.tag_long.build() == self.tag_long_original_bytes def testBuildTagShort(self): assert self.tag_short.build() == self.tag_short_original_bytes def testBuildTagLong(self): build = self.tag_long.build() original = self.tag_long_original_bytes assert len(build) == len(original) assert build == original
def setUp(self): self.swf = SWF(cws_bytes)
def setUp(self): self.swf = SWF(open(swf_path).read()) self.jpeg_tag = self.swf.find_tag(swftag.DefineBitsJPEG2)