Skip to content

Instantly share code, notes, and snippets.

@vaer-k
Created August 21, 2017 20:12
Show Gist options
  • Save vaer-k/b1e452e2c962b5c3079468b887a67e75 to your computer and use it in GitHub Desktop.
Save vaer-k/b1e452e2c962b5c3079468b887a67e75 to your computer and use it in GitHub Desktop.
Download twitch emotes
import os
import json
from tqdm import tqdm
from urllib import request
PATH = '~/Downloads/twitch_emotes'
EMOTE_URI = 'https://twitchemotes.com/api_cache/v2/global.json'
path = os.path.expanduser(PATH)
if not os.path.exists(path):
os.makedirs(path)
print('Saving emotes to folder: {}...'.format(path))
emotes = json.loads(request.urlopen(EMOTE_URI).read().decode('utf-8'))
for code, emote in tqdm(emotes['emotes'].items()):
url = emotes['template']['large'].replace('{image_id}', str(emote['image_id']))
filename = '{0}/{1}.png'.format(path, code)
request.urlretrieve(url, filename)
print('Done! Kappa')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment