From 7f8349d4b13b371821f73839bf9bf2edff2d5b15 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sat, 5 Jan 2019 15:23:22 -0600 Subject: [PATCH] Escape function names in signature extractor --- src/invidious/signatures.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/invidious/signatures.cr b/src/invidious/signatures.cr index eaf919021..b2ed89d26 100644 --- a/src/invidious/signatures.cr +++ b/src/invidious/signatures.cr @@ -1,15 +1,15 @@ def fetch_decrypt_function(id = "CvFH_6DNRCY") client = make_client(YT_URL) - document = client.get("/watch?v=#{id}").body - url = document.match(/src="(?\/yts\/jsbin\/player-.{9}\/en_US\/base.js)"/).not_nil!["url"] + document = client.get("/watch?v=#{id}&gl=US&hl=en&disable_polymer=1").body + url = document.match(/src="(?\/yts\/jsbin\/player_ias-.{9}\/en_US\/base.js)"/).not_nil!["url"] player = client.get(url).body function_name = player.match(/^(?[^=]+)=function\(a\){a=a\.split\(""\)/m).not_nil!["name"] - function_body = player.match(/^#{function_name}=function\(a\){(?[^}]+)}/m).not_nil!["body"] + function_body = player.match(/^#{Regex.escape(function_name)}=function\(a\){(?[^}]+)}/m).not_nil!["body"] function_body = function_body.split(";")[1..-2] var_name = function_body[0][0, 2] - var_body = player.delete("\n").match(/var #{var_name}={(?(.*?))};/).not_nil!["body"] + var_body = player.delete("\n").match(/var #{Regex.escape(var_name)}={(?(.*?))};/).not_nil!["body"] operations = {} of String => String var_body.split("},").each do |operation|