From e66d188381e3de326ec00f69a7b839712d01888a Mon Sep 17 00:00:00 2001 From: Ritvik Saraf <13ritvik@gmail.com> Date: Fri, 8 Mar 2019 04:54:39 +0530 Subject: [PATCH] throw content not available --- .../services/peertube/PeertubeParsingHelper.java | 11 +++++++++++ .../peertube/extractors/PeertubeChannelExtractor.java | 2 ++ 2 files changed, 13 insertions(+) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeParsingHelper.java index b50cede2..68bc66bd 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeParsingHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeParsingHelper.java @@ -4,8 +4,12 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import org.jsoup.helper.StringUtil; +import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import com.grack.nanojson.JsonObject; + public class PeertubeParsingHelper { private PeertubeParsingHelper() { @@ -20,4 +24,11 @@ public class PeertubeParsingHelper { throw new ParsingException(e.getMessage(), e); } } + + public static void validate(JsonObject json) throws ContentNotAvailableException { + String error = json.getString("error"); + if(!StringUtil.isBlank(error)) { + throw new ContentNotAvailableException(error); + } + } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java index 62001025..0c9123b8 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java @@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; +import org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import org.schabi.newpipe.extractor.utils.JsonUtils; @@ -119,6 +120,7 @@ public class PeertubeChannelExtractor extends ChannelExtractor { StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); if(json != null) { + PeertubeParsingHelper.validate(json); Number number = JsonUtils.getNumber(json, "total"); if(number != null) this.total = number.longValue(); collectStreamsFrom(collector, json, pageUrl);