best way to save what you love
Svelte collaborationdownloaderinstagramjavascriptmusicredditsocial-mediasoundcloudsveltetiktoktwittertypescriptvideovimeovkwebappyoutubeyoutube-downloader
api/bilibili: use shortlink resolver
jj6d18dff5ccbf
diff --git a/api/src/processing/services/bilibili.js b/api/src/processing/services/bilibili.jsindex b47b0bc2..4ee148db 100644--- a/api/src/processing/services/bilibili.js+++ b/api/src/processing/services/bilibili.js@@ -1,19 +1,8 @@import { genericUserAgent, env } from "../../config.js";+import { resolveRedirectingURL } from "../url.js";// TO-DO: higher quality downloads (currently requires an account)-function com_resolveShortlink(shortId) {- return fetch(`https://b23.tv/${shortId}`, { redirect: 'manual' })- .then(r => r.status > 300 && r.status < 400 && r.headers.get('location'))- .then(url => {- if (!url) return;- const path = new URL(url).pathname;- if (path.startsWith('/video/'))- return path.split('/')[2];- })- .catch(() => {})-}-function getBest(content) {return content?.filter(v => v.baseUrl || v.url).map(v => (v.baseUrl = v.baseUrl || v.url, v))@@ -99,7 +88,8 @@ async function tv_download(id) {export default async function({ comId, tvId, comShortLink }) {if (comShortLink) {- comId = await com_resolveShortlink(comShortLink);+ const patternMatch = await resolveRedirectingURL(`https://b23.tv/${comShortLink}`);+ comId = patternMatch?.comId;}if (comId) {