diff --git a/docs/supportedsites.md b/docs/supportedsites.md index cec88be2..4f9e1a1f 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -136,7 +136,7 @@ Consider all listed sites to potentially be NSFW. Bluesky https://bsky.app/ - Avatars, Backgrounds, Feeds, Followed Users, Likes, Lists, Media Files, Posts, Replies, Search Results, User Profiles + Avatars, Backgrounds, Feeds, Followed Users, Hashtags, Likes, Lists, Media Files, Posts, Replies, Search Results, User Profiles Supported diff --git a/gallery_dl/extractor/bluesky.py b/gallery_dl/extractor/bluesky.py index a1a488ee..de5d0c6f 100644 --- a/gallery_dl/extractor/bluesky.py +++ b/gallery_dl/extractor/bluesky.py @@ -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") diff --git a/test/results/bluesky.py b/test/results/bluesky.py index 3831aca7..50a0dcd9 100644 --- a/test/results/bluesky.py +++ b/test/results/bluesky.py @@ -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"),