[bluesky] add 'bookmark' extractor (#8370)
This commit is contained in:
@@ -148,7 +148,7 @@ Consider all listed sites to potentially be NSFW.
|
||||
<tr id="bluesky" title="bluesky">
|
||||
<td>Bluesky</td>
|
||||
<td>https://bsky.app/</td>
|
||||
<td>Avatars, Backgrounds, Feeds, Followed Users, Hashtags, User Profile Information, Likes, Lists, Media Files, Posts, Replies, Search Results, User Profiles, Videos</td>
|
||||
<td>Avatars, Backgrounds, Bookmarks, Feeds, Followed Users, Hashtags, User Profile Information, Likes, Lists, Media Files, Posts, Replies, Search Results, User Profiles, Videos</td>
|
||||
<td>Supported</td>
|
||||
</tr>
|
||||
<tr id="boosty" title="boosty">
|
||||
|
||||
@@ -44,6 +44,8 @@ class BlueskyExtractor(Extractor):
|
||||
for post in self.posts():
|
||||
if "post" in post:
|
||||
post = post["post"]
|
||||
elif "item" in post:
|
||||
post = post["item"]
|
||||
if self._user_did and post["author"]["did"] != self._user_did:
|
||||
self.log.debug("Skipping %s (repost)", self._pid(post))
|
||||
continue
|
||||
@@ -372,6 +374,15 @@ class BlueskyHashtagExtractor(BlueskyExtractor):
|
||||
return self.api.search_posts("#"+hashtag, order)
|
||||
|
||||
|
||||
class BlueskyBookmarkExtractor(BlueskyExtractor):
|
||||
subcategory = "bookmark"
|
||||
pattern = BASE_PATTERN + r"/saved"
|
||||
example = "https://bsky.app/saved"
|
||||
|
||||
def posts(self):
|
||||
return self.api.get_bookmarks()
|
||||
|
||||
|
||||
class BlueskyAPI():
|
||||
"""Interface for the Bluesky API
|
||||
|
||||
@@ -407,6 +418,10 @@ class BlueskyAPI():
|
||||
}
|
||||
return self._pagination(endpoint, params)
|
||||
|
||||
def get_bookmarks(self):
|
||||
endpoint = "app.bsky.bookmark.getBookmarks"
|
||||
return self._pagination(endpoint, {}, "bookmarks", check_empty=True)
|
||||
|
||||
def get_feed(self, actor, feed):
|
||||
endpoint = "app.bsky.feed.getFeed"
|
||||
uri = (f"at://{self._did_from_actor(actor)}"
|
||||
|
||||
@@ -443,4 +443,9 @@ __tests__ = (
|
||||
"#class" : bluesky.BlueskyPostExtractor,
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://bsky.app/saved",
|
||||
"#class" : bluesky.BlueskyBookmarkExtractor,
|
||||
},
|
||||
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user