diff options
| author | david <[email protected]> | 2026-10-20 14:47:03 -0300 |
|---|---|---|
| committer | david <[email protected]> | 2026-10-20 14:47:03 -0300 |
| commit | 7958daa50debe471830aecf2c43af5054d682101 (patch) | |
| tree | 3382e570009c9d41234401fed1ee28d94c5ebba9 | |
| parent | 7c1fbbcf5b119fb15397af58f3a9e7fbf499269c (diff) | |
| download | faggot-chan-7958daa50debe471830aecf2c43af5054d682101.tar.gz faggot-chan-7958daa50debe471830aecf2c43af5054d682101.zip | |
steal media now only steals gifs
| -rw-r--r-- | bot.py | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -287,17 +287,18 @@ async def steal_media(url: str, name: str): f.write(f"[{now_str()}] saved media: {name}\n") async def steal_attachments(message): - #steal images and gifs and stuff (always do this regardless of what else fires) + #steal gifs only (always do this regardless of what else fires) media = [ (a.url, f"{a.id}_{Path(a.filename).name}") for a in message.attachments - if a.content_type and a.content_type.startswith(("image/", "video/")) and a.size <= MEDIA_SAVE_MAX_BYTES + if a.content_type and a.content_type.split(";")[0].strip().lower() == "image/gif" and a.size <= MEDIA_SAVE_MAX_BYTES ] for embed in message.embeds: + #tenor/klipy links come as gifv embeds with an mp4 in embed.video direct gif links are plain image embeds for part in (embed.image, embed.video): if part and part.url: - ext = Path(urlparse(part.url).path).suffix # no extension, no preview on discord, not worth keeping - if ext: + ext = Path(urlparse(part.url).path).suffix # no extension no preview on discord not worth keeping + if ext and (embed.type == "gifv" or ext.lower() == ".gif"): media.append((part.url, hashlib.sha1(part.url.encode()).hexdigest()[:16] + ext)) for url, name in media: |
