blob: 2c2871dcf5c2f75a604f686e7adfc6576ac1d4b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
const file = await Deno.readTextFile(Deno.args[1])
const note_filter = Deno.args.length >= 3 ? Deno.args[2] : ""
const ws = new WebSocket(Deno.args[0])
function run_enqueue() {
let kind = "http"
for (const line of file.split("\n")) {
if (!line.trim().length) continue
else if (line.startsWith("[") && line.endsWith("]"))
kind = line.substring(1, line.length - 1)
else {
const [name, rest] = line.split("=", 2)
const [id, note] = rest.split(";", 2)
if (note_filter.length && note != note_filter) continue
const key = `${kind}:${id}`;
ws.send(JSON.stringify({ t: "metadata", key, data: { output: name, title: name } }))
ws.send(JSON.stringify({ t: "enqueue", key }))
}
}
ws.send(JSON.stringify({ t: "save" }))
console.log("done");
}
ws.onerror = () => console.error("ws error")
ws.onclose = () => console.error("ws closed")
ws.onopen = () => {
console.log("ws open");
ws.send(JSON.stringify({ t: "register", name: "enqueuer", sources: [] }))
run_enqueue()
}
ws.onmessage = ev => {
console.log(ev.data);
}
|