Skip to content

Instantly share code, notes, and snippets.

@Matojeje
Created January 30, 2020 21:21
Show Gist options
  • Save Matojeje/8f49df03dd575d9b6e55dcca2e87f192 to your computer and use it in GitHub Desktop.
Save Matojeje/8f49df03dd575d9b6e55dcca2e87f192 to your computer and use it in GitHub Desktop.
Converts JSON files exported from bodymovin AE plugin to TGS (Telegram sticker)
import argparse
import gzip
parser = argparse.ArgumentParser(description="Packs JSON files exported by Bodymovin into TGS files for Telegram.\nIt's literally just gzip.", epilog="By Mato.")
parser.add_argument("filename", type=str, help="The JSON file to convert")
filename = vars(parser.parse_args())["filename"]
print("Opening file")
# http://xahlee.info/python/gzip.html
input = open(filename, "rb")
file = input.read()
input.close()
output = gzip.GzipFile(filename + ".gz.tgs", "wb")
output.write(file)
output.close()
print("Done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment