summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsyeopite <syeopite@syeopite.dev>2021-06-25 12:14:21 -0700
committersyeopite <syeopite@syeopite.dev>2021-06-25 12:14:21 -0700
commit7da0b2fd7fb977eb9e5f790e63e93b9bde0c9768 (patch)
tree206670106efeaacec5c8196865b8ff936bed18ef /src
parentaa55e67389ac8c3786c5e0ac4dca3d50f2193e16 (diff)
downloadinvidious-7da0b2fd7fb977eb9e5f790e63e93b9bde0c9768.tar.gz
invidious-7da0b2fd7fb977eb9e5f790e63e93b9bde0c9768.tar.bz2
invidious-7da0b2fd7fb977eb9e5f790e63e93b9bde0c9768.zip
Switch from URI::Params.new to URI::Params.encode
Diffstat (limited to 'src')
-rw-r--r--src/invidious/videos.cr21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index 5b2158ec..264a70e8 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -989,15 +989,22 @@ def fetch_video(id, region)
# Try to pull streams from embed URL
if info["reason"]?
- required_parameters = URI::Params.new({
- "video_id" => [id],
- "eurl" => ["https://youtube.googleapis.com/v/#{id}"],
- "html5" => ["1"],
- "c" => ["TVHTML5"],
- "cver" => ["6.20180913"],
+ # The html5, c and cver parameters are required in order to extract age-restricted videos
+ # See https://github.com/yt-dlp/yt-dlp/commit/4e6767b5f2e2523ebd3dd1240584ead53e8c8905
+ required_parameters = URI::Params.encode({
+ "video_id" => id,
+ "eurl" => "https://youtube.googleapis.com/v/#{id}",
+ "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"]?
player_response = JSON.parse(embed_info["player_response"])