diff options
Diffstat (limited to 'scripts/ytdlp_download.ts')
-rw-r--r-- | scripts/ytdlp_download.ts | 9 |
1 files changed, 7 insertions, 2 deletions
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<string, string> { } } +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 => { |