fix: use IPv4 for YouTube playback extraction
The default route returned a YouTube anti-bot challenge; the same bundled extractor and media URLs work over IPv4 without cookies. Limit the route choice to canonical YouTube videos so generic sites keep their existing routing.
This commit is contained in:
@@ -245,7 +245,7 @@ enum YouTubeResolver {
|
||||
environment["PATH"] = directories.joined(separator: ":")
|
||||
let transport = "[protocol~='^(https?|m3u8(_native)?)$']"
|
||||
let resolution = height.map { "[height=\($0)]" } ?? "[height<=?1080]"
|
||||
let arguments = [
|
||||
var arguments = [
|
||||
"--ignore-config", "--no-plugin-dirs", "--no-cache-dir", "--no-remote-components",
|
||||
"--no-playlist", "--simulate", "--skip-download", "--dump-single-json",
|
||||
"--no-progress", "--color", "never", "--no-check-formats",
|
||||
@@ -253,8 +253,12 @@ enum YouTubeResolver {
|
||||
"--socket-timeout", "20", "--extractor-retries", "0", "--retries", "0",
|
||||
"--format-sort", "res", "--format-sort-force",
|
||||
"--format", "bestvideo*[dynamic_range=?SDR]\(resolution)\(transport)+bestaudio\(transport)/best[dynamic_range=?SDR]\(resolution)\(transport)",
|
||||
"--", webpageURL.absoluteString
|
||||
]
|
||||
if webpageURL.host == "www.youtube.com" {
|
||||
arguments.append("--force-ipv4")
|
||||
}
|
||||
arguments.append("--")
|
||||
arguments.append(webpageURL.absoluteString)
|
||||
let output = try await YouTubeExtraction(executable: executable, arguments: arguments, environment: environment).run()
|
||||
try Task.checkCancellation()
|
||||
if let error = dependencyError(String(decoding: output.stderr, as: UTF8.self).lowercased()) {
|
||||
|
||||
Reference in New Issue
Block a user