From e6d124dd7dfc0c1d08626b7c6f16a103a5e0e408 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Thu, 8 Aug 2019 23:19:04 +0200 Subject: [PATCH] OG metadata tweaks --- utils/opengraph.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/opengraph.py b/utils/opengraph.py index 961243f..0fb3d0b 100644 --- a/utils/opengraph.py +++ b/utils/opengraph.py @@ -54,7 +54,9 @@ def fetch_og_metadata(user_agent, links): continue try: - h = requests.head(l, headers={"User-Agent": user_agent}, timeout=3) + h = requests.head( + l, headers={"User-Agent": user_agent}, timeout=3, allow_redirects=True + ) h.raise_for_status() except requests.HTTPError as http_err: logger.debug( @@ -70,7 +72,9 @@ def fetch_og_metadata(user_agent, links): continue try: - r = requests.get(l, headers={"User-Agent": user_agent}, timeout=5) + r = requests.get( + l, headers={"User-Agent": user_agent}, timeout=5, allow_redirects=True + ) r.raise_for_status() except requests.HTTPError as http_err: logger.debug(