diff options
| author | TheFrenchGhosty <47571719+TheFrenchGhosty@users.noreply.github.com> | 2020-12-03 23:31:39 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-03 23:31:39 +0000 |
| commit | 76cad4138219bc57ffc771e1b5eee5437b51aca6 (patch) | |
| tree | 58eb8d0f6350be16435225acc88994afd73cd0a3 /src | |
| parent | 501db8f27678d61b7c810d65e124e96b9e38565f (diff) | |
| parent | 7823c07f1aea70828f0eb9244b961d90abb5d23f (diff) | |
| download | invidious-76cad4138219bc57ffc771e1b5eee5437b51aca6.tar.gz invidious-76cad4138219bc57ffc771e1b5eee5437b51aca6.tar.bz2 invidious-76cad4138219bc57ffc771e1b5eee5437b51aca6.zip | |
Merge pull request #1525 from saltycrys/fix-video-descriptions
Fix `extract_polymer_config`
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/videos.cr | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 8b20c181..edbff14e 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -816,7 +816,7 @@ end def extract_polymer_config(body) params = {} of String => JSON::Any - player_response = body.match(/window\["ytInitialPlayerResponse"\]\s*=\s*(?<info>.*?);\n/) + player_response = body.match(/(window\["ytInitialPlayerResponse"\]|var\sytInitialPlayerResponse)\s*=\s*(?<info>{.*?});/m) .try { |r| JSON.parse(r["info"]).as_h } if body.includes?("To continue with your YouTube experience, please fill out the form below.") || @@ -914,10 +914,14 @@ def extract_polymer_config(body) .try { |r| JSON.parse(r["info"]) }.try &.["args"]["player_response"]? .try &.as_s?.try &.try { |r| JSON.parse(r).as_h } - return params if !initial_data - - {"playabilityStatus", "streamingData"}.each do |f| - params[f] = initial_data[f] if initial_data[f]? + if initial_data + {"playabilityStatus", "streamingData"}.each do |f| + params[f] = initial_data[f] if initial_data[f]? + end + else + {"playabilityStatus", "streamingData"}.each do |f| + params[f] = player_response[f] if player_response[f]? + end end params |
