From 7ccf64596eb693fa2cdc06ead6abdf9d82dc2fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 27 Mar 2025 18:32:04 +0100 Subject: [PATCH] [mastodon] support '/statuses' URLs (#7255) - /statuses/123456789 - /users/USER/statuses/123456789 --- gallery_dl/extractor/mastodon.py | 3 ++- test/results/mastodonsocial.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gallery_dl/extractor/mastodon.py b/gallery_dl/extractor/mastodon.py index 5b354ac0..5e78ad4d 100644 --- a/gallery_dl/extractor/mastodon.py +++ b/gallery_dl/extractor/mastodon.py @@ -196,7 +196,8 @@ class MastodonFollowingExtractor(MastodonExtractor): class MastodonStatusExtractor(MastodonExtractor): """Extractor for images from a status""" subcategory = "status" - pattern = BASE_PATTERN + r"/@[^/?#]+/(?!following)([^/?#]+)" + pattern = (BASE_PATTERN + r"/(?:@[^/?#]+|(?:users/[^/?#]+/)?statuses)" + r"/(?!following)([^/?#]+)") example = "https://mastodon.social/@USER/12345" def statuses(self): diff --git a/test/results/mastodonsocial.py b/test/results/mastodonsocial.py index 1eed8a24..890fa4dc 100644 --- a/test/results/mastodonsocial.py +++ b/test/results/mastodonsocial.py @@ -160,10 +160,25 @@ __tests__ = ( "#class" : mastodon.MastodonStatusExtractor, "#count" : 4, + "account": { + "acct": "jk", + }, "count": 4, "num" : int, }, +{ + "#url" : "https://mastodon.social/statuses/103794036899778366", + "#category": ("mastodon", "mastodon.social", "status"), + "#class" : mastodon.MastodonStatusExtractor, +}, + +{ + "#url" : "https://mastodon.social/users/jk/statuses/103794036899778366", + "#category": ("mastodon", "mastodon.social", "status"), + "#class" : mastodon.MastodonStatusExtractor, +}, + { "#url" : "https://mastodon.social/@technewsbot@assortedflotsam.com/112360601113258881", "#comment" : "card image",