forked from distok/cutthecord
58 lines
2.1 KiB
Python
58 lines
2.1 KiB
Python
#!/bin/env python3
|
|
import os
|
|
import shutil
|
|
|
|
# REPLACE THESE LINES
|
|
extracted_discord_path = "/tmp/cutthecord/discord"
|
|
extracted_mutstd_path = "/var/www/mutant/72x72"
|
|
|
|
# Add your custom emojis here
|
|
# with "mutstd filename": "discord filename".
|
|
# You'll need to write a patch for `assets/data/emojis.json` too.
|
|
custom_emojis = {"101666.png": "emoji_101666.png"}
|
|
|
|
|
|
def clean_emoji_name(name):
|
|
name = name.lower().replace("_", "-")\
|
|
.replace("emoji-", "").replace("-fe0f", "")
|
|
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)
|
|
full_discord_path = os.path.join(discord_emoji_path, emoji)
|
|
|
|
# Copy and overwrite the discord emojis with the mutantstd alternatives
|
|
shutil.copyfile(full_mutstd_path, full_discord_path)
|
|
|
|
print("Replaced {} emoji.".format(emoji))
|
|
replace_counter += 1
|
|
|
|
for custom_emoji in custom_emojis:
|
|
discord_emoji_name = custom_emojis[custom_emoji]
|
|
full_mutstd_path = os.path.join(extracted_mutstd_path, custom_emoji)
|
|
full_discord_path = os.path.join(discord_emoji_path, discord_emoji_name)
|
|
shutil.copyfile(full_mutstd_path, full_discord_path)
|
|
print("Added custom {} emoji.".format(discord_emoji_name))
|
|
replace_counter += 1
|
|
|
|
print("Done, {} emojis replaced.".format(replace_counter))
|