From e18482e9aed553cfb42410ca1e5292584bceb8ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 5 Jan 2023 14:55:55 +0100 Subject: [PATCH] [twitter] improve 'http' -> 'https' replacement --- gallery_dl/extractor/twitter.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gallery_dl/extractor/twitter.py b/gallery_dl/extractor/twitter.py index a2e414e4..7dbc63dd 100644 --- a/gallery_dl/extractor/twitter.py +++ b/gallery_dl/extractor/twitter.py @@ -222,10 +222,12 @@ class TwitterExtractor(Extractor): url = url["expanded_url"] if "//twitpic.com/" not in url or "/photos/" in url: continue - resp = self.request(url.replace("http:", "https:", 1), fatal=False) - if resp.status_code >= 400: + if url.startswith("http:"): + url = "https" + url[4:] + response = self.request(url, fatal=False) + if response.status_code >= 400: continue - url = text.extr(resp.text, 'name="twitter:image" value="', '"') + url = text.extr(response.text, 'name="twitter:image" value="', '"') if url: files.append({"url": url})