mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-06 12:48:29 +00:00
Fix ytInitialData parsing
For some reason Ruby and Crystal add PCRE_DOTALL to the "m" flag which
is supposed to be PCRE_MULTILINE. I guess that makes sense, but it's
nonstandard and I had to read the Crystal source to figure it out.
See 4c88b8b69b/src/regex/regex.cr (L10)
This commit is contained in:
parent
aeed7deb2d
commit
a4f923839a
@ -597,7 +597,7 @@ def create_notification_stream(env, topics, connection_channel)
|
||||
end
|
||||
|
||||
def extract_initial_data(body) : Hash(String, JSON::Any)
|
||||
initial_data = body.match(/(window\["ytInitialData"\]|var\s+ytInitialData)\s*=\s*(?<info>.*?);+\s*\n/).try &.["info"] || "{}"
|
||||
initial_data = body.match(/(window\["ytInitialData"\]|var\s+ytInitialData)\s*=\s*(?<info>.*?);+(\s*\n|<\/script>)/m).try &.["info"] || "{}"
|
||||
if initial_data.starts_with?("JSON.parse(\"")
|
||||
return JSON.parse(JSON.parse(%({"initial_data":"#{initial_data[12..-3]}"}))["initial_data"].as_s).as_h
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user