Videos and Images now work with the blob system in Bsky (mastodon doesn't give the user a blob)

This commit is contained in:
CatAClock 2025-05-20 17:36:28 -07:00
parent 6e8ca0b4d8
commit 69605379c3
2 changed files with 7 additions and 3 deletions

View file

@ -48,7 +48,7 @@ export async function GetPosts(URIs) {
// Get a blob (like an image or video). Authentication need not apply.
export async function GetBlob(DID, CID) {
let request = fetch("https://bsky.social/xrpc/com.atproto.sync.getBlob?did=" + DID + "&cid=" + CID, {method: "GET"});
let body = await request.then((response) => response.json());
let body = await request.then((response) => response.blob());
return body;
}

View file

@ -83,11 +83,15 @@ async function GetPost() {
if (post.post.record.hasOwnProperty("embed")) {
if (post.post.record.embed.$type == "app.bsky.embed.images") {
for (let i of post.post.embed.images) {
document.getElementsByClassName("Images")[0].innerHTML = document.getElementsByClassName("Images")[0].innerHTML + "<img src=" + i.fullsize + " alt='" + i.alt + "'/>";
var Blobby = await BlueskyAPI.GetBlob(post.post.author.did, post.post.record.embed.images[0].image.ref.$link);
var ObjectURL = URL.createObjectURL(Blobby)
document.getElementsByClassName("Images")[0].innerHTML = document.getElementsByClassName("Images")[0].innerHTML + "<img src=" + ObjectURL + " alt='" + i.alt + "'/>";
}
} else if (post.post.record.embed.$type == "app.bsky.embed.video") {
let i = post.post.embed.playlist;
document.getElementsByClassName("Images")[0].innerHTML = document.getElementsByClassName("Images")[0].innerHTML + "<video controls src=" + i + "></video>";
var Blobby = await BlueskyAPI.GetBlob(post.post.author.did, post.post.record.embed.video.ref.$link);
var ObjectURL = URL.createObjectURL(Blobby)
document.getElementsByClassName("Images")[0].innerHTML = document.getElementsByClassName("Images")[0].innerHTML + "<video controls src=" + ObjectURL + "></video>";
}
}
// We don't need to update the post with new information. The repos are seperate.