Skip to content

Instantly share code, notes, and snippets.

@xusheng6
Created March 6, 2024 14:29
Show Gist options
  • Save xusheng6/fb2016567ca95b932967a7d25bf04e44 to your computer and use it in GitHub Desktop.
Save xusheng6/fb2016567ca95b932967a7d25bf04e44 to your computer and use it in GitHub Desktop.
import brotli
import zipfile
import os
archive_path = 'data-63cebb7cb7e3e17ed8a87d7c7a3fd1ab551cfd73.archive'
dump_root = 'dump'
with zipfile.ZipFile(archive_path) as archive:
for info in archive.infolist():
if info.compress_type != 34:
continue
archive.fp.seek(info.header_offset + len(info.FileHeader()))
compressed = archive.fp.read(info.compress_size)
decompressed = brotli.decompress(compressed)
print(info.filename)
dump_path = os.path.join(dump_root, info.filename)
os.makedirs(os.path.dirname(dump_path), exist_ok=True)
with open(dump_path, 'wb') as output:
output.write(decompressed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment