Dynamically get urls from hipchat. No need for repo-based images!
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 1.9 KiB |
BIN
assets/argh.png
Before Width: | Height: | Size: 5.3 KiB |
BIN
assets/atom.png
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.4 KiB |
BIN
assets/aww.png
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 1.3 KiB |
BIN
assets/beer.png
Before Width: | Height: | Size: 1.5 KiB |
|
@ -1,8 +1,11 @@
|
||||||
import json
|
import json, requests
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
from lxml import html
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
ASSETS_URL="https://raw.githubusercontent.com/RealOrangeOne/hipchat-emoticons-for-all/master/assets/"
|
CUSTOM_ASSETS_URL="https://raw.githubusercontent.com/RealOrangeOne/hipchat-emoticons-for-all/master/assets/"
|
||||||
|
|
||||||
|
Emoticon = namedtuple('Emoticon', ['ident', 'url'])
|
||||||
|
|
||||||
def get_icon_name(path):
|
def get_icon_name(path):
|
||||||
return get_filename(path).replace('.png', '').replace('.gif', '')
|
return get_filename(path).replace('.png', '').replace('.gif', '')
|
||||||
|
@ -11,11 +14,23 @@ def get_filename(path):
|
||||||
return path.replace('assets/', '')
|
return path.replace('assets/', '')
|
||||||
|
|
||||||
|
|
||||||
files = glob('assets/*.png') + glob('assets/*.gif')
|
page = requests.get("https://www.hipchat.com/emoticons")
|
||||||
images = []
|
html_tree = html.fromstring(page.text)
|
||||||
|
emoticon_paths = html_tree.xpath("//div[@class='emoticon-block']/img/@src")
|
||||||
|
emoticon_names = html_tree.xpath("//div[@class='emoticon-block']/div/text()")
|
||||||
|
|
||||||
|
|
||||||
|
emoticons = []
|
||||||
|
for i in range(len(emoticon_names)-1):
|
||||||
|
emoticons.append(Emoticon(emoticon_names[i][1:-1], emoticon_paths[i]))
|
||||||
|
|
||||||
|
images = []
|
||||||
|
for emoticon in emoticons:
|
||||||
|
images.append({emoticon.ident: emoticon.url})
|
||||||
|
|
||||||
|
files = glob('assets/*.png') + glob('assets/*.gif')
|
||||||
for filename in files:
|
for filename in files:
|
||||||
images.append({get_icon_name(filename): ASSETS_URL + get_filename(filename)})
|
images.append({get_icon_name(filename): CUSTOM_ASSETS_URL + get_filename(filename)})
|
||||||
|
|
||||||
|
|
||||||
image_decoder = {"images":images}
|
image_decoder = {"images":images}
|
||||||
|
|
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 1,012 B |
BIN
assets/doge.png
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 6.2 KiB |
BIN
assets/drool.png
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.6 KiB |
BIN
assets/herp.png
Before Width: | Height: | Size: 16 KiB |
BIN
assets/hubot.png
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB |
BIN
assets/llama.png
Before Width: | Height: | Size: 3.8 KiB |
BIN
assets/lol.png
Before Width: | Height: | Size: 2.3 KiB |
BIN
assets/metal.png
Before Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 9.1 KiB |
BIN
assets/nice.png
Before Width: | Height: | Size: 2.9 KiB |
BIN
assets/noot.png
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1 KiB |
BIN
assets/ohmy.png
Before Width: | Height: | Size: 2.4 KiB |
BIN
assets/okay.png
Before Width: | Height: | Size: 1 KiB |
BIN
assets/poo.png
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 3 KiB |
BIN
assets/smug.gif
Before Width: | Height: | Size: 972 B |
BIN
assets/stare.png
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.2 KiB |
BIN
assets/troll.png
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2.7 KiB |
BIN
assets/wat.png
Before Width: | Height: | Size: 1.1 KiB |
BIN
assets/wooow.gif
Before Width: | Height: | Size: 17 KiB |
BIN
assets/yey.png
Before Width: | Height: | Size: 2.1 KiB |