From 89f067e0ed2a900c32d95beae668c0321d7da79f Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 21 May 2025 19:00:24 +0200 Subject: finish up channel info script --- scripts/ytdlp_channel_info.ts | 10 +++++++--- scripts/ytdlp_flatten.ts | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/ytdlp_channel_info.ts b/scripts/ytdlp_channel_info.ts index c02182c..803336c 100644 --- a/scripts/ytdlp_channel_info.ts +++ b/scripts/ytdlp_channel_info.ts @@ -4,10 +4,13 @@ const ws = new WebSocket(Deno.args[0]) // deno-lint-ignore no-unused-vars let config: Config = {} as unknown as Config +const supported = [ + "youtube-channel-info" +] function key_to_url(key: string): string { const [kind, id] = key.split(":", 2) - if (kind == "youtube-channel") return `https://youtube.com/channel/${id}` - throw new Error("unknown kind"); + if (kind == "youtube-channel-info") return `https://youtube.com/channel/${id}` + throw new Error(`unknown kind ${kind}`); } async function dfile(path: string, url: string) { @@ -52,7 +55,7 @@ ws.onclose = () => { } ws.onopen = () => { console.log("ws open"); - ws.send(JSON.stringify({ t: "register", name: "yt-dlp channel info generator", task_kinds: ["youtube-channel-info"] })) + ws.send(JSON.stringify({ t: "register", name: "yt-dlp channel info generator", task_kinds: supported })) ws.send(JSON.stringify({ t: "accept" })) } ws.onmessage = async ev => { @@ -63,6 +66,7 @@ ws.onmessage = async ev => { if (p.t == "work") { const url = key_to_url(p.key) if (!p.data.output) throw new Error("no output"); + console.log(`got work ${p.key}`); await save_infojson(url, p.key, p.data) ws.send(JSON.stringify({ t: "complete", key: p.key })) ws.send(JSON.stringify({ t: "save" })) diff --git a/scripts/ytdlp_flatten.ts b/scripts/ytdlp_flatten.ts index a433665..5145196 100644 --- a/scripts/ytdlp_flatten.ts +++ b/scripts/ytdlp_flatten.ts @@ -73,8 +73,8 @@ ws.onmessage = async ev => { if (p.t == "error") console.error(`error: ${p.message}`); if (p.t == "work") { const [outkind, url] = key_to_url(p.key) - if (!p.data.output) throw new Error("no output"); await flat_playlist(url, outkind, p.data) + ws.send(JSON.stringify({ t: "metadata", key: key_to_infokey(p.key), data: p.data })) ws.send(JSON.stringify({ t: "enqueue", key: key_to_infokey(p.key) })) ws.send(JSON.stringify({ t: "complete", key: p.key })) ws.send(JSON.stringify({ t: "save" })) -- cgit v1.2.3-70-g09d2