throw content not available
This commit is contained in:
parent
22dac63698
commit
e66d188381
2 changed files with 13 additions and 0 deletions
|
@ -4,8 +4,12 @@ import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.jsoup.helper.StringUtil;
|
||||||
|
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
|
||||||
|
import com.grack.nanojson.JsonObject;
|
||||||
|
|
||||||
public class PeertubeParsingHelper {
|
public class PeertubeParsingHelper {
|
||||||
|
|
||||||
private PeertubeParsingHelper() {
|
private PeertubeParsingHelper() {
|
||||||
|
@ -20,4 +24,11 @@ public class PeertubeParsingHelper {
|
||||||
throw new ParsingException(e.getMessage(), e);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
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.StreamInfoItem;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||||
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
||||||
|
@ -119,6 +120,7 @@ public class PeertubeChannelExtractor extends ChannelExtractor {
|
||||||
|
|
||||||
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
|
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
|
||||||
if(json != null) {
|
if(json != null) {
|
||||||
|
PeertubeParsingHelper.validate(json);
|
||||||
Number number = JsonUtils.getNumber(json, "total");
|
Number number = JsonUtils.getNumber(json, "total");
|
||||||
if(number != null) this.total = number.longValue();
|
if(number != null) this.total = number.longValue();
|
||||||
collectStreamsFrom(collector, json, pageUrl);
|
collectStreamsFrom(collector, json, pageUrl);
|
||||||
|
|
Loading…
Reference in a new issue