1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[bluesky] add 'reposts' option (#4438, #5248)

This commit is contained in:
Mike Fährmann 2024-02-27 18:42:29 +01:00
parent c8b591303f
commit 495c9ee126
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 23 additions and 4 deletions

View File

@ -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

View File

@ -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