feat: receive ordered stream playback queues

This commit is contained in:
2026-10-22 14:06:47 +02:00
parent e7a33ff68e
commit 70672321a1
9 changed files with 239 additions and 7 deletions
+12
View File
@@ -5,12 +5,14 @@ enum PlayerCommand {
case printDefaultConfig
case launch(URL?, newInstance: Bool, noConfig: Bool, progressFile: URL?)
case launchSource(sourceFile: URL, newInstance: Bool, noConfig: Bool, progressFile: URL?)
case launchQueue(queueFile: URL, newInstance: Bool, noConfig: Bool)
static let usage = """
Usage: terebi [--new-instance] [--no-config] [FILE | STREAM_URL]
terebi [--new-instance] [--no-config] --url STREAM_URL
terebi --new-instance --url STREAM_URL --progress-file PATH
terebi --new-instance --source-file PATH [--progress-file PATH]
terebi --new-instance [--no-config] --queue-file PATH
terebi [--new-instance] [--no-config] -- FILE
terebi --help
terebi --default-config
@@ -23,6 +25,7 @@ enum PlayerCommand {
--no-config Use built-in settings instead of config.toml on a fresh launch.
--url URL Open a YouTube video or Miruro episode URL.
--source-file PATH Open a validated resolved HTTP(S) source in a new player.
--queue-file PATH Open an ordered version-1 stream queue with per-item reports.
--progress-file PATH Write JSONL playback facts to a new private file; requires
--new-instance. The GUI owns reporting after this CLI exits.
-- Treat the following argument as a filename, even with a leading '-'.
@@ -90,6 +93,15 @@ enum PlayerCommand {
guard progressFile == nil else { throw ArgumentError("--progress-file cannot be combined with --default-config.") }
return .printDefaultConfig
}
if inputs.first == "--queue-file" {
guard newInstance, progressFile == nil, inputs.count == 2,
inputs[1].hasPrefix("/"), !inputs[1].contains("\0") else {
throw ArgumentError("--queue-file requires --new-instance and one absolute manifest path; it cannot be combined with --progress-file.")
}
let queueFile = URL(fileURLWithPath: inputs[1]).standardizedFileURL
_ = try StreamQueue.load(from: queueFile)
return .launchQueue(queueFile: queueFile, newInstance: newInstance, noConfig: noConfig)
}
if inputs.first == "--source-file" {
guard newInstance else { throw ArgumentError("--source-file requires --new-instance.") }
guard inputs.count == 2, !inputs[1].isEmpty, !inputs[1].contains("\0"),