Files
zapret-autotune/cmd/zapret-autotune/main.go
T
2026-10-10 08:29:56 +03:00

100 lines
3.6 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 by group (not active)
discover youtube --video-id ID --proxy socks5://HOST:PORT
Discover cache hostname only (no media-transfer check)
health youtube One-shot Player API health through configured loopback SOCKS
managed init|status|apply
Manual activation inside the designated managed-test target only
check youtube Refuse checks until probe URLs/video IDs are configured and agreed
tune youtube Test youtube.com frontend only; print options without applying
tune googlevideo --video-id ID --proxy socks5://HOST:PORT
Discover and verify one exact cache host; proposal only
recover googlevideo --video-id ID --proxy socks5://HOST:PORT
Recheck saved scenarios before scanning; proposal, not active
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 {
return runWithPlayer(args, stdout, stderr, runPlayerCurl)
}
func runWithPlayer(args []string, stdout, stderr io.Writer, player playerRunner) int {
if len(args) > 0 && args[0] == "managed" {
return managedCLI(args[1:], stdout, stderr, managedDependencies(player))
}
if len(args) == 2 && args[0] == "health" && args[1] == "youtube" {
return healthYoutube(stdout, stderr, player)
}
if len(args) >= 2 && args[0] == "recover" && args[1] == "googlevideo" {
return recoverGooglevideo(args[2:], stdout, stderr, player, runBlockcheck, runCombinedBlockcheckForHost)
}
if len(args) >= 2 && args[0] == "tune" && args[1] == "googlevideo" {
return tuneGooglevideo(args[2:], stdout, stderr, player, runBlockcheck, runCombinedBlockcheckForHost)
}
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" {
return discoverYoutube(args[2:], stdout, stderr, player)
}
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
}