From 495c9ee126bd31bdd881a5770232fb2f71384a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 27 Feb 2024 18:42:29 +0100 Subject: [PATCH] [bluesky] add 'reposts' option (#4438, #5248) --- docs/configuration.rst | 10 ++++++++++ gallery_dl/extractor/bluesky.py | 17 +++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 26a8e2b7..186b87d2 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1242,6 +1242,16 @@ Description (See `depth` parameter of `app.bsky.feed.getPostThread `__) +extractor.bluesky.reposts +------------------------- +Type + ``bool`` +Default + ``false`` +Description + Process reposts. + + extractor.cyberdrop.domain -------------------------- Type diff --git a/gallery_dl/extractor/bluesky.py b/gallery_dl/extractor/bluesky.py index c7221500..691d504f 100644 --- a/gallery_dl/extractor/bluesky.py +++ b/gallery_dl/extractor/bluesky.py @@ -39,12 +39,18 @@ class BlueskyExtractor(Extractor): self._metadata_facets = ("facets" in meta) self.api = BlueskyAPI(self) - self._user = None + self._user = self._user_did = None def items(self): for post in self.posts(): if "post" in post: post = post["post"] + + pid = post["uri"].rpartition("/")[2] + if self._user_did and post["author"]["did"] != self._user_did: + self.log.debug("Skipping %s (repost)", pid) + continue + post.update(post["record"]) del post["record"] @@ -75,7 +81,7 @@ class BlueskyExtractor(Extractor): if self._metadata_user: post["user"] = self._user or post["author"] - post["post_id"] = post["uri"].rpartition("/")[2] + post["post_id"] = pid post["count"] = len(images) post["date"] = text.parse_datetime( post["createdAt"][:19], "%Y-%m-%dT%H:%M:%S") @@ -385,8 +391,11 @@ class BlueskyAPI(): else: did = self.resolve_handle(actor) - if self.extractor._metadata_user: - self.extractor._user = self.get_profile(did) + extr = self.extractor + if not extr.config("reposts", False): + extr._user_did = did + if extr._metadata_user: + extr._user = self.get_profile(did) return did