Created
August 21, 2017 20:12
-
-
Save vaer-k/b1e452e2c962b5c3079468b887a67e75 to your computer and use it in GitHub Desktop.
Download twitch emotes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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