From be7e08a3b891a28479af77dcf1d0e016fd9ff35f Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 20 May 2025 23:37:23 +0200 Subject: bilibili support --- scripts/ytdlp_download.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'scripts/ytdlp_download.ts') diff --git a/scripts/ytdlp_download.ts b/scripts/ytdlp_download.ts index 9489e49..184f2f5 100644 --- a/scripts/ytdlp_download.ts +++ b/scripts/ytdlp_download.ts @@ -24,9 +24,14 @@ export class TextLineStream extends TransformStream { } } +const supported = [ + "youtube", + "bilibili", +] function key_to_url(key: string): string { const [kind, id] = key.split(":", 2) - if (kind == "youtube") return `https://youtube.com/watch?v=${id}` + if (kind == "youtube") return `https://www.youtube.com/watch?v=${id}` + if (kind == "bilibili") return `https://www.bilibili.com/video/${id}` throw new Error("unknown kind"); } @@ -79,7 +84,7 @@ ws.onclose = () => { } ws.onopen = () => { console.log("ws open"); - ws.send(JSON.stringify({ t: "register", name: "yt-dlp video downloader", task_kinds: ["youtube"] })) + ws.send(JSON.stringify({ t: "register", name: "yt-dlp video downloader", task_kinds: supported })) ws.send(JSON.stringify({ t: "accept" })) } ws.onmessage = async ev => { -- cgit v1.2.3-70-g09d2