fedimbed.bluesky: fix videos from PDSes
This commit is contained in:
parent
8884a60798
commit
8f732b49bf
1 changed files with 16 additions and 12 deletions
|
@ -147,9 +147,10 @@ async function blueskyQuoteEmbed(quote) {
|
|||
break;
|
||||
}
|
||||
case "app.bsky.embed.video#view": {
|
||||
const videoUrl = `https://bsky.social/xrpc/com.atproto.sync.getBlob?did=${encodeURIComponent(
|
||||
quote.author.did
|
||||
)}&cid=${embed.cid}`;
|
||||
const lookup = await fetch(`https://plc.directory/${quote.author.did}`).then((res) => res.json());
|
||||
const domain = lookup.service.find((service) => service.id === "#atproto_pds").serviceEndpoint;
|
||||
const videoUrl = `${domain}/xrpc/com.atproto.sync.getBlob?did=${quote.author.did}&cid=${embed.cid}`;
|
||||
|
||||
const contentType = await fetch(videoUrl, {
|
||||
method: "HEAD",
|
||||
}).then((res) => res.headers.get("Content-Type"));
|
||||
|
@ -163,9 +164,10 @@ async function blueskyQuoteEmbed(quote) {
|
|||
if (embed.media.$type === "app.bsky.embed.images#view") {
|
||||
embeds.push(...embed.media.images.map((image) => ({...mainEmbed, image: {url: image.fullsize}})));
|
||||
} else if (embed.media.$type === "app.bsky.embed.video#view") {
|
||||
const videoUrl = `https://bsky.social/xrpc/com.atproto.sync.getBlob?did=${encodeURIComponent(
|
||||
quote.author.did
|
||||
)}&cid=${embed.media.cid}`;
|
||||
const lookup = await fetch(`https://plc.directory/${quote.author.did}`).then((res) => res.json());
|
||||
const domain = lookup.service.find((service) => service.id === "#atproto_pds").serviceEndpoint;
|
||||
const videoUrl = `${domain}/xrpc/com.atproto.sync.getBlob?did=${quote.author.did}&cid=${embed.cid}`;
|
||||
|
||||
const contentType = await fetch(videoUrl, {
|
||||
method: "HEAD",
|
||||
}).then((res) => res.headers.get("Content-Type"));
|
||||
|
@ -253,9 +255,10 @@ async function bluesky(msg, url, spoiler = false) {
|
|||
break;
|
||||
}
|
||||
case "app.bsky.embed.video#view": {
|
||||
const videoUrl = `https://bsky.social/xrpc/com.atproto.sync.getBlob?did=${encodeURIComponent(
|
||||
post.author.did
|
||||
)}&cid=${post.embed.cid}`;
|
||||
const lookup = await fetch(`https://plc.directory/${post.author.did}`).then((res) => res.json());
|
||||
const domain = lookup.service.find((service) => service.id === "#atproto_pds").serviceEndpoint;
|
||||
const videoUrl = `${domain}/xrpc/com.atproto.sync.getBlob?did=${post.author.did}&cid=${post.embed.cid}`;
|
||||
|
||||
const contentType = await fetch(videoUrl, {
|
||||
method: "HEAD",
|
||||
}).then((res) => res.headers.get("Content-Type"));
|
||||
|
@ -278,9 +281,10 @@ async function bluesky(msg, url, spoiler = false) {
|
|||
if (post.embed.media.$type === "app.bsky.embed.images#view") {
|
||||
embeds.push(...post.embed.media.images.map((image) => ({...mainEmbed, image: {url: image.fullsize}})));
|
||||
} else if (post.embed.media.$type === "app.bsky.embed.video#view") {
|
||||
const videoUrl = `https://bsky.social/xrpc/com.atproto.sync.getBlob?did=${encodeURIComponent(
|
||||
post.author.did
|
||||
)}&cid=${post.embed.media.cid}`;
|
||||
const lookup = await fetch(`https://plc.directory/${post.author.did}`).then((res) => res.json());
|
||||
const domain = lookup.service.find((service) => service.id === "#atproto_pds").serviceEndpoint;
|
||||
const videoUrl = `${domain}/xrpc/com.atproto.sync.getBlob?did=${post.author.did}&cid=${post.embed.cid}`;
|
||||
|
||||
const contentType = await fetch(videoUrl, {
|
||||
method: "HEAD",
|
||||
}).then((res) => res.headers.get("Content-Type"));
|
||||
|
|
Loading…
Reference in a new issue