Closed aalku closed 1 week ago
Love your project, as always.
I made these changes in order to upload video from an URL. fetchMediaForBlob() failed with the "image/" type if the URL pointed to a video.
fetchMediaForBlob()
diff --git a/node_modules/@skyware/bot/dist/bot/Bot.js b/node_modules/@skyware/bot/dist/bot/Bot.js index 596325a..948fd2b 100644 --- a/node_modules/@skyware/bot/dist/bot/Bot.js +++ b/node_modules/@skyware/bot/dist/bot/Bot.js @@ -620,10 +620,10 @@ export class Bot extends EventEmitter { if (payload.images?.length && payload.video) { throw new Error("A post can only contain one of images or video."); } - const uploadMedia = async (media) => { + const uploadMedia = async (media, type="image/") => { let blob; if (typeof media === "string") { - blob = await fetchMediaForBlob(media, "image/").catch((e) => { + blob = await fetchMediaForBlob(media, type).catch((e) => { // eslint-disable-next-line @typescript-eslint/no-base-to-string, @typescript-eslint/restrict-template-expressions throw new Error(`Failed to fetch media at ${media}.`, { cause: e }); }) ?? {}; @@ -711,7 +711,7 @@ export class Bot extends EventEmitter { throw new Error("Video blob is not a video"); } payload.video.alt ??= ""; - const videoBlob = await uploadMedia(payload.video.data); + const videoBlob = await uploadMedia(payload.video.data, "video/"); embed = { ...payload.video, $type: "app.bsky.embed.video",
This issue body was partially generated by patch-package.
Whoops, good catch! Will fix in the next version.
Love your project, as always.
I made these changes in order to upload video from an URL.
fetchMediaForBlob()
failed with the "image/" type if the URL pointed to a video.This issue body was partially generated by patch-package.