Revert "[media.ccc.de] Get conference name from API URL"
This reverts commit d1a0686d2f
.
This commit is contained in:
parent
d1a0686d2f
commit
0cfefe222a
|
@ -4,7 +4,6 @@ import com.grack.nanojson.JsonArray;
|
||||||
import com.grack.nanojson.JsonObject;
|
import com.grack.nanojson.JsonObject;
|
||||||
import com.grack.nanojson.JsonParser;
|
import com.grack.nanojson.JsonParser;
|
||||||
import com.grack.nanojson.JsonParserException;
|
import com.grack.nanojson.JsonParserException;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.Page;
|
import org.schabi.newpipe.extractor.Page;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.downloader.Downloader;
|
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.StreamInfoItem;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class MediaCCCRecentKiosk extends KioskExtractor<StreamInfoItem> {
|
public class MediaCCCRecentKiosk extends KioskExtractor<StreamInfoItem> {
|
||||||
|
|
||||||
private JsonObject doc;
|
private JsonObject doc;
|
||||||
private final Map<String, String> conferenceNames = new HashMap<>();
|
|
||||||
|
|
||||||
public MediaCCCRecentKiosk(StreamingService streamingService, ListLinkHandler linkHandler, String kioskId) {
|
public MediaCCCRecentKiosk(StreamingService streamingService, ListLinkHandler linkHandler, String kioskId) {
|
||||||
super(streamingService, linkHandler, kioskId);
|
super(streamingService, linkHandler, kioskId);
|
||||||
|
@ -46,9 +41,8 @@ public class MediaCCCRecentKiosk extends KioskExtractor<StreamInfoItem> {
|
||||||
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
|
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
|
||||||
final JsonArray events = doc.getArray("events");
|
final JsonArray events = doc.getArray("events");
|
||||||
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
|
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
|
||||||
|
|
||||||
for (int i = 0; i < events.size(); i++) {
|
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);
|
return new InfoItemsPage<>(collector, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,22 @@
|
||||||
package org.schabi.newpipe.extractor.services.media_ccc.extractors;
|
package org.schabi.newpipe.extractor.services.media_ccc.extractors;
|
||||||
|
|
||||||
import com.grack.nanojson.JsonObject;
|
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.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||||
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferenceLinkHandlerFactory;
|
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferenceLinkHandlerFactory;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||||
|
|
||||||
import java.io.IOException;
|
import javax.annotation.Nullable;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
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 {
|
public class MediaCCCRecentKioskExtractor implements StreamInfoItemExtractor {
|
||||||
|
|
||||||
private final JsonObject event;
|
private final JsonObject event;
|
||||||
private final Map<String, String> conferenceNames;
|
|
||||||
|
|
||||||
public MediaCCCRecentKioskExtractor(final JsonObject event,
|
public MediaCCCRecentKioskExtractor(final JsonObject event) {
|
||||||
final Map<String, String> conferenceNames) {
|
|
||||||
this.event = event;
|
this.event = event;
|
||||||
this.conferenceNames = conferenceNames;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,25 +56,7 @@ public class MediaCCCRecentKioskExtractor implements StreamInfoItemExtractor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderName() throws ParsingException {
|
public String getUploaderName() throws ParsingException {
|
||||||
final String conferenceApiUrl = event.getString("conference_url");
|
return "";
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue