initial commit
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
venv/
|
||||||
|
out/
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
*.spec
|
||||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
discord.py-self==2.1.0
|
||||||
|
pyinstaller==6.19.0
|
||||||
54
scrapist.py
Normal file
54
scrapist.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import discord
|
||||||
|
import os
|
||||||
|
import argparse
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
prog="Scrapist",
|
||||||
|
description="Simple emoji extractor for Discord."
|
||||||
|
)
|
||||||
|
parser.add_argument('-t', '--discord_token', help="user or bot token that has access to the Discord server you'll be exporting emoji from. can also be provided via the `$DISCORD_TOKEN` env variable")
|
||||||
|
parser.add_argument('-g', '--guild_id', help="ID of the Discord server you wish to extract emoji from", required=True)
|
||||||
|
parser.add_argument('-o', '--out_dir', help="path where emojis will be downloaded to", required=True)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
discord_token = os.getenv("DISCORD_TOKEN")
|
||||||
|
if args.discord_token is not None:
|
||||||
|
discord_token = args.discord_token
|
||||||
|
if discord_token is None:
|
||||||
|
exit("No Discord token provided")
|
||||||
|
|
||||||
|
guild_id = args.guild_id
|
||||||
|
out_dir = args.out_dir
|
||||||
|
|
||||||
|
class Scrapist(discord.Client):
|
||||||
|
async def on_ready(self):
|
||||||
|
print('Logged in as', self.user)
|
||||||
|
|
||||||
|
guild = self.get_guild(int(guild_id))
|
||||||
|
guild_name = guild.name
|
||||||
|
|
||||||
|
# Create output directories if they don't exist
|
||||||
|
Path(f'{out_dir}/{guild_name}/emoji').mkdir(parents=True, exist_ok=True)
|
||||||
|
Path(f'{out_dir}/{guild_name}/animated').mkdir(parents=True, exist_ok=True)
|
||||||
|
Path(f'{out_dir}/{guild_name}/sticker').mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
emotes = await guild.fetch_emojis()
|
||||||
|
for emote in emotes:
|
||||||
|
if emote.animated:
|
||||||
|
filename = f"{emote.name}.webp"
|
||||||
|
await emote.save(f'{out_dir}/{guild_name}/animated/{filename}')
|
||||||
|
else:
|
||||||
|
filename = f"{emote.name}.png"
|
||||||
|
await emote.save(f'{out_dir}/{guild_name}/emoji/{filename}')
|
||||||
|
print(f"downloaded {filename}")
|
||||||
|
stickers = await guild.fetch_stickers()
|
||||||
|
for sticker in stickers:
|
||||||
|
filename = f"{sticker.name}.png"
|
||||||
|
await sticker.save(f'{out_dir}/{guild_name}/sticker/{filename}')
|
||||||
|
print(f"downloaded {sticker.name}")
|
||||||
|
|
||||||
|
await self.close()
|
||||||
|
|
||||||
|
client = Scrapist()
|
||||||
|
client.run(discord_token)
|
||||||
Reference in New Issue
Block a user