|
|
@ -597,7 +597,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"\]\s*=\s*(?<info>.*?);+\n/).try &.["info"] || "{}"
|
|
|
|
initial_data = body.match(/(window\["ytInitialData"\]|var\s+ytInitialData)\s*=\s*(?<info>.*?);+\s*\n/).try &.["info"] || "{}"
|
|
|
|
if initial_data.starts_with?("JSON.parse(\"")
|
|
|
|
if initial_data.starts_with?("JSON.parse(\"")
|
|
|
|
return JSON.parse(JSON.parse(%({"initial_data":"#{initial_data[12..-3]}"}))["initial_data"].as_s).as_h
|
|
|
|
return JSON.parse(JSON.parse(%({"initial_data":"#{initial_data[12..-3]}"}))["initial_data"].as_s).as_h
|
|
|
|
else
|
|
|
|
else
|
|
|
|