use of com.grack.nanojson.JsonParserException in project NewPipeExtractor by TeamNewPipe.
the class PeertubeInstance method fetchInstanceMetaData.
public void fetchInstanceMetaData() throws Exception {
Downloader downloader = NewPipe.getDownloader();
Response response = null;
try {
response = downloader.get(url + "/api/v1/config");
} catch (ReCaptchaException | IOException e) {
throw new Exception("unable to configure instance " + url, e);
}
if (response == null || Utils.isBlank(response.responseBody())) {
throw new Exception("unable to configure instance " + url);
}
try {
JsonObject json = JsonParser.object().from(response.responseBody());
this.name = JsonUtils.getString(json, "instance.name");
} catch (JsonParserException | ParsingException e) {
throw new Exception("unable to parse instance config", e);
}
}
use of com.grack.nanojson.JsonParserException in project NewPipeExtractor by TeamNewPipe.
the class PeertubePlaylistExtractor method onFetchPage.
@Override
public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException {
final Response response = downloader.get(getUrl());
try {
playlistInfo = JsonParser.object().from(response.responseBody());
} catch (JsonParserException jpe) {
throw new ExtractionException("Could not parse json", jpe);
}
PeertubeParsingHelper.validate(playlistInfo);
}
use of com.grack.nanojson.JsonParserException in project NewPipeExtractor by TeamNewPipe.
the class BandcampPlaylistExtractor method onFetchPage.
@Override
public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException {
final String html = downloader.get(getLinkHandler().getUrl()).responseBody();
document = Jsoup.parse(html);
albumJson = getAlbumInfoJson(html);
trackInfo = albumJson.getArray("trackinfo");
try {
name = getJsonData(html, "data-embed").getString("album_title");
} catch (final JsonParserException e) {
throw new ParsingException("Faulty JSON; page likely does not contain album data", e);
} catch (final ArrayIndexOutOfBoundsException e) {
throw new ParsingException("JSON does not exist", e);
}
if (trackInfo.size() <= 0) {
// Albums without trackInfo need to be purchased before they can be played
throw new ContentNotAvailableException("Album needs to be purchased");
}
}
use of com.grack.nanojson.JsonParserException in project NewPipeExtractor by TeamNewPipe.
the class MediaCCCSearchExtractor method onFetchPage.
@Override
public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException {
if (getLinkHandler().getContentFilters().contains(EVENTS) || getLinkHandler().getContentFilters().contains(ALL) || getLinkHandler().getContentFilters().isEmpty()) {
final String site;
final String url = getUrl();
site = downloader.get(url, getExtractorLocalization()).responseBody();
try {
doc = JsonParser.object().from(site);
} catch (JsonParserException jpe) {
throw new ExtractionException("Could not parse JSON.", jpe);
}
}
if (getLinkHandler().getContentFilters().contains(CONFERENCES) || getLinkHandler().getContentFilters().contains(ALL) || getLinkHandler().getContentFilters().isEmpty()) {
conferenceKiosk.fetchPage();
}
}
use of com.grack.nanojson.JsonParserException in project NewPipeExtractor by TeamNewPipe.
the class MediaCCCStreamExtractor method onFetchPage.
@Override
public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException {
final String videoUrl = MediaCCCStreamLinkHandlerFactory.VIDEO_API_ENDPOINT + getId();
try {
data = JsonParser.object().from(downloader.get(videoUrl).responseBody());
conferenceData = JsonParser.object().from(downloader.get(data.getString("conference_url")).responseBody());
} catch (JsonParserException jpe) {
throw new ExtractionException("Could not parse json returned by url: " + videoUrl, jpe);
}
}
Aggregations