Revert "[media.ccc.de] Get conference name from API URL"

This reverts commit d1a0686d2f.
This commit is contained in:
TobiGr 2020-12-26 13:15:03 +01:00
parent d1a0686d2f
commit 0cfefe222a
2 changed files with 5 additions and 41 deletions

View File

@ -4,7 +4,6 @@ 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.Page;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.downloader.Downloader;
@ -15,16 +14,12 @@ import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import java.io.IOException;
public class MediaCCCRecentKiosk extends KioskExtractor<StreamInfoItem> {
private JsonObject doc;
private final Map<String, String> conferenceNames = new HashMap<>();
public MediaCCCRecentKiosk(StreamingService streamingService, ListLinkHandler linkHandler, String kioskId) {
super(streamingService, linkHandler, kioskId);
@ -46,9 +41,8 @@ public class MediaCCCRecentKiosk extends KioskExtractor<StreamInfoItem> {
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
final JsonArray events = doc.getArray("events");
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
for (int i = 0; i < events.size(); i++) {
collector.commit(new MediaCCCRecentKioskExtractor(events.getObject(i), conferenceNames));
collector.commit(new MediaCCCRecentKioskExtractor(events.getObject(i)));
}
return new InfoItemsPage<>(collector, null);
}

View File

@ -1,34 +1,22 @@
package org.schabi.newpipe.extractor.services.media_ccc.extractors;
import com.grack.nanojson.JsonObject;
import org.schabi.newpipe.extractor.ServiceList;
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.localization.DateWrapper;
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferenceLinkHandlerFactory;
import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor;
import org.schabi.newpipe.extractor.stream.StreamType;
import java.io.IOException;
import javax.annotation.Nullable;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
import javax.annotation.Nullable;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class MediaCCCRecentKioskExtractor implements StreamInfoItemExtractor {
private final JsonObject event;
private final Map<String, String> conferenceNames;
public MediaCCCRecentKioskExtractor(final JsonObject event,
final Map<String, String> conferenceNames) {
public MediaCCCRecentKioskExtractor(final JsonObject event) {
this.event = event;
this.conferenceNames = conferenceNames;
}
@Override
@ -68,25 +56,7 @@ public class MediaCCCRecentKioskExtractor implements StreamInfoItemExtractor {
@Override
public String getUploaderName() throws ParsingException {
final String conferenceApiUrl = event.getString("conference_url");
if (isNullOrEmpty(conferenceApiUrl)) {
throw new ParsingException("conference url is empty");
}
if (conferenceNames.containsKey(conferenceApiUrl)) {
return conferenceNames.get(conferenceApiUrl);
}
// get conference name from API.
try {
ChannelExtractor extractor = ServiceList.MediaCCC.getChannelExtractor(
new MediaCCCConferenceLinkHandlerFactory().fromUrl(conferenceApiUrl));
extractor.fetchPage();
conferenceNames.put(conferenceApiUrl, extractor.getName());
return extractor.getName();
} catch (IOException | ExtractionException e) {
throw new ParsingException("Could not get conference name from conference API URL", e);
}
return "";
}
@Override