Closed kawulogustidev closed 4 years ago
I have the same problem. Error While getting Youtube Data : com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 101601 path $.args.player_response
same problem Error While getting Youtube Data : com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 96226 path $.args.player_response
The error is on the following code: private String parsePlayerConfig(String body) throws ExtractorException {
Log.d("=>=", "parsePlayerConfig: "+ RegexUtils.matchGroup(regexPageLink, body,"logd u streem"));
if (Utils.isListContain(reasonUnavialable, RegexUtils.matchGroup(regexPageLink, body,"parseplayer if"))) {
throw new ExtractorException(RegexUtils.matchGroup(regexPageLink, body,"parse player if true"));
}
if (body.contains("ytplayer.config")) {
return RegexUtils.matchGroup(regexPlayerJson, body,"u strem body contain if");
} else {
throw new ExtractorException("This Video is unavialable");
}
}
private PlayerResponse parseJson(String body) throws Exception { JsonParser parser = new JsonParser(); LogUtils.log("Body: "+body); response = new GsonBuilder().serializeNulls().create().fromJson(parser.parse(body), Response.class); return new GsonBuilder().serializeNulls().create().fromJson(response.getArgs().getPlayerResponse(), PlayerResponse.class); }
Someone will help us !
I think this has to do with captcha needed for streaming video because of youtube's new policy
Yeah, same issue here, anybody got a fix for it?
I found some revised yesterday in something similar to this project. I'm leaving a link as I think this can help with the correction.
https://github.com/sealedtx/java-youtube-downloader/commit/4a98b11b3ed2fc98e93117929dedf63489c2ecb9
change String regexPlayerJson="(?<=ytplayer.config\s=).?((\}(\n|)\}(\n|))|(\}))(?=;)"; to String regexPlayerJson="(?<=ytplayer.config\s=).?((\}(\n|)\}(\n|))|(\}))(?=;ytplayer)";
in YoutubeStreamExtractor.java. It worked for me.
Another alternative, use https://github.com/sealedtx/java-youtube-downloader, then use the code to the Extractor. It also worked for me.
Sorry for no updates.. im busy in exams nowadays... If you find a fix that's good else ill fix myself in next 2 days..
@krathore01 The following error appears https://ibb.co/J7zT5bm
@krathore01 The following error appears https://ibb.co/J7zT5bm
use this (?<=ytplayer.config\s=).?((}(\n|)}(\n|))|(}))(?=;ytplayer)
Sorry for no updates.. im busy in exams nowadays... If you find a fix that's good else ill fix myself in next 2 days Please solve this ASAP
It doesn't work even if I change it like below String regexPlayerJson="(?<=ytplayer.config\s=).?((\}(\n|)\}(\n|))|(\}))(?=;ytplayer)"; ㅠ_ㅠ
@yyms3275
When I try this, it works.
String regexPlayerJson="(?<=ytplayer.config\s=).*?((\}(\n|)\}(\n|))|(\}))(?=;ytplayer)";
@hhyeok1026
감사합니다. 다시해보니 잘되네요 ^^ (Thank you. Trying again, it works well ^^)
Hello, I receive an error using the latest code. I think, Youtube has made some changes to the player response json.
Error While getting Youtube Data:com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 121677 path $.args.player_response
The error is on the following code:
private PlayerResponse parseJson(String body) throws Exception { JsonParser parser = new JsonParser(); LogUtils.log("Body: "+body); response = new GsonBuilder().serializeNulls().create().fromJson(parser.parse(body), Response.class); return new GsonBuilder().serializeNulls().create().fromJson(response.getArgs().getPlayerResponse(), PlayerResponse.class); }
I guess there is need some changes on regex pattern.