From aaf6992bae35922d6058bd114e230af30886de67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 17 Sep 2022 14:44:42 +0200 Subject: [PATCH] [twitter] fix new-style '/card_img/' URLs --- gallery_dl/extractor/twitter.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gallery_dl/extractor/twitter.py b/gallery_dl/extractor/twitter.py index 923e5721..48eb3081 100644 --- a/gallery_dl/extractor/twitter.py +++ b/gallery_dl/extractor/twitter.py @@ -155,8 +155,11 @@ class TwitterExtractor(Extractor): }) elif "media_url_https" in media: url = media["media_url_https"] - base, _, fmt = url.rpartition(".") - base += "?format=" + fmt + "&name=" + if url[-4] == ".": + base, _, fmt = url.rpartition(".") + base += "?format=" + fmt + "&name=" + else: + base = url.rpartition("=")[0] + "=" files.append(text.nameext_from_url(url, { "url" : base + self._size_image, "width" : width, @@ -796,6 +799,13 @@ class TwitterTweetExtractor(TwitterExtractor): ("https://twitter.com/my0nruri/status/1528379296041299968", { "keyword": {"description": "oc"} }), + # '?format=...&name=...'-style URLs + ("https://twitter.com/poco_dandy/status/1150646424461176832", { + "options": (("cards", True),), + "pattern": r"https://pbs.twimg.com/card_img/157\d+/\w+" + r"\?format=(jpg|png)&name=orig$", + "range": "1-2", + }), ) def __init__(self, match):