Skip to content

Commit

Permalink
[bluesky] add 'depth' option (#4438)
Browse files Browse the repository at this point in the history
and reduce default depth and parentHeight values
  • Loading branch information
mikf committed Feb 15, 2024
1 parent 42335ea commit 7e036ea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
12 changes: 12 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,18 @@ Description
Download embedded videos hosted on https://www.blogger.com/


extractor.bluesky.post.depth
----------------------------
Type
``integer``
Default
``0``
Description
Sets the maximum depth of returned reply posts.

(See `depth` parameter of `app.bsky.feed.getPostThread <https://www.docs.bsky.app/docs/api/app-bsky-feed-get-post-thread>`__)


extractor.cyberdrop.domain
--------------------------
Type
Expand Down
18 changes: 16 additions & 2 deletions gallery_dl/extractor/bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ class BlueskyAPI():
"""

def __init__(self, extractor):
self.headers = {}
self.extractor = extractor
self.log = extractor.log
self.headers = {"Accept": "application/json"}

self.username, self.password = extractor._get_auth_info()
if self.username:
Expand Down Expand Up @@ -265,8 +265,22 @@ def get_post_thread(self, actor, post_id):
params = {
"uri": "at://{}/app.bsky.feed.post/{}".format(
self._did_from_actor(actor), post_id),
"depth" : self.extractor.config("depth", "0"),
"parentHeight": "0",
}
return (self._call(endpoint, params)["thread"],)

thread = self._call(endpoint, params)["thread"]
if "replies" not in thread:
return (thread,)

index = 0
posts = [thread]
while index < len(posts):
post = posts[index]
if "replies" in post:
posts.extend(post["replies"])
index += 1
return posts

def get_profile(self, actor):
endpoint = "app.bsky.actor.getProfile"
Expand Down

0 comments on commit 7e036ea

Please sign in to comment.