feat(tune): add proposal-only Googlevideo scans
Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
1 parent
7fad9b3b5c
commit
6220eb0b31
10 files changed
+638
-27
No files matched your search
@@ -103,17 +103,25 @@ func playerHostname(body []byte) (string, error) {
|
||||
return host, nil
|
||||
}
|
||||
|
||||
func discoverYoutube(args []string, stdout, stderr io.Writer, runner playerRunner) int {
|
||||
func discoveryFlags(args []string) (string, string, error) {
|
||||
flags := flag.NewFlagSet("discover youtube", flag.ContinueOnError)
|
||||
flags.SetOutput(io.Discard) // flag errors can contain untrusted arguments.
|
||||
videoID := flags.String("video-id", "", "")
|
||||
proxy := flags.String("proxy", "", "")
|
||||
if flags.Parse(args) != nil || flags.NArg() != 0 || !videoIDPattern.MatchString(*videoID) || !validDiscoveryProxy(*proxy) {
|
||||
fmt.Fprintln(stderr, "error: discover youtube requires --video-id (11 characters) and --proxy socks5://HOST:PORT without credentials")
|
||||
return "", "", errors.New("requires --video-id (11 characters) and --proxy socks5://HOST:PORT without credentials")
|
||||
}
|
||||
return *videoID, *proxy, nil
|
||||
}
|
||||
|
||||
func discoverYoutube(args []string, stdout, stderr io.Writer, runner playerRunner) int {
|
||||
videoID, proxy, err := discoveryFlags(args)
|
||||
if err != nil {
|
||||
fmt.Fprintln(stderr, "error: discover youtube", err)
|
||||
return 2
|
||||
}
|
||||
payload, _ := json.Marshal(map[string]interface{}{
|
||||
"videoId": *videoID,
|
||||
"videoId": videoID,
|
||||
"context": map[string]interface{}{"client": map[string]interface{}{
|
||||
"clientName": "ANDROID", "clientVersion": "21.02.35", "androidSdkVersion": 30,
|
||||
"userAgent": playerUserAgent, "osName": "Android", "osVersion": "11",
|
||||
@@ -125,8 +133,8 @@ func discoverYoutube(args []string, stdout, stderr io.Writer, runner playerRunne
|
||||
output := &playerBoundedWriter{dst: &body, limit: playerResponseLimit}
|
||||
diagnostics := &playerBoundedWriter{dst: io.Discard, limit: 64 << 10}
|
||||
// Disable curlrc and NO_PROXY bypasses: the explicit proxy must be used.
|
||||
err := runner(ctx, []string{"--disable", "--silent", "--show-error", "--fail", "--max-time", "30",
|
||||
"--noproxy", "", "--proxy", *proxy, "--user-agent", playerUserAgent, "--json", string(payload), playerURL}, output, diagnostics)
|
||||
err = runner(ctx, []string{"--disable", "--silent", "--show-error", "--fail", "--max-time", "30",
|
||||
"--noproxy", "", "--proxy", proxy, "--user-agent", playerUserAgent, "--json", string(payload), playerURL}, output, diagnostics)
|
||||
if err != nil || output.exceeded || diagnostics.exceeded {
|
||||
fmt.Fprintln(stderr, "error: player request failed or exceeded output limit")
|
||||
return 1
|
||||
@@ -139,7 +147,7 @@ func discoverYoutube(args []string, stdout, stderr io.Writer, runner playerRunne
|
||||
result := struct {
|
||||
VideoID string `json:"videoId"`
|
||||
Hostnames []string `json:"hostnames"`
|
||||
}{*videoID, []string{host}}
|
||||
}{videoID, []string{host}}
|
||||
if json.NewEncoder(stdout).Encode(result) != nil {
|
||||
fmt.Fprintln(stderr, "error: cannot write discovery result")
|
||||
return 1
|
||||
|
||||
Reference in new issue
Block a user