68 lines
2.4 KiB
Java
68 lines
2.4 KiB
Java
|
package org.schabi.newpipe.extractor.services.media_ccc.extractors;
|
||
|
|
||
|
import com.grack.nanojson.JsonArray;
|
||
|
import com.grack.nanojson.JsonObject;
|
||
|
import com.grack.nanojson.JsonParser;
|
||
|
import com.grack.nanojson.JsonParserException;
|
||
|
import org.schabi.newpipe.extractor.Downloader;
|
||
|
import org.schabi.newpipe.extractor.InfoItem;
|
||
|
import org.schabi.newpipe.extractor.InfoItemsCollector;
|
||
|
import org.schabi.newpipe.extractor.StreamingService;
|
||
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||
|
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
|
||
|
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||
|
import org.schabi.newpipe.extractor.services.media_ccc.extractors.infoItems.MediaCCCStreamInfoItemExtractor;
|
||
|
import org.schabi.newpipe.extractor.utils.Localization;
|
||
|
|
||
|
import javax.annotation.Nonnull;
|
||
|
import java.io.IOException;
|
||
|
|
||
|
public class MediaCCCSearchExtractor extends SearchExtractor {
|
||
|
|
||
|
JsonObject doc;
|
||
|
|
||
|
public MediaCCCSearchExtractor(StreamingService service, SearchQueryHandler linkHandler, Localization localization) {
|
||
|
super(service, linkHandler, localization);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String getSearchSuggestion() throws ParsingException {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Nonnull
|
||
|
@Override
|
||
|
public InfoItemsPage<InfoItem> getInitialPage() throws IOException, ExtractionException {
|
||
|
InfoItemsCollector searchItems = getInfoItemSearchCollector();
|
||
|
JsonArray events = doc.getArray("events");
|
||
|
for(int i = 0; i < events.size(); i++) {
|
||
|
searchItems.commit(new MediaCCCStreamInfoItemExtractor(
|
||
|
events.getObject(i)));
|
||
|
}
|
||
|
return new InfoItemsPage<>(searchItems, null);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String getNextPageUrl() throws IOException, ExtractionException {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public InfoItemsPage<InfoItem> getPage(String pageUrl) throws IOException, ExtractionException {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
|
||
|
final String site;
|
||
|
final String url = getUrl();
|
||
|
site = downloader.download(url, getLocalization());
|
||
|
try {
|
||
|
doc = JsonParser.object().from(site);
|
||
|
} catch (JsonParserException jpe) {
|
||
|
throw new ExtractionException("Could not parse json.", jpe);
|
||
|
}
|
||
|
}
|
||
|
}
|