Skip to content

Commit

Permalink
[bluesky] add 'reposts' option (#4438, #5248)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Feb 27, 2024
1 parent c8b5913 commit 495c9ee
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
10 changes: 10 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,16 @@ Description
(See `depth` parameter of `app.bsky.feed.getPostThread <https://www.docs.bsky.app/docs/api/app-bsky-feed-get-post-thread>`__)


extractor.bluesky.reposts
-------------------------
Type
``bool``
Default
``false``
Description
Process reposts.


extractor.cyberdrop.domain
--------------------------
Type
Expand Down
17 changes: 13 additions & 4 deletions gallery_dl/extractor/bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ def _init(self):
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"]

Expand Down Expand Up @@ -75,7 +81,7 @@ def items(self):
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")
Expand Down Expand Up @@ -385,8 +391,11 @@ def _did_from_actor(self, actor):
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

Expand Down

0 comments on commit 495c9ee

Please sign in to comment.