Closed FilX closed 6 years ago
I'm getting the same error on any video:
Newtonsoft.Json.JsonReaderException: Additional text encountered after finished reading JSON content: }. Path '', line 1, position 14836.
at Newtonsoft.Json.JsonTextReader.Read()
at Newtonsoft.Json.Linq.JToken.Parse(String json, JsonLoadSettings settings)
at YoutubeExplode.YoutubeClient.GetVideoEmbedPageConfigAsync(String videoId) in d:\Code\Git\YoutubeExplode\YoutubeExplode\YoutubeClient.Video.cs:line 34
at YoutubeExplode.YoutubeClient.GetVideoPlayerContextAsync(String videoId) in d:\Code\Git\YoutubeExplode\YoutubeExplode\YoutubeClient.Video.cs:line 88
at YoutubeExplode.YoutubeClient.GetVideoMediaStreamInfosAsync(String videoId) in d:\Code\Git\YoutubeExplode\YoutubeExplode\YoutubeClient.Video.cs:line 264
Looks like they've changed the encoding or something like that.
var part = raw.SubstringAfter("yt.setConfig({'PLAYER_CONFIG': ").SubstringUntil(",'");
this part no longer works.
Changing to:
var part = raw.SubstringAfter("yt.setConfig({'PLAYER_CONFIG': ").SubstringUntil("});writeEmbed();");
it started working for me. Haven't tried on other videos. Works on all videos I've tried.
Edit: @FilX lol haven't noticed that you already fixed it.
Newtonsoft.Json.JsonReaderException: 'Additional text encountered after finished reading JSON content: }. Path '', line 1, position 14816.'
Video ID: wFQqbXk4W8Y and all other
It seems that youtube changed site content.
YoutubeClient.GetVideoEmbedPageConfigAsync cannot find expected string .SubstringUntil(",'");
Possible fix:
Instead
var part = raw.SubstringAfter("yt.setConfig({'PLAYER_CONFIG': ").SubstringUntil(",'");
use
var part = raw.SubstringAfter("yt.setConfig({'PLAYER_CONFIG': ").SubstringUntil("});writeEmbed()");