mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-14 20:30:06 +00:00
api/bluesky: add a dispatcher & update unknown error message
This commit is contained in:
parent
e3f6784e83
commit
8fc9ca2916
2 changed files with 9 additions and 7 deletions
|
@ -240,7 +240,8 @@ export default async function({ host, patternMatch, params }) {
|
||||||
case "bsky":
|
case "bsky":
|
||||||
r = await bluesky({
|
r = await bluesky({
|
||||||
...patternMatch,
|
...patternMatch,
|
||||||
alwaysProxy: params.alwaysProxy
|
alwaysProxy: params.alwaysProxy,
|
||||||
|
dispatcher
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@ import HLS from "hls-parser";
|
||||||
import { cobaltUserAgent } from "../../config.js";
|
import { cobaltUserAgent } from "../../config.js";
|
||||||
import { createStream } from "../../stream/manage.js";
|
import { createStream } from "../../stream/manage.js";
|
||||||
|
|
||||||
const extractVideo = async ({ media, filename }) => {
|
const extractVideo = async ({ media, filename, dispatcher }) => {
|
||||||
const urlMasterHLS = media?.playlist;
|
const urlMasterHLS = media?.playlist;
|
||||||
if (!urlMasterHLS) return { error: "fetch.empty" };
|
if (!urlMasterHLS) return { error: "fetch.empty" };
|
||||||
if (!urlMasterHLS.startsWith("https://video.bsky.app/")) return { error: "fetch.empty" };
|
if (!urlMasterHLS.startsWith("https://video.bsky.app/")) return { error: "fetch.empty" };
|
||||||
|
|
||||||
const masterHLS = await fetch(urlMasterHLS)
|
const masterHLS = await fetch(urlMasterHLS, { dispatcher })
|
||||||
.then(r => {
|
.then(r => {
|
||||||
if (r.status !== 200) return;
|
if (r.status !== 200) return;
|
||||||
return r.text();
|
return r.text();
|
||||||
|
@ -64,7 +64,7 @@ const extractImages = ({ getPost, filename, alwaysProxy }) => {
|
||||||
return { picker };
|
return { picker };
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function ({ user, post, alwaysProxy }) {
|
export default async function ({ user, post, alwaysProxy, dispatcher }) {
|
||||||
const apiEndpoint = new URL("https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread?depth=0&parentHeight=0");
|
const apiEndpoint = new URL("https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread?depth=0&parentHeight=0");
|
||||||
apiEndpoint.searchParams.set(
|
apiEndpoint.searchParams.set(
|
||||||
"uri",
|
"uri",
|
||||||
|
@ -73,8 +73,9 @@ export default async function ({ user, post, alwaysProxy }) {
|
||||||
|
|
||||||
const getPost = await fetch(apiEndpoint, {
|
const getPost = await fetch(apiEndpoint, {
|
||||||
headers: {
|
headers: {
|
||||||
"user-agent": cobaltUserAgent
|
"user-agent": cobaltUserAgent,
|
||||||
}
|
},
|
||||||
|
dispatcher
|
||||||
}).then(r => r.json()).catch(() => {});
|
}).then(r => r.json()).catch(() => {});
|
||||||
|
|
||||||
if (!getPost) return { error: "fetch.empty" };
|
if (!getPost) return { error: "fetch.empty" };
|
||||||
|
@ -87,7 +88,7 @@ export default async function ({ user, post, alwaysProxy }) {
|
||||||
case "InvalidRequest":
|
case "InvalidRequest":
|
||||||
return { error: "link.unsupported" };
|
return { error: "link.unsupported" };
|
||||||
default:
|
default:
|
||||||
return { error: "fetch.empty" };
|
return { error: "content.post.unavailable" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue