summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsyeopite <syeopite@syeopite.dev>2021-03-29 17:37:12 -0700
committersyeopite <syeopite@syeopite.dev>2021-03-29 17:37:12 -0700
commit608313c1d1e0f5ec9b4ce9b1d6303f03530656d8 (patch)
treed901702e60f25a7c154eec040d6b4ecdd99ac5bc
parent2c1cf42994eaa47e8f6a8dd991fe6d85cce7693c (diff)
downloadinvidious-608313c1d1e0f5ec9b4ce9b1d6303f03530656d8.tar.gz
invidious-608313c1d1e0f5ec9b4ce9b1d6303f03530656d8.tar.bz2
invidious-608313c1d1e0f5ec9b4ce9b1d6303f03530656d8.zip
Update regex expressions to handle unexpected '};'
-rw-r--r--src/invidious/helpers/helpers.cr2
-rw-r--r--src/invidious/videos.cr2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr
index 5d127e1a..5e49afb7 100644
--- a/src/invidious/helpers/helpers.cr
+++ b/src/invidious/helpers/helpers.cr
@@ -678,7 +678,7 @@ def create_notification_stream(env, topics, connection_channel)
end
def extract_initial_data(body) : Hash(String, JSON::Any)
- return JSON.parse(body.match(/(window\["ytInitialData"\]|var\s*ytInitialData)\s*=\s*(?<info>\{.*?\});/mx).try &.["info"] || "{}").as_h
+ return JSON.parse(body.match(/(window\["ytInitialData"\]|var\s*ytInitialData)\s*=\s*(?<info>{.*?});<\/script>/mx).try &.["info"] || "{}").as_h
end
def proxy_file(response, env)
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index e6d4c764..2b793a1b 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -818,7 +818,7 @@ end
def extract_polymer_config(body)
params = {} of String => JSON::Any
- player_response = body.match(/(window\["ytInitialPlayerResponse"\]|var\sytInitialPlayerResponse)\s*=\s*(?<info>{.*?});/m)
+ player_response = body.match(/(window\["ytInitialPlayerResponse"\]|var\sytInitialPlayerResponse)\s*=\s*(?<info>{.*?});\s*var\s*meta/m)
.try { |r| JSON.parse(r["info"]).as_h }
if body.includes?("To continue with your YouTube experience, please fill out the form below.") ||