mirror of
https://gitea.invidious.io/iv-org/invidious.git
synced 2024-08-15 00:53:41 +00:00
fix: ytInitialData parsing with regex
This commit is contained in:
parent
1973f93d4a
commit
480d31eb5e
1 changed files with 1 additions and 6 deletions
|
@ -598,12 +598,7 @@ def create_notification_stream(env, topics, connection_channel)
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_initial_data(body) : Hash(String, JSON::Any)
|
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"] || "{}"
|
return JSON.parse(body.match(/(window\["ytInitialData"\]|var\s*ytInitialData)\s*=\s*(?<info>\{.*?\});/).try &.["info"] || "{}").as_h
|
||||||
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
|
|
||||||
return JSON.parse(initial_data).as_h
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def proxy_file(response, env)
|
def proxy_file(response, env)
|
||||||
|
|
Loading…
Reference in a new issue