summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/urlshortener.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2025-04-27 20:34:08 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2025-04-27 20:34:08 -0400
commit4a18b5837c1dd82f5964afcfc3fecc53cd97e79c (patch)
tree44019190a44fd449daa0efd07c65bbe524688c33 /gallery_dl/extractor/urlshortener.py
parentb830dc03b3b7c9dd119648e1be9c1145d56e096c (diff)
New upstream version 1.29.5.upstream/1.29.5
Diffstat (limited to 'gallery_dl/extractor/urlshortener.py')
-rw-r--r--gallery_dl/extractor/urlshortener.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/gallery_dl/extractor/urlshortener.py b/gallery_dl/extractor/urlshortener.py
index 49a3deb..0478ef0 100644
--- a/gallery_dl/extractor/urlshortener.py
+++ b/gallery_dl/extractor/urlshortener.py
@@ -32,21 +32,13 @@ BASE_PATTERN = UrlshortenerExtractor.update({
class UrlshortenerLinkExtractor(UrlshortenerExtractor):
"""Extractor for general-purpose URL shorteners"""
subcategory = "link"
- pattern = BASE_PATTERN + r"/([^/?#]+)"
+ pattern = BASE_PATTERN + r"(/[^/?#]+)"
example = "https://bit.ly/abcde"
- def __init__(self, match):
- UrlshortenerExtractor.__init__(self, match)
- self.id = match.group(match.lastindex)
-
- def _init(self):
- self.headers = self.config_instance("headers")
-
def items(self):
- response = self.request(
- "{}/{}".format(self.root, self.id), headers=self.headers,
- method="HEAD", allow_redirects=False, notfound="URL")
- try:
- yield Message.Queue, response.headers["location"], {}
- except KeyError:
+ url = self.root + self.groups[-1]
+ location = self.request_location(
+ url, headers=self.config_instance("headers"), notfound="URL")
+ if not location:
raise exception.StopExtraction("Unable to resolve short URL")
+ yield Message.Queue, location, {}