mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
[bluesky] add 'hashtag' extractor (#4438)
https://github.com/mikf/gallery-dl/issues/4438#issuecomment-2439979958
This commit is contained in:
parent
8dce52471a
commit
a4791f5243
@ -136,7 +136,7 @@ Consider all listed sites to potentially be NSFW.
|
||||
<tr>
|
||||
<td>Bluesky</td>
|
||||
<td>https://bsky.app/</td>
|
||||
<td>Avatars, Backgrounds, Feeds, Followed Users, Likes, Lists, Media Files, Posts, Replies, Search Results, User Profiles</td>
|
||||
<td>Avatars, Backgrounds, Feeds, Followed Users, Hashtags, Likes, Lists, Media Files, Posts, Replies, Search Results, User Profiles</td>
|
||||
<td>Supported</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -317,6 +317,15 @@ class BlueskySearchExtractor(BlueskyExtractor):
|
||||
return self.api.search_posts(self.user)
|
||||
|
||||
|
||||
class BlueskyHashtagExtractor(BlueskyExtractor):
|
||||
subcategory = "hashtag"
|
||||
pattern = BASE_PATTERN + r"/hashtag/([^/?#]+)(?:/(top|latest))?"
|
||||
example = "https://bsky.app/hashtag/NAME"
|
||||
|
||||
def posts(self):
|
||||
return self.api.search_posts("#"+self.user, self.groups[1])
|
||||
|
||||
|
||||
class BlueskyAPI():
|
||||
"""Interface for the Bluesky API
|
||||
|
||||
@ -412,11 +421,12 @@ class BlueskyAPI():
|
||||
params = {"handle": handle}
|
||||
return self._call(endpoint, params)["did"]
|
||||
|
||||
def search_posts(self, query):
|
||||
def search_posts(self, query, sort=None):
|
||||
endpoint = "app.bsky.feed.searchPosts"
|
||||
params = {
|
||||
"q" : query,
|
||||
"limit": "100",
|
||||
"sort" : sort,
|
||||
}
|
||||
return self._pagination(endpoint, params, "posts")
|
||||
|
||||
|
@ -110,6 +110,22 @@ __tests__ = (
|
||||
"#archive" : False,
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://bsky.app/hashtag/nature",
|
||||
"#class" : bluesky.BlueskyHashtagExtractor,
|
||||
"#range" : "1-40",
|
||||
"#count" : 40,
|
||||
"#archive" : False,
|
||||
},
|
||||
{
|
||||
"#url" : "https://bsky.app/hashtag/top",
|
||||
"#class" : bluesky.BlueskyHashtagExtractor,
|
||||
},
|
||||
{
|
||||
"#url" : "https://bsky.app/hashtag/nature/latest",
|
||||
"#class" : bluesky.BlueskyHashtagExtractor,
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://bsky.app/profile/bsky.app/post/3kh5rarr3gn2n",
|
||||
"#category": ("", "bluesky", "post"),
|
||||
|
Loading…
Reference in New Issue
Block a user