bilibili: resolve b23.tv short links to full bilibili url

This commit is contained in:
Tyler Lafayette 2023-06-21 17:49:35 +08:00
parent 0848923cc7
commit c2470eaa19

View File

@ -31,6 +31,14 @@ export async function getJSON(originalURL, lang, obj) {
url = url.replace(url.split('/')[5], '')
}
break;
case "b23":
const shortUrlId = new URL(url).pathname.split("/")[1];
if (!shortUrlId) {
return apiJSON(0, { t: errorUnsupported(lang) });
}
host = "bilibili";
url = await fetch(`https://b23.tv/${shortUrlId}`).then(res => res.url);
}
if (!(host && host.length < 20 && host in patterns && patterns[host]["enabled"])) return apiJSON(0, { t: errorUnsupported(lang) });