Switch from URI::Params.new to URI::Params.encode

pull/2205/head
syeopite 3 years ago
parent aa55e67389
commit 7da0b2fd7f
No known key found for this signature in database
GPG Key ID: 6FA616E5A5294A82

@ -989,15 +989,22 @@ def fetch_video(id, region)
# Try to pull streams from embed URL # Try to pull streams from embed URL
if info["reason"]? if info["reason"]?
required_parameters = URI::Params.new({ # The html5, c and cver parameters are required in order to extract age-restricted videos
"video_id" => [id], # See https://github.com/yt-dlp/yt-dlp/commit/4e6767b5f2e2523ebd3dd1240584ead53e8c8905
"eurl" => ["https://youtube.googleapis.com/v/#{id}"], required_parameters = URI::Params.encode({
"html5" => ["1"], "video_id" => id,
"c" => ["TVHTML5"], "eurl" => "https://youtube.googleapis.com/v/#{id}",
"cver" => ["6.20180913"], "html5" => "1",
"c" => "TVHTML5",
"cver" => "6.20180913",
}) })
embed_info = HTTP::Params.parse(YT_POOL.client &.get("/get_video_info?#{required_parameters}", headers: HTTP::Headers{"x-youtube-client-version" => "6.20180913"}).body) # In order to actually extract video info without error, the `x-youtube-client-version` has to be set to the same version as `cver` above.
embed_info = HTTP::Params.parse(YT_POOL.client &.get("/get_video_info?#{required_parameters}",
headers: HTTP::Headers{
"x-youtube-client-version" => "6.20180913",
}).body
)
if embed_info["player_response"]? if embed_info["player_response"]?
player_response = JSON.parse(embed_info["player_response"]) player_response = JSON.parse(embed_info["player_response"])

Loading…
Cancel
Save