From cd01eacd3d9218250e8a7ae51dfd9b10f071b96e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 10 May 2025 18:00:25 +0200 Subject: [PATCH] [mastodon] support Akkoma/Pleroma '/objects/:uuid' URLs (#7497) --- gallery_dl/extractor/mastodon.py | 6 +++++- test/results/mastodon.py | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gallery_dl/extractor/mastodon.py b/gallery_dl/extractor/mastodon.py index 4cb45c88..8b384741 100644 --- a/gallery_dl/extractor/mastodon.py +++ b/gallery_dl/extractor/mastodon.py @@ -197,10 +197,14 @@ class MastodonStatusExtractor(MastodonExtractor): """Extractor for images from a status""" subcategory = "status" pattern = (BASE_PATTERN + r"/(?:@[^/?#]+|(?:users/[^/?#]+/)?" - r"(?:statuses|notice))/(?!following)([^/?#]+)") + r"(?:statuses|notice|objects()))/(?!following)([^/?#]+)") example = "https://mastodon.social/@USER/12345" def statuses(self): + if self.groups[-2] is not None: + url = "{}/objects/{}".format(self.root, self.item) + location = self.request_location(url) + self.item = location.rpartition("/")[2] return (MastodonAPI(self).status(self.item),) diff --git a/test/results/mastodon.py b/test/results/mastodon.py index 14fa724a..4e1407bb 100644 --- a/test/results/mastodon.py +++ b/test/results/mastodon.py @@ -74,4 +74,15 @@ __tests__ = ( "instance_remote": None, }, +{ + "#url" : "mastodon:https://labyrinth.zone/objects/ac523779-93d3-4315-ab8e-25b1665740cf", + "#comment" : "/objects/:uuid (#7497)", + "#category": ("mastodon", "labyrinth.zone", "status"), + "#class" : mastodon.MastodonStatusExtractor, + "#urls" : "https://media.labyrinth.zone/media/96e10a9e3b0f24f63713d8a03e939eec7f9e636cdef57a14c389163f58e60947.png", + + "instance" : "labyrinth.zone", + "instance_remote": None, +}, + )