Update regex expressions to handle unexpected '};'#1953
Update regex expressions to handle unexpected '};'#1953TheFrenchGhosty merged 1 commit intoiv-org:masterfrom
Conversation
| 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) |
There was a problem hiding this comment.
I have noticed that this extra javascript (var meta = ...) is not always present in the script.
I can't tell what triggers it (I've tried multiple combinations of URL arguments, with no luck).
There was a problem hiding this comment.
Huh that's strange. Its always been present on my end.
saltycrys
left a comment
There was a problem hiding this comment.
The most robust way to handle this would be to put a full JSON parser in there so only the starting point needs to be found. That would be terrible for performance probably.
But as long as this works that's not necessary.
Or, as proposed in #1981, find a direct API providing the required |
That is fantastic! @TheFrenchGhosty put some bounties on that please. |
|
|
|
Merged. @syeopite to receive your reward either send your BTC address in a comment (preferred), or contact us directly, with a proof that this is indeed you. |
|
bc1qpgyc5hkcwg4l4a28j274g4tufym07e0as7pwwk |
|
A 20$ bounty has been rewarded to @syeopite for this PR. Transaction (caa3a36040c086642a0262048f95b0c5d84009e87ddc34acf65b6928895f3fdb): Amount sent: 0.000405221 BTC (~16.46€ or ~20$) Mining fees (10 sat/byte): 0.0000481 BTC (~1.95€) |
Fixes: #1673
I want to be awarded the bounty associated to the issue this PR is fixing.
Tested with the following ids:
Details
O4r9D2jI0_w
VQOdmckqNro
3AF3sYnvj5o
BFlF9gGnyro
BUU7WFd8XLU
channel/UCRZY6MGMG1Fmzt50rYalTwQ
I wasn't able to reproduce the error in any of the videos linked in duplicate issues. However, this does fix the error in the original video and any other content with "};".