refactor: execute adapter plans through shared core
Execute the private YouTube qualification plan through core-owned scheduling while retaining worker cleanup, proof sealing and legacy policy boundaries. Preserve unsafe collector failures alongside concurrent cancellation or deadlines. Send bounded Player JSON through stdin instead of argv and update all shared runner callers. Generic controller cutover and remote runtime acceptance remain pending. Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
1 parent
f4853173b3
commit
e270810f33
24 files changed
+725
-92
No files matched your search
@@ -24,7 +24,7 @@ const playerResponseLimit = 1 << 20
|
||||
var videoIDPattern = regexp.MustCompile(`^[A-Za-z0-9_-]{11}$`)
|
||||
var discoveryDNSLabel = regexp.MustCompile(`^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$`)
|
||||
|
||||
type playerRunner func(context.Context, []string, io.Writer, io.Writer) error
|
||||
type playerRunner func(context.Context, []string, io.Reader, io.Writer, io.Writer) error
|
||||
|
||||
// Keep request diagnostics private while retaining typed causes for supervision.
|
||||
type playerRequestError struct{ cause error }
|
||||
@@ -32,8 +32,9 @@ type playerRequestError struct{ cause error }
|
||||
func (e *playerRequestError) Error() string { return "player request failed or exceeded output limit" }
|
||||
func (e *playerRequestError) Unwrap() error { return e.cause }
|
||||
|
||||
func runPlayerCurl(ctx context.Context, args []string, stdout, stderr io.Writer) error {
|
||||
func runPlayerCurl(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) error {
|
||||
cmd := exec.CommandContext(ctx, "curl", args...)
|
||||
cmd.Stdin = stdin
|
||||
cmd.Stdout, cmd.Stderr = stdout, stderr
|
||||
return cmd.Run()
|
||||
}
|
||||
@@ -151,6 +152,9 @@ func requestPlayer(videoID, proxy string, runner playerRunner) ([]byte, error) {
|
||||
if _, err := requiredYoutubeAdapter(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !videoIDPattern.MatchString(videoID) {
|
||||
return nil, errors.New("invalid player video ID")
|
||||
}
|
||||
payload, _ := json.Marshal(map[string]interface{}{
|
||||
"videoId": videoID,
|
||||
"context": map[string]interface{}{"client": map[string]interface{}{
|
||||
@@ -164,8 +168,9 @@ func requestPlayer(videoID, proxy string, runner playerRunner) ([]byte, error) {
|
||||
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.
|
||||
// Keep the bounded JSON body off argv; curl retains its JSON POST headers.
|
||||
err := runner(ctx, []string{"--disable", "--silent", "--show-error", "--fail", "--max-time", "30",
|
||||
"--noproxy", "", "--proxy", proxy, "--user-agent", playerUserAgent, "--json", string(payload), playerURL}, output, diagnostics)
|
||||
"--noproxy", "", "--proxy", proxy, "--user-agent", playerUserAgent, "--json", "@-", playerURL}, bytes.NewReader(payload), output, diagnostics)
|
||||
if err != nil || output.exceeded || diagnostics.exceeded {
|
||||
if output.exceeded || diagnostics.exceeded {
|
||||
// An output failure remains unsafe even if the child was also canceled.
|
||||
|
||||
Reference in new issue
Block a user