Skip to content

Instantly share code, notes, and snippets.

@alex
Created November 12, 2017 04:33
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alex/17653ac6813ce12c9452321600731997 to your computer and use it in GitHub Desktop.
Save alex/17653ac6813ce12c9452321600731997 to your computer and use it in GitHub Desktop.
from __future__ import print_function
import os
import sys
import zipfile
import requests
def main(argv):
if len(argv) != 3:
print("Usage: python download-emoji.py <token> <target-file>", file=sys.stderr)
os.exit(1)
[_, token, path] = argv
session = requests.session()
metadata = session.get(
"https://slack.com/api/emoji.list?token={}".format(token)
).json()
assert metadata["ok"]
print("Downloading {} emoji...".format(len(metadata["emoji"])))
with zipfile.ZipFile(path, "w") as zf:
for name, url in metadata["emoji"].items():
if url.startswith("alias:"):
continue
print("Downloading :{}:...".format(name))
data = session.get(url).content
zf.writestr(name + ".png", data)
print("Your emoji are ready! " + path)
if __name__ == "__main__":
main(sys.argv)
@brodygov
Copy link

brodygov commented Oct 2, 2018

🙇‍♂️ Should be sys.exit(1) instead of os.exit(1) on L13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment