From 9dbacbc6188d88f540870be8f6b652b3e95ccc2d Mon Sep 17 00:00:00 2001 From: vkay94 Date: Wed, 9 Dec 2020 14:57:38 +0100 Subject: [PATCH] Fix comments parsing --- .../extractors/YoutubeCommentsExtractor.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java index bd2af3c67..6b5a992c8 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java @@ -160,8 +160,15 @@ public class YoutubeCommentsExtractor extends CommentsExtractor { } private String findValue(String doc, String start, String end) { - final int beginIndex = doc.indexOf(start) + start.length(); - final int endIndex = doc.indexOf(end, beginIndex); - return doc.substring(beginIndex, endIndex); + final String unescaped = doc + .replaceAll("\\\\x22", "\"") + .replaceAll("\\\\x7b", "{") + .replaceAll("\\\\x7d", "}") + .replaceAll("\\\\x5b", "[") + .replaceAll("\\\\x5d", "]"); + + final int beginIndex = unescaped.indexOf(start) + start.length(); + final int endIndex = unescaped.indexOf(end, beginIndex); + return unescaped.substring(beginIndex, endIndex); } }