2019-01-18 19:16:00 +00:00
|
|
|
#!/bin/env python3
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
|
|
|
|
# REPLACE THESE LINES
|
|
|
|
extracted_discord_path = "/tmp/cutthecord/discord"
|
|
|
|
extracted_mutstd_path = "/var/www/mutant/72x72"
|
|
|
|
|
|
|
|
|
|
|
|
def clean_emoji_name(name):
|
|
|
|
name = name.lower().replace("_", "-")\
|
2019-01-18 19:23:27 +00:00
|
|
|
.replace("emoji-", "").replace("-fe0f", "")
|
2019-01-18 19:16:00 +00:00
|
|
|
return name
|
|
|
|
|
|
|
|
|
|
|
|
discord_emoji_path = os.path.join(extracted_discord_path, "res", "raw")
|
|
|
|
# Get file listings in relevant folders
|
|
|
|
discord_emojis = os.listdir(discord_emoji_path)
|
|
|
|
mutstd_emojis = os.listdir(extracted_mutstd_path)
|
|
|
|
|
|
|
|
# Clean names of mutantstd emojis so thar we can compare them
|
|
|
|
# to clean discord emojis later
|
|
|
|
clean_mutstd_emojis = {clean_emoji_name(emoji): emoji for
|
|
|
|
emoji in mutstd_emojis}
|
|
|
|
|
|
|
|
replace_counter = 0
|
|
|
|
|
|
|
|
# Go through each discord emoji, and clean their names
|
|
|
|
for emoji in discord_emojis:
|
|
|
|
clean_discord_emoji = clean_emoji_name(emoji)
|
|
|
|
|
|
|
|
# Check if said clean name of emoji is in clean mutstd list
|
|
|
|
if clean_discord_emoji in clean_mutstd_emojis:
|
|
|
|
# Get full unclean filename of mutantstd emoji, generate relevant paths
|
|
|
|
full_mutstd_name = clean_mutstd_emojis[clean_discord_emoji]
|
|
|
|
full_mutstd_path = os.path.join(extracted_mutstd_path, full_mutstd_name)
|
2019-01-18 19:37:04 +00:00
|
|
|
full_discord_path = os.path.join(discord_emoji_path, emoji)
|
2019-01-18 19:16:00 +00:00
|
|
|
|
|
|
|
# Copy and overwrite the discord emojis with the mutantstd alternatives
|
|
|
|
shutil.copyfile(full_mutstd_path, full_discord_path)
|
|
|
|
|
2019-01-18 19:31:45 +00:00
|
|
|
print("Replaced {} emoji.".format(emoji))
|
2019-01-18 19:16:00 +00:00
|
|
|
replace_counter += 1
|
|
|
|
|
|
|
|
print("Done, {} emojis replaced.".format(replace_counter))
|