feat: report authoritative playback progress from shared backend

This commit is contained in:
2026-10-11 19:29:35 +02:00
parent a4c38bfa51
commit cc99a2a4f8
14 changed files with 1369 additions and 62 deletions
+21 -2
View File
@@ -16,12 +16,14 @@ struct PlayerCommandChecks {
let instanceFile = directory.appendingPathComponent("--new-instance")
for file in [movie, optionFile, colonFile, instanceFile] { try Data().write(to: file) }
func opened(_ arguments: [String], newInstance: Bool = false, noConfig: Bool = false) throws -> URL? {
guard case .launch(let url, let independent, let bypass) = try PlayerCommand.parse(arguments, directory: directory) else {
func opened(_ arguments: [String], newInstance: Bool = false, noConfig: Bool = false,
progressFile: URL? = nil) throws -> URL? {
guard case .launch(let url, let independent, let bypass, let report) = try PlayerCommand.parse(arguments, directory: directory) else {
fatalError("FAIL: expected a launch command")
}
require(independent == newInstance, "launch mode preserves default reuse or explicit independence")
require(bypass == noConfig, "configuration loading defaults on and can be explicitly bypassed")
require(report == progressFile, "reporting destination preserves launch scope and resolves against invoking directory")
return url
}
require(try opened([movie.lastPathComponent]) == movie, "relative paths resolve against invocation directory, preserving spaces")
@@ -58,6 +60,17 @@ struct PlayerCommandChecks {
guard case .printDefaultConfig = try PlayerCommand.parse(["--default-config"]) else {
fatalError("FAIL: printing defaults must not launch a player")
}
let report = directory.appendingPathComponent("session with spaces.jsonl")
require(try opened(["--new-instance", "--url", canonical.absoluteString, "--progress-file", report.path],
newInstance: true, progressFile: report) == canonical,
"reporting after media arguments retains canonical YouTube identity")
require(try opened(["--progress-file", report.lastPathComponent, "--new-instance", "--no-config", "--url", canonical.absoluteString],
newInstance: true, noConfig: true, progressFile: report) == canonical,
"relative report path is made absolute before GUI forwarding")
let reportFlagFile = directory.appendingPathComponent("--progress-file")
try Data().write(to: reportFlagFile)
require(try opened(["--", "--progress-file"]) == reportFlagFile,
"escaped reporting option remains a filename")
for arguments in [["--url"], ["--url", canonical.absoluteString, movie.path], ["--"],
[movie.path, movie.path], ["--unknown"], ["missing.mp4"], [directory.path],
@@ -67,6 +80,12 @@ struct PlayerCommandChecks {
["--new-instance", "--unknown"], ["--no-config", "--no-config"],
["--default-config", movie.path], ["--default-config", "--default-config"],
["--print-default-config"],
["--progress-file", report.path],
["--new-instance", "--url", canonical.absoluteString, "--progress-file"],
["--new-instance", "--progress-file", ""],
["--new-instance", "--progress-file", report.path, "--progress-file", report.path],
["--new-instance", "--progress-file", report.path, "--help"],
["--new-instance", "--progress-file", report.path, "--default-config"],
["--no-config", "--new-instance", "--no-config"]] {
do {
_ = try PlayerCommand.parse(arguments, directory: directory)