77 lines
2.5 KiB
Go
77 lines
2.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
const usage = `Usage: zapret-autotune <command>
|
|
|
|
Commands:
|
|
status Show latest recorded tune run/proposal (not live service health)
|
|
history [--limit N] List recorded tune attempts (default 20; proposals not active)
|
|
strategies youtube List recorded proposals (not active), newest first
|
|
discover youtube Refuse discovery until provider/config is agreed
|
|
check youtube Refuse checks until probe URLs/video IDs are configured and agreed
|
|
tune youtube Test youtube.com frontend only; print options without applying
|
|
render <json-file> Select normalized offline results and print NFQWS2_OPT
|
|
`
|
|
|
|
func main() {
|
|
os.Exit(run(os.Args[1:], os.Stdout, os.Stderr))
|
|
}
|
|
|
|
func run(args []string, stdout, stderr io.Writer) int {
|
|
if len(args) > 0 && args[0] == "history" {
|
|
return history(args[1:], stdout, stderr)
|
|
}
|
|
if len(args) == 2 && args[0] == "strategies" && args[1] == "youtube" {
|
|
return strategiesYoutube(stdout, stderr)
|
|
}
|
|
if len(args) == 2 && args[0] == "tune" && args[1] == "youtube" {
|
|
return tuneYoutube(stdout, stderr, runBlockcheck)
|
|
}
|
|
if len(args) == 2 && args[0] == "render" {
|
|
file, err := os.Open(args[1])
|
|
if err != nil {
|
|
fmt.Fprintln(stderr, "error: cannot open results:", err)
|
|
return 1
|
|
}
|
|
defer file.Close()
|
|
output, err := renderResults(file)
|
|
if err != nil {
|
|
fmt.Fprintln(stderr, "error: cannot render results:", err)
|
|
return 1
|
|
}
|
|
if _, err := fmt.Fprintln(stdout, output); err != nil {
|
|
fmt.Fprintln(stderr, "error: cannot write results:", err)
|
|
return 1
|
|
}
|
|
return 0
|
|
}
|
|
if len(args) == 1 {
|
|
switch args[0] {
|
|
case "status":
|
|
return status(stdout, stderr)
|
|
case "help", "--help", "-h":
|
|
if _, err := fmt.Fprint(stdout, usage); err != nil {
|
|
fmt.Fprintln(stderr, "error: cannot write usage:", err)
|
|
return 1
|
|
}
|
|
return 0
|
|
}
|
|
}
|
|
if len(args) == 2 && args[0] == "discover" && args[1] == "youtube" {
|
|
fmt.Fprintln(stderr, "error: discover youtube is unavailable: YouTube provider/config is not implemented; probe URLs/video IDs and API credentials/cookie requirements have not been configured or agreed. No network requests were made; no endpoints were generated.")
|
|
return 1
|
|
}
|
|
if len(args) == 2 && args[0] == "check" && args[1] == "youtube" {
|
|
fmt.Fprintln(stderr, "error: check youtube is unavailable: YouTube probe URLs/video IDs have not been configured or agreed. No network requests were made; production health was not checked.")
|
|
return 1
|
|
}
|
|
fmt.Fprintln(stderr, "error: missing, unknown, or unsupported command/arguments")
|
|
fmt.Fprint(stderr, usage)
|
|
return 2
|
|
}
|