[bluesky] handle different 'embed' structure

This commit is contained in:
Mike Fährmann
2024-03-03 20:41:01 +01:00
parent 1115dccd0d
commit 6482bbc525
2 changed files with 14 additions and 2 deletions

View File

@@ -107,10 +107,14 @@ class BlueskyExtractor(Extractor):
post["width"] = post["height"] = 0
image = file["image"]
post["filename"] = link = image["ref"]["$link"]
try:
cid = image["ref"]["$link"]
except KeyError:
cid = image["cid"]
post["filename"] = cid
post["extension"] = image["mimeType"].rpartition("/")[2]
yield Message.Url, base + link, post
yield Message.Url, base + cid, post
def posts(self):
return ()

View File

@@ -202,4 +202,12 @@ __tests__ = (
"uri" : "at://did:plc:cslxjqkeexku6elp5xowxkq7/app.bsky.feed.post/3kkzc3xaf5m2w",
},
{
"#url" : "https://bsky.app/profile/go-guiltism.bsky.social/post/3klgth6lilt2l",
"#comment" : "different embed CID path",
"#category": ("", "bluesky", "post"),
"#class" : bluesky.BlueskyPostExtractor,
"#urls" : "https://bsky.social/xrpc/com.atproto.sync.getBlob?did=did:plc:owc2r2dsewj3hk73rtd746zh&cid=bafkreieuhplc7fpbvi3suvacaf2dqxzvuu4hgl5o6eifqb76tf3uopldmi",
},
)