From 875485313f216ce96d7d2a2c11e47d2d1b074a42 Mon Sep 17 00:00:00 2001 From: ClosedPort22 <44864697+ClosedPort22@users.noreply.github.com> Date: Sun, 9 Apr 2023 18:06:42 +0800 Subject: [PATCH] [urlshortener] force HTTPS --- gallery_dl/extractor/urlshortener.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gallery_dl/extractor/urlshortener.py b/gallery_dl/extractor/urlshortener.py index 23a6df86..3e404e86 100644 --- a/gallery_dl/extractor/urlshortener.py +++ b/gallery_dl/extractor/urlshortener.py @@ -28,7 +28,7 @@ class UrlshortenerExtractor(BaseExtractor): def __init__(self, match): BaseExtractor.__init__(self, match) self.headers = INSTANCES[self.category].get("headers") - self.url = match.group() + self.id = match.group(match.lastindex) def request(self, url, **kwargs): kwargs["headers"] = self.headers @@ -36,7 +36,8 @@ class UrlshortenerExtractor(BaseExtractor): def items(self): response = self.request( - self.url, method="HEAD", allow_redirects=False, notfound="URL") + "{}/{}".format(self.root, self.id), method="HEAD", + allow_redirects=False, notfound="URL") if "location" not in response.headers: raise exception.StopExtraction("Unable to resolve short URL") yield Message.Queue, response.headers["location"], {} @@ -56,4 +57,4 @@ INSTANCES = { } UrlshortenerExtractor.pattern = \ - UrlshortenerExtractor.update(INSTANCES) + r"/[^/?#&]+" + UrlshortenerExtractor.update(INSTANCES) + r"/([^/?#&]+)"