From 1061b1302901f86b27276924788516100b4a6fbb Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Thu, 8 Aug 2019 23:48:30 +0200 Subject: [PATCH] More OG meta tweaks --- utils/opengraph.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils/opengraph.py b/utils/opengraph.py index 0fb3d0b..e869594 100644 --- a/utils/opengraph.py +++ b/utils/opengraph.py @@ -1,4 +1,5 @@ import logging +import mimetypes from typing import Any from typing import Dict from typing import Set @@ -41,6 +42,12 @@ def links_from_note(note: Dict[str, Any]) -> Set[str]: def fetch_og_metadata(user_agent, links): res = [] for l in links: + # Try to skip media early + mimetype, _ = mimetypes.guess_type(l) + if mimetype and mimetype.split("/")[0] in ["image", "video", "audio"]: + logger.info(f"skipping media link {l}") + continue + check_url(l) # Remove any AP objects