113 lines
3.2 KiB
Java
113 lines
3.2 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.StreamingService;
|
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
|
import org.schabi.newpipe.extractor.downloader.Downloader;
|
|
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.media_ccc.extractors.infoItems.MediaCCCStreamInfoItemExtractor;
|
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
|
|
|
import java.io.IOException;
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
public class MediaCCCConferenceExtractor extends ChannelExtractor {
|
|
private JsonObject conferenceData;
|
|
|
|
public MediaCCCConferenceExtractor(final StreamingService service,
|
|
final ListLinkHandler linkHandler) {
|
|
super(service, linkHandler);
|
|
}
|
|
|
|
@Override
|
|
public String getAvatarUrl() {
|
|
return conferenceData.getString("logo_url");
|
|
}
|
|
|
|
@Override
|
|
public String getBannerUrl() {
|
|
return conferenceData.getString("logo_url");
|
|
}
|
|
|
|
@Override
|
|
public String getFeedUrl() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public long getSubscriberCount() {
|
|
return -1;
|
|
}
|
|
|
|
@Override
|
|
public String getDescription() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public String getParentChannelName() throws ParsingException {
|
|
return "";
|
|
}
|
|
|
|
@Override
|
|
public String getParentChannelUrl() throws ParsingException {
|
|
return "";
|
|
}
|
|
|
|
@Override
|
|
public String getParentChannelAvatarUrl() throws ParsingException {
|
|
return "";
|
|
}
|
|
|
|
@Nonnull
|
|
@Override
|
|
public InfoItemsPage<StreamInfoItem> getInitialPage() {
|
|
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
|
|
JsonArray events = conferenceData.getArray("events");
|
|
for (int i = 0; i < events.size(); i++) {
|
|
collector.commit(new MediaCCCStreamInfoItemExtractor(events.getObject(i)));
|
|
}
|
|
return new InfoItemsPage<>(collector, null);
|
|
}
|
|
|
|
@Override
|
|
public String getNextPageUrl() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public InfoItemsPage<StreamInfoItem> getPage(final String pageUrl) {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void onFetchPage(@Nonnull final Downloader downloader)
|
|
throws IOException, ExtractionException {
|
|
try {
|
|
conferenceData = JsonParser.object().from(downloader.get(getUrl()).responseBody());
|
|
} catch (JsonParserException jpe) {
|
|
throw new ExtractionException("Could not parse json returnd by url: " + getUrl());
|
|
}
|
|
}
|
|
|
|
@Nonnull
|
|
@Override
|
|
public String getName() throws ParsingException {
|
|
return conferenceData.getString("title");
|
|
}
|
|
|
|
@Nonnull
|
|
@Override
|
|
public String getOriginalUrl() {
|
|
return "https://media.ccc.de/c/" + conferenceData.getString("acronym");
|
|
}
|
|
}
|