diff --git a/templates/utils.html b/templates/utils.html index 8b15a1a..3659366 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -77,6 +77,7 @@ {% if meta and meta.og_metadata and obj | has_type('Note') %} {% for og in meta.og_metadata %} +{% if og.url %}
@@ -87,6 +88,7 @@ {{ og.site_name }}
+{% endif %} {% endfor %} {% endif %} diff --git a/utils/opengraph.py b/utils/opengraph.py index 87ffa5e..30c752b 100644 --- a/utils/opengraph.py +++ b/utils/opengraph.py @@ -42,4 +42,11 @@ def fetch_og_metadata(user_agent, links): r = requests.get(l, headers={"User-Agent": user_agent}, timeout=15) r.raise_for_status() htmls.append(r.text) - return [dict(opengraph.OpenGraph(html=html)) for html in htmls] + + res = [] + for html in htmls: + data = dict(opengraph.OpenGraph(html=html)) + if data.get("url"): + res.append(data) + + return res