Skip to content

Instantly share code, notes, and snippets.

@MCausc78
Last active January 25, 2025 14:38
Show Gist options
  • Save MCausc78/132a277087e6c17522b626ea5797b8cd to your computer and use it in GitHub Desktop.
Save MCausc78/132a277087e6c17522b626ea5797b8cd to your computer and use it in GitHub Desktop.
from __future__ import annotations
import json
import re
import requests
RE_EMOJIS: re.Pattern[str] = re.compile("= JSON\\.parse\\(('{\"people\":[^']+')\\)")
URL: str = 'https://raw.githubusercontent.com/Discord-Datamining/Discord-Datamining/refs/heads/master/current.js'
headers = {'User-Agent': 'Horror/1.0'} # replace user-agent
print('Downloading main JS script')
response = requests.get(URL, headers=headers)
response.raise_for_status()
print('Extracting emojis')
script = response.text
if match := RE_EMOJIS.search(script):
emojis = json.loads(eval(match.group(1)))
with open('emojis.json', 'w') as fp:
json.dump(emojis, fp, ensure_ascii=True, indent=1, separators=(', ', ': '))
print('Successfully extracted emojis')
else:
print('Failed to extract emojis')

emojis.json contains mapping of section names to array of emoji objects.

Emoji Object

Emoji Structure

Field Type Description
names array[string] The emoji names
surrogates string The emoji string
unicodeVersion float The unicode version the emoji appeared in (example: 6.1)
hasDiversity? boolean Whether the emoji has diversity (default false)
diversityChildren? ^2^ array[emoji object] The emoji diversity
diversity ^1^ array[string] The fitzpatrick applied to the emoji (in HEX format)
hasDiversityParent ^1^ boolean Whether the diversity field is present

^1^ Only available inside diversityChildren.

^2^ Only available outside diversityChildren.

Example Emoji Object

{
 "names": [
  "cat", 
  "cat_face"
 ], 
 "surrogates": "\ud83d\udc31", 
 "unicodeVersion": 6
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment