Open cou929 opened 2 years ago
I encountered a situation where the video cannot play with the following error.
Domain: XCDYouTubeVideoErrorDomain Code: -2 User Info: { }
It seems that sometimes YouTube returns some pattern of HTML that makes the parser fails.
videoInfo
ytInitialPlayerResponse = {...}
};
<script nonce="tZD2YtPt7fxsKqPJwe7GAw">var ytInitialPlayerResponse = { ... // This "privateDoNotAccessOrElseSafeScriptWrappedValue" key contains the JavaScript source code which contains `};` "privateDoNotAccessOrElseSafeScriptWrappedValue": "(function(){function u(x){return x}var X=this||self,C=function(x,O,W,R,J){if(R=(J=X.trustedTypes,W),!J||!J.createPolicy)return R;try{R=J.createPolicy(O,{createHTML:y,createScript:y,createScriptURL:y})}catch(z){if(X.console)X.console[x](z.message)}return R},y=function(x){return u.call(this,x)}; ...", ... }}}};var meta = document.createElement('meta'); meta.name = 'referrer'; meta.content = 'origin-when-cross-origin'; document.getElementsByTagName('head')[0].appendChild(meta);</script>
Is there anybody who encountered the same issue? How do we fix this problem?
I encountered a situation where the video cannot play with the following error.
It seems that sometimes YouTube returns some pattern of HTML that makes the parser fails.
videoInfo
from YouTube's HTML, find a string that matchesytInitialPlayerResponse = {...}
by using this regex and deserialize it to json};
inside JSON, which makes it fail to deserializeIs there anybody who encountered the same issue? How do we fix this problem?