如何通过API获得twich表情?

时间:2016-10-25 06:50:36

标签: python json api

我需要下载twich.tv表情。我找到了Phyton脚本,但那不起作用。写剧本的人说Twich激活了云计算等等page with API doc

import urllib
import os
import json

if not os.path.exists('./emotes'):
    os.makedirs('./emotes')
print('Saving emotes to folder: ' + os.path.abspath('./emotes') + '...')
print('Grabbing emote list...')
emotes = json.load(urllib.urlopen('https://twitchemotes.com/api_cache/v2/global.json'))
for code, emote in emotes['emotes'].items():
    print('Downloading: ' + code + '...')
    urllib.urlretrieve('http:' + emotes['template']['large'].replace('{image_id}', str(emote['image_id'])),
                       './emotes/' + code + '.png')
print('Done! Kappa')

1 个答案:

答案 0 :(得分:0)

是的,我认为API不再适用了。似乎你可以使用https://api.twitch.tv/kraken/chat/emoticons/

import urllib
import os
import json

if not os.path.exists('./emotes'):
    os.makedirs('./emotes')
print('Saving emotes to folder: ' + os.path.abspath('./emotes') + '...')
print('Grabbing emote list...')
emotes = json.load(urllib.urlopen('https://api.twitch.tv/kraken/chat/emoticons/'))
for emote in emotes['emoticons']:
    code = emote['regex']
    print('Downloading: ' + code + '...')
    urllib.urlretrieve(emote['images'][0]['url'], './emotes/' + code + '.png')
print('Done! Kappa')