aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bot.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/bot.py b/bot.py
index a1ecece..edf04c1 100644
--- a/bot.py
+++ b/bot.py
@@ -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: