mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
[bluesky] add 'avatar' and 'background' extractors (#4438)
This commit is contained in:
parent
24c1317e0d
commit
91e5c4fdfe
@ -1185,6 +1185,31 @@ Description
|
||||
Download embedded videos hosted on https://www.blogger.com/
|
||||
|
||||
|
||||
extractor.bluesky.include
|
||||
-------------------------
|
||||
Type
|
||||
* ``string``
|
||||
* ``list`` of ``strings``
|
||||
Default
|
||||
``"media"``
|
||||
Example
|
||||
* ``"avatar,background,posts"``
|
||||
* ``["avatar", "background", "posts"]``
|
||||
Description
|
||||
A (comma-separated) list of subcategories to include
|
||||
when processing a user profile.
|
||||
|
||||
Possible values are
|
||||
``"avatar"``,
|
||||
``"background"``,
|
||||
``"posts"``,
|
||||
``"replies"``,
|
||||
``"media"``,
|
||||
``"likes"``,
|
||||
|
||||
It is possible to use ``"all"`` instead of listing all values separately.
|
||||
|
||||
|
||||
extractor.bluesky.metadata
|
||||
--------------------------
|
||||
Type
|
||||
|
@ -108,6 +108,36 @@ class BlueskyExtractor(Extractor):
|
||||
def posts(self):
|
||||
return ()
|
||||
|
||||
def _make_post(self, actor, kind):
|
||||
did = self.api._did_from_actor(actor)
|
||||
profile = self.api.get_profile(did)
|
||||
|
||||
if kind not in profile:
|
||||
return ()
|
||||
cid = profile[kind].rpartition("/")[2].partition("@")[0]
|
||||
|
||||
return ({
|
||||
"post": {
|
||||
"embed": {"images": [{
|
||||
"alt": kind,
|
||||
"image": {
|
||||
"$type" : "blob",
|
||||
"ref" : {"$link": cid},
|
||||
"mimeType": "image/jpeg",
|
||||
"size" : 0,
|
||||
},
|
||||
"aspectRatio": {
|
||||
"width" : 1000,
|
||||
"height": 1000,
|
||||
},
|
||||
}]},
|
||||
"author" : profile,
|
||||
"record" : (),
|
||||
"createdAt": "",
|
||||
"uri" : cid,
|
||||
},
|
||||
},)
|
||||
|
||||
|
||||
class BlueskyUserExtractor(BlueskyExtractor):
|
||||
subcategory = "user"
|
||||
@ -120,10 +150,12 @@ class BlueskyUserExtractor(BlueskyExtractor):
|
||||
def items(self):
|
||||
base = "{}/profile/{}/".format(self.root, self.user)
|
||||
return self._dispatch_extractors((
|
||||
(BlueskyPostsExtractor , base + "posts"),
|
||||
(BlueskyRepliesExtractor, base + "replies"),
|
||||
(BlueskyMediaExtractor , base + "media"),
|
||||
(BlueskyLikesExtractor , base + "likes"),
|
||||
(BlueskyAvatarExtractor , base + "avatar"),
|
||||
(BlueskyBackgroundExtractor, base + "banner"),
|
||||
(BlueskyPostsExtractor , base + "posts"),
|
||||
(BlueskyRepliesExtractor , base + "replies"),
|
||||
(BlueskyMediaExtractor , base + "media"),
|
||||
(BlueskyLikesExtractor , base + "likes"),
|
||||
), ("media",))
|
||||
|
||||
|
||||
@ -213,6 +245,26 @@ class BlueskyPostExtractor(BlueskyExtractor):
|
||||
return self.api.get_post_thread(self.user, self.post_id)
|
||||
|
||||
|
||||
class BlueskyAvatarExtractor(BlueskyExtractor):
|
||||
subcategory = "avatar"
|
||||
filename_fmt = "avatar_{post_id}.{extension}"
|
||||
pattern = USER_PATTERN + r"/avatar"
|
||||
example = "https://bsky.app/profile/HANDLE/avatar"
|
||||
|
||||
def posts(self):
|
||||
return self._make_post(self.user, "avatar")
|
||||
|
||||
|
||||
class BlueskyBackgroundExtractor(BlueskyExtractor):
|
||||
subcategory = "background"
|
||||
filename_fmt = "background_{post_id}.{extension}"
|
||||
pattern = USER_PATTERN + r"/ba(?:nner|ckground)"
|
||||
example = "https://bsky.app/profile/HANDLE/banner"
|
||||
|
||||
def posts(self):
|
||||
return self._make_post(self.user, "banner")
|
||||
|
||||
|
||||
class BlueskyAPI():
|
||||
"""Interface for the Bluesky API
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user