mirror of
https://github.com/TeamNewPipe/NewPipeExtractor
synced 2025-09-01 14:55:26 +00:00
[MediaCCC] Fix checkstyle issues
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
package org.schabi.newpipe.extractor.services.media_ccc;
|
package org.schabi.newpipe.extractor.services.media_ccc;
|
||||||
|
|
||||||
|
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO;
|
||||||
|
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.VIDEO;
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||||
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
|
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
|
||||||
import org.schabi.newpipe.extractor.kiosk.KioskList;
|
import org.schabi.newpipe.extractor.kiosk.KioskList;
|
||||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
|
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
|
||||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||||
@@ -14,16 +17,24 @@ import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
|
|||||||
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandlerFactory;
|
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandlerFactory;
|
||||||
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||||
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||||
import org.schabi.newpipe.extractor.services.media_ccc.extractors.*;
|
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceExtractor;
|
||||||
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.*;
|
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceKiosk;
|
||||||
|
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCLiveStreamExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCLiveStreamKiosk;
|
||||||
|
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCParsingHelper;
|
||||||
|
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCRecentKiosk;
|
||||||
|
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCSearchExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferenceLinkHandlerFactory;
|
||||||
|
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferencesListLinkHandlerFactory;
|
||||||
|
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCLiveListLinkHandlerFactory;
|
||||||
|
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCRecentListLinkHandlerFactory;
|
||||||
|
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory;
|
||||||
|
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCStreamLinkHandlerFactory;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||||
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||||
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
|
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO;
|
|
||||||
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.VIDEO;
|
|
||||||
|
|
||||||
public class MediaCCCService extends StreamingService {
|
public class MediaCCCService extends StreamingService {
|
||||||
public MediaCCCService(final int id) {
|
public MediaCCCService(final int id) {
|
||||||
super(id, "media.ccc.de", asList(AUDIO, VIDEO));
|
super(id, "media.ccc.de", asList(AUDIO, VIDEO));
|
||||||
@@ -79,42 +90,42 @@ public class MediaCCCService extends StreamingService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KioskList getKioskList() throws ExtractionException {
|
public KioskList getKioskList() throws ExtractionException {
|
||||||
KioskList list = new KioskList(this);
|
final KioskList list = new KioskList(this);
|
||||||
|
|
||||||
// add kiosks here e.g.:
|
// add kiosks here e.g.:
|
||||||
try {
|
try {
|
||||||
list.addKioskEntry(new KioskList.KioskExtractorFactory() {
|
list.addKioskEntry(
|
||||||
@Override
|
(streamingService, url, kioskId) -> new MediaCCCConferenceKiosk(
|
||||||
public KioskExtractor createNewKiosk(final StreamingService streamingService,
|
MediaCCCService.this,
|
||||||
final String url, final String kioskId)
|
new MediaCCCConferencesListLinkHandlerFactory().fromUrl(url),
|
||||||
throws ExtractionException {
|
kioskId
|
||||||
return new MediaCCCConferenceKiosk(MediaCCCService.this,
|
),
|
||||||
new MediaCCCConferencesListLinkHandlerFactory().fromUrl(url), kioskId);
|
new MediaCCCConferencesListLinkHandlerFactory(),
|
||||||
}
|
"conferences"
|
||||||
}, new MediaCCCConferencesListLinkHandlerFactory(), "conferences");
|
);
|
||||||
|
|
||||||
list.addKioskEntry(new KioskList.KioskExtractorFactory() {
|
list.addKioskEntry(
|
||||||
@Override
|
(streamingService, url, kioskId) -> new MediaCCCRecentKiosk(
|
||||||
public KioskExtractor createNewKiosk(final StreamingService streamingService,
|
MediaCCCService.this,
|
||||||
final String url, final String kioskId)
|
new MediaCCCRecentListLinkHandlerFactory().fromUrl(url),
|
||||||
throws ExtractionException {
|
kioskId
|
||||||
return new MediaCCCRecentKiosk(MediaCCCService.this,
|
),
|
||||||
new MediaCCCRecentListLinkHandlerFactory().fromUrl(url), kioskId);
|
new MediaCCCRecentListLinkHandlerFactory(),
|
||||||
}
|
"recent"
|
||||||
}, new MediaCCCRecentListLinkHandlerFactory(), "recent");
|
);
|
||||||
|
|
||||||
list.addKioskEntry(new KioskList.KioskExtractorFactory() {
|
list.addKioskEntry(
|
||||||
@Override
|
(streamingService, url, kioskId) -> new MediaCCCLiveStreamKiosk(
|
||||||
public KioskExtractor createNewKiosk(final StreamingService streamingService,
|
MediaCCCService.this,
|
||||||
final String url, final String kioskId)
|
new MediaCCCLiveListLinkHandlerFactory().fromUrl(url),
|
||||||
throws ExtractionException {
|
kioskId
|
||||||
return new MediaCCCLiveStreamKiosk(MediaCCCService.this,
|
),
|
||||||
new MediaCCCLiveListLinkHandlerFactory().fromUrl(url), kioskId);
|
new MediaCCCLiveListLinkHandlerFactory(),
|
||||||
}
|
"live"
|
||||||
}, new MediaCCCLiveListLinkHandlerFactory(), "live");
|
);
|
||||||
|
|
||||||
list.setDefaultKiosk("recent");
|
list.setDefaultKiosk("recent");
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new ExtractionException(e);
|
throw new ExtractionException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,22 +53,22 @@ public class MediaCCCConferenceExtractor extends ChannelExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParentChannelName() throws ParsingException {
|
public String getParentChannelName() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParentChannelUrl() throws ParsingException {
|
public String getParentChannelUrl() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParentChannelAvatarUrl() throws ParsingException {
|
public String getParentChannelAvatarUrl() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVerified() throws ParsingException {
|
public boolean isVerified() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,10 +91,11 @@ public class MediaCCCConferenceExtractor extends ChannelExtractor {
|
|||||||
@Override
|
@Override
|
||||||
public void onFetchPage(@Nonnull final Downloader downloader)
|
public void onFetchPage(@Nonnull final Downloader downloader)
|
||||||
throws IOException, ExtractionException {
|
throws IOException, ExtractionException {
|
||||||
final String conferenceUrl = MediaCCCConferenceLinkHandlerFactory.CONFERENCE_API_ENDPOINT + getId();
|
final String conferenceUrl
|
||||||
|
= MediaCCCConferenceLinkHandlerFactory.CONFERENCE_API_ENDPOINT + getId();
|
||||||
try {
|
try {
|
||||||
conferenceData = JsonParser.object().from(downloader.get(conferenceUrl).responseBody());
|
conferenceData = JsonParser.object().from(downloader.get(conferenceUrl).responseBody());
|
||||||
} catch (JsonParserException jpe) {
|
} catch (final JsonParserException jpe) {
|
||||||
throw new ExtractionException("Could not parse json returnd by url: " + conferenceUrl);
|
throw new ExtractionException("Could not parse json returnd by url: " + conferenceUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,8 +32,8 @@ public class MediaCCCConferenceKiosk extends KioskExtractor<ChannelInfoItem> {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public InfoItemsPage<ChannelInfoItem> getInitialPage() {
|
public InfoItemsPage<ChannelInfoItem> getInitialPage() {
|
||||||
JsonArray conferences = doc.getArray("conferences");
|
final JsonArray conferences = doc.getArray("conferences");
|
||||||
ChannelInfoItemsCollector collector = new ChannelInfoItemsCollector(getServiceId());
|
final ChannelInfoItemsCollector collector = new ChannelInfoItemsCollector(getServiceId());
|
||||||
for (int i = 0; i < conferences.size(); i++) {
|
for (int i = 0; i < conferences.size(); i++) {
|
||||||
collector.commit(new MediaCCCConferenceInfoItemExtractor(conferences.getObject(i)));
|
collector.commit(new MediaCCCConferenceInfoItemExtractor(conferences.getObject(i)));
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ public class MediaCCCConferenceKiosk extends KioskExtractor<ChannelInfoItem> {
|
|||||||
.responseBody();
|
.responseBody();
|
||||||
try {
|
try {
|
||||||
doc = JsonParser.object().from(site);
|
doc = JsonParser.object().from(site);
|
||||||
} catch (JsonParserException jpe) {
|
} catch (final JsonParserException jpe) {
|
||||||
throw new ExtractionException("Could not parse json.", jpe);
|
throw new ExtractionException("Could not parse json.", jpe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,50 +2,51 @@ package org.schabi.newpipe.extractor.services.media_ccc.extractors;
|
|||||||
|
|
||||||
import com.grack.nanojson.JsonArray;
|
import com.grack.nanojson.JsonArray;
|
||||||
import com.grack.nanojson.JsonObject;
|
import com.grack.nanojson.JsonObject;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.MediaFormat;
|
import org.schabi.newpipe.extractor.MediaFormat;
|
||||||
import org.schabi.newpipe.extractor.MetaInfo;
|
|
||||||
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;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
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.linkhandler.LinkHandler;
|
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
|
||||||
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||||
import org.schabi.newpipe.extractor.stream.*;
|
import org.schabi.newpipe.extractor.stream.Description;
|
||||||
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||||
|
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class MediaCCCLiveStreamExtractor extends StreamExtractor {
|
public class MediaCCCLiveStreamExtractor extends StreamExtractor {
|
||||||
private JsonArray doc = null;
|
|
||||||
private JsonObject conference = null;
|
private JsonObject conference = null;
|
||||||
private String group = "";
|
private String group = "";
|
||||||
private JsonObject room = null;
|
private JsonObject room = null;
|
||||||
|
|
||||||
public MediaCCCLiveStreamExtractor(StreamingService service, LinkHandler linkHandler) {
|
public MediaCCCLiveStreamExtractor(final StreamingService service,
|
||||||
|
final LinkHandler linkHandler) {
|
||||||
super(service, linkHandler);
|
super(service, linkHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
|
public void onFetchPage(@Nonnull final Downloader downloader)
|
||||||
doc = MediaCCCParsingHelper.getLiveStreams(downloader, getExtractorLocalization());
|
throws IOException, ExtractionException {
|
||||||
|
final JsonArray doc =
|
||||||
|
MediaCCCParsingHelper.getLiveStreams(downloader, getExtractorLocalization());
|
||||||
// find correct room
|
// find correct room
|
||||||
for (int c = 0; c < doc.size(); c++) {
|
for (int c = 0; c < doc.size(); c++) {
|
||||||
final JsonObject conference = doc.getObject(c);
|
conference = doc.getObject(c);
|
||||||
final JsonArray groups = conference.getArray("groups");
|
final JsonArray groups = conference.getArray("groups");
|
||||||
for (int g = 0; g < groups.size(); g++) {
|
for (int g = 0; g < groups.size(); g++) {
|
||||||
final String group = groups.getObject(g).getString("group");
|
group = groups.getObject(g).getString("group");
|
||||||
final JsonArray rooms = groups.getObject(g).getArray("rooms");
|
final JsonArray rooms = groups.getObject(g).getArray("rooms");
|
||||||
for (int r = 0; r < rooms.size(); r++) {
|
for (int r = 0; r < rooms.size(); r++) {
|
||||||
final JsonObject room = rooms.getObject(r);
|
room = rooms.getObject(r);
|
||||||
if (getId().equals(conference.getString("slug") + "/" + room.getString("slug"))) {
|
if (getId().equals(
|
||||||
this.conference = conference;
|
conference.getString("slug") + "/" + room.getString("slug"))) {
|
||||||
this.group = group;
|
|
||||||
this.room = room;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,7 +70,8 @@ public class MediaCCCLiveStreamExtractor extends StreamExtractor {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Description getDescription() throws ParsingException {
|
public Description getDescription() throws ParsingException {
|
||||||
return new Description(conference.getString("description") + " - " + group, Description.PLAIN_TEXT);
|
return new Description(conference.getString("description")
|
||||||
|
+ " - " + group, Description.PLAIN_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -93,12 +95,11 @@ public class MediaCCCLiveStreamExtractor extends StreamExtractor {
|
|||||||
@Override
|
@Override
|
||||||
public String getHlsUrl() {
|
public String getHlsUrl() {
|
||||||
// TODO: There are multiple HLS streams.
|
// TODO: There are multiple HLS streams.
|
||||||
// Make getHlsUrl() and getDashMpdUrl() return lists of VideoStreams, so the user can choose a resolution.
|
// Make getHlsUrl() and getDashMpdUrl() return lists of VideoStreams,
|
||||||
|
// so the user can choose a resolution.
|
||||||
for (int s = 0; s < room.getArray("streams").size(); s++) {
|
for (int s = 0; s < room.getArray("streams").size(); s++) {
|
||||||
final JsonObject stream = room.getArray("streams").getObject(s);
|
final JsonObject stream = room.getArray("streams").getObject(s);
|
||||||
if (stream.getString("type").equals("video")) {
|
if (stream.getString("type").equals("video")) {
|
||||||
final String resolution = stream.getArray("videoSize").getInt(0) + "x"
|
|
||||||
+ stream.getArray("videoSize").getInt(1);
|
|
||||||
if (stream.has("hls")) {
|
if (stream.has("hls")) {
|
||||||
return stream.getObject("urls").getObject("hls").getString("url");
|
return stream.getObject("urls").getObject("hls").getString("url");
|
||||||
}
|
}
|
||||||
@@ -115,7 +116,8 @@ public class MediaCCCLiveStreamExtractor extends StreamExtractor {
|
|||||||
if (stream.getString("type").equals("audio")) {
|
if (stream.getString("type").equals("audio")) {
|
||||||
for (final String type : stream.getObject("urls").keySet()) {
|
for (final String type : stream.getObject("urls").keySet()) {
|
||||||
final JsonObject url = stream.getObject("urls").getObject(type);
|
final JsonObject url = stream.getObject("urls").getObject(type);
|
||||||
audioStreams.add(new AudioStream(url.getString("url"), MediaFormat.getFromSuffix(type), -1));
|
audioStreams.add(new AudioStream(url.getString("url"),
|
||||||
|
MediaFormat.getFromSuffix(type), -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,19 +18,22 @@ import java.io.IOException;
|
|||||||
public class MediaCCCLiveStreamKiosk extends KioskExtractor<StreamInfoItem> {
|
public class MediaCCCLiveStreamKiosk extends KioskExtractor<StreamInfoItem> {
|
||||||
private JsonArray doc;
|
private JsonArray doc;
|
||||||
|
|
||||||
public MediaCCCLiveStreamKiosk(StreamingService streamingService, ListLinkHandler linkHandler, String kioskId) {
|
public MediaCCCLiveStreamKiosk(final StreamingService streamingService,
|
||||||
|
final ListLinkHandler linkHandler,
|
||||||
|
final String kioskId) {
|
||||||
super(streamingService, linkHandler, kioskId);
|
super(streamingService, linkHandler, kioskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
|
public void onFetchPage(@Nonnull final Downloader downloader)
|
||||||
|
throws IOException, ExtractionException {
|
||||||
doc = MediaCCCParsingHelper.getLiveStreams(downloader, getExtractorLocalization());
|
doc = MediaCCCParsingHelper.getLiveStreams(downloader, getExtractorLocalization());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
|
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
|
||||||
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
|
final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
|
||||||
for (int c = 0; c < doc.size(); c++) {
|
for (int c = 0; c < doc.size(); c++) {
|
||||||
final JsonObject conference = doc.getObject(c);
|
final JsonObject conference = doc.getObject(c);
|
||||||
final JsonArray groups = conference.getArray("groups");
|
final JsonArray groups = conference.getArray("groups");
|
||||||
@@ -48,7 +51,8 @@ public class MediaCCCLiveStreamKiosk extends KioskExtractor<StreamInfoItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InfoItemsPage<StreamInfoItem> getPage(Page page) throws IOException, ExtractionException {
|
public InfoItemsPage<StreamInfoItem> getPage(final Page page)
|
||||||
|
throws IOException, ExtractionException {
|
||||||
return InfoItemsPage.emptyPage();
|
return InfoItemsPage.emptyPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,8 @@ public class MediaCCCLiveStreamKioskExtractor implements StreamInfoItemExtractor
|
|||||||
private final String group;
|
private final String group;
|
||||||
private final JsonObject roomInfo;
|
private final JsonObject roomInfo;
|
||||||
|
|
||||||
public MediaCCCLiveStreamKioskExtractor(final JsonObject conferenceInfo, final String group,
|
public MediaCCCLiveStreamKioskExtractor(final JsonObject conferenceInfo,
|
||||||
|
final String group,
|
||||||
final JsonObject roomInfo) {
|
final JsonObject roomInfo) {
|
||||||
this.conferenceInfo = conferenceInfo;
|
this.conferenceInfo = conferenceInfo;
|
||||||
this.group = group;
|
this.group = group;
|
||||||
@@ -39,7 +40,7 @@ public class MediaCCCLiveStreamKioskExtractor implements StreamInfoItemExtractor
|
|||||||
@Override
|
@Override
|
||||||
public StreamType getStreamType() throws ParsingException {
|
public StreamType getStreamType() throws ParsingException {
|
||||||
boolean isVideo = false;
|
boolean isVideo = false;
|
||||||
for (Object stream : roomInfo.getArray("streams")) {
|
for (final Object stream : roomInfo.getArray("streams")) {
|
||||||
if ("video".equals(((JsonObject) stream).getString("type"))) {
|
if ("video".equals(((JsonObject) stream).getString("type"))) {
|
||||||
isVideo = true;
|
isVideo = true;
|
||||||
break;
|
break;
|
||||||
@@ -65,7 +66,8 @@ public class MediaCCCLiveStreamKioskExtractor implements StreamInfoItemExtractor
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderName() throws ParsingException {
|
public String getUploaderName() throws ParsingException {
|
||||||
return conferenceInfo.getString("conference") + " - " + group + " - " + roomInfo.getString("display");
|
return conferenceInfo.getString("conference") + " - " + group
|
||||||
|
+ " - " + roomInfo.getString("display");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -15,15 +15,17 @@ import java.time.format.DateTimeParseException;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public final class MediaCCCParsingHelper {
|
public final class MediaCCCParsingHelper {
|
||||||
private static final Pattern LIVE_STREAM_ID_PATTERN = Pattern.compile("\\w+/\\w+"); // {conference_slug}/{room_slug}
|
// {conference_slug}/{room_slug}
|
||||||
|
private static final Pattern LIVE_STREAM_ID_PATTERN = Pattern.compile("\\w+/\\w+");
|
||||||
private static JsonArray liveStreams = null;
|
private static JsonArray liveStreams = null;
|
||||||
|
|
||||||
private MediaCCCParsingHelper() { }
|
private MediaCCCParsingHelper() { }
|
||||||
|
|
||||||
public static OffsetDateTime parseDateFrom(final String textualUploadDate) throws ParsingException {
|
public static OffsetDateTime parseDateFrom(final String textualUploadDate)
|
||||||
|
throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return OffsetDateTime.parse(textualUploadDate);
|
return OffsetDateTime.parse(textualUploadDate);
|
||||||
} catch (DateTimeParseException e) {
|
} catch (final DateTimeParseException e) {
|
||||||
throw new ParsingException("Could not parse date: \"" + textualUploadDate + "\"", e);
|
throw new ParsingException("Could not parse date: \"" + textualUploadDate + "\"", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,8 +33,8 @@ public final class MediaCCCParsingHelper {
|
|||||||
/**
|
/**
|
||||||
* Check whether an id is a live stream id
|
* Check whether an id is a live stream id
|
||||||
* @param id the {@code id} to check
|
* @param id the {@code id} to check
|
||||||
* @return returns {@code true} if the {@code id} is formatted like {@code {conference_slug}/{room_slug}};
|
* @return returns {@code true} if the {@code id} is formatted like
|
||||||
* {@code false} otherwise
|
* {@code {conference_slug}/{room_slug}}; {@code false} otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isLiveStreamId(final String id) {
|
public static boolean isLiveStreamId(final String id) {
|
||||||
return LIVE_STREAM_ID_PATTERN.matcher(id).find();
|
return LIVE_STREAM_ID_PATTERN.matcher(id).find();
|
||||||
@@ -40,24 +42,28 @@ public final class MediaCCCParsingHelper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get currently available live streams from
|
* Get currently available live streams from
|
||||||
* <a href="https://streaming.media.ccc.de/streams/v2.json">https://streaming.media.ccc.de/streams/v2.json</a>.
|
* <a href="https://streaming.media.ccc.de/streams/v2.json">
|
||||||
|
* https://streaming.media.ccc.de/streams/v2.json</a>.
|
||||||
* Use this method to cache requests, because they can get quite big.
|
* Use this method to cache requests, because they can get quite big.
|
||||||
* TODO: implement better caching policy (max-age: 3 min)
|
* TODO: implement better caching policy (max-age: 3 min)
|
||||||
* @param downloader The downloader to use for making the request
|
* @param downloader The downloader to use for making the request
|
||||||
* @param localization The localization to be used. Will most likely be ignored.
|
* @param localization The localization to be used. Will most likely be ignored.
|
||||||
* @return {@link JsonArray} containing current conferences and info about their rooms and streams.
|
* @return {@link JsonArray} containing current conferences and info about their rooms and
|
||||||
* @throws ExtractionException if the data could not be fetched or the retrieved data could not be parsed to a {@link JsonArray}
|
* streams.
|
||||||
|
* @throws ExtractionException if the data could not be fetched or the retrieved data could not
|
||||||
|
* be parsed to a {@link JsonArray}
|
||||||
*/
|
*/
|
||||||
public static JsonArray getLiveStreams(final Downloader downloader, final Localization localization)
|
public static JsonArray getLiveStreams(final Downloader downloader,
|
||||||
|
final Localization localization)
|
||||||
throws ExtractionException {
|
throws ExtractionException {
|
||||||
if (liveStreams == null) {
|
if (liveStreams == null) {
|
||||||
try {
|
try {
|
||||||
final String site = downloader.get("https://streaming.media.ccc.de/streams/v2.json",
|
final String site = downloader.get("https://streaming.media.ccc.de/streams/v2.json",
|
||||||
localization).responseBody();
|
localization).responseBody();
|
||||||
liveStreams = JsonParser.array().from(site);
|
liveStreams = JsonParser.array().from(site);
|
||||||
} catch (IOException | ReCaptchaException e) {
|
} catch (final IOException | ReCaptchaException e) {
|
||||||
throw new ExtractionException("Could not get live stream JSON.", e);
|
throw new ExtractionException("Could not get live stream JSON.", e);
|
||||||
} catch (JsonParserException e) {
|
} catch (final JsonParserException e) {
|
||||||
throw new ExtractionException("Could not parse JSON.", e);
|
throw new ExtractionException("Could not parse JSON.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,17 +22,20 @@ public class MediaCCCRecentKiosk extends KioskExtractor<StreamInfoItem> {
|
|||||||
|
|
||||||
private JsonObject doc;
|
private JsonObject doc;
|
||||||
|
|
||||||
public MediaCCCRecentKiosk(StreamingService streamingService, ListLinkHandler linkHandler, String kioskId) {
|
public MediaCCCRecentKiosk(final StreamingService streamingService,
|
||||||
|
final ListLinkHandler linkHandler,
|
||||||
|
final String kioskId) {
|
||||||
super(streamingService, linkHandler, kioskId);
|
super(streamingService, linkHandler, kioskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
|
public void onFetchPage(@Nonnull final Downloader downloader)
|
||||||
|
throws IOException, ExtractionException {
|
||||||
final String site = downloader.get("https://api.media.ccc.de/public/events/recent",
|
final String site = downloader.get("https://api.media.ccc.de/public/events/recent",
|
||||||
getExtractorLocalization()).responseBody();
|
getExtractorLocalization()).responseBody();
|
||||||
try {
|
try {
|
||||||
doc = JsonParser.object().from(site);
|
doc = JsonParser.object().from(site);
|
||||||
} catch (JsonParserException jpe) {
|
} catch (final JsonParserException jpe) {
|
||||||
throw new ExtractionException("Could not parse json.", jpe);
|
throw new ExtractionException("Could not parse json.", jpe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,7 +51,8 @@ public class MediaCCCRecentKiosk extends KioskExtractor<StreamInfoItem> {
|
|||||||
streamInfoItem -> streamInfoItem.getUploadDate().offsetDateTime());
|
streamInfoItem -> streamInfoItem.getUploadDate().offsetDateTime());
|
||||||
comparator = comparator.reversed();
|
comparator = comparator.reversed();
|
||||||
|
|
||||||
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId(), comparator);
|
final StreamInfoItemsCollector collector
|
||||||
|
= new StreamInfoItemsCollector(getServiceId(), comparator);
|
||||||
for (int i = 0; i < events.size(); i++) {
|
for (int i = 0; i < events.size(); i++) {
|
||||||
collector.commit(new MediaCCCRecentKioskExtractor(events.getObject(i)));
|
collector.commit(new MediaCCCRecentKioskExtractor(events.getObject(i)));
|
||||||
}
|
}
|
||||||
@@ -56,7 +60,8 @@ public class MediaCCCRecentKiosk extends KioskExtractor<StreamInfoItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InfoItemsPage<StreamInfoItem> getPage(Page page) throws IOException, ExtractionException {
|
public InfoItemsPage<StreamInfoItem> getPage(final Page page)
|
||||||
|
throws IOException, ExtractionException {
|
||||||
return InfoItemsPage.emptyPage();
|
return InfoItemsPage.emptyPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,8 +46,8 @@ public class MediaCCCRecentKioskExtractor implements StreamInfoItemExtractor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getDuration() throws ParsingException {
|
public long getDuration() throws ParsingException {
|
||||||
// duration and length have the same value
|
// duration and length have the same value, see
|
||||||
// see https://github.com/voc/voctoweb/blob/master/app/views/public/shared/_event.json.jbuilder
|
// https://github.com/voc/voctoweb/blob/master/app/views/public/shared/_event.json.jbuilder
|
||||||
return event.getInt("duration");
|
return event.getInt("duration");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
package org.schabi.newpipe.extractor.services.media_ccc.extractors;
|
package org.schabi.newpipe.extractor.services.media_ccc.extractors;
|
||||||
|
|
||||||
|
import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.ALL;
|
||||||
|
import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.CONFERENCES;
|
||||||
|
import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.EVENTS;
|
||||||
|
|
||||||
import com.grack.nanojson.JsonArray;
|
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;
|
||||||
@@ -13,7 +17,6 @@ import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
|||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
|
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
|
||||||
import org.schabi.newpipe.extractor.downloader.Downloader;
|
import org.schabi.newpipe.extractor.downloader.Downloader;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
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.linkhandler.SearchQueryHandler;
|
||||||
import org.schabi.newpipe.extractor.MultiInfoItemsCollector;
|
import org.schabi.newpipe.extractor.MultiInfoItemsCollector;
|
||||||
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||||
@@ -26,10 +29,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.ALL;
|
|
||||||
import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.CONFERENCES;
|
|
||||||
import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.EVENTS;
|
|
||||||
|
|
||||||
public class MediaCCCSearchExtractor extends SearchExtractor {
|
public class MediaCCCSearchExtractor extends SearchExtractor {
|
||||||
private JsonObject doc;
|
private JsonObject doc;
|
||||||
private MediaCCCConferenceKiosk conferenceKiosk;
|
private MediaCCCConferenceKiosk conferenceKiosk;
|
||||||
@@ -41,7 +40,7 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
|
|||||||
conferenceKiosk = new MediaCCCConferenceKiosk(service,
|
conferenceKiosk = new MediaCCCConferenceKiosk(service,
|
||||||
new MediaCCCConferencesListLinkHandlerFactory().fromId("conferences"),
|
new MediaCCCConferencesListLinkHandlerFactory().fromId("conferences"),
|
||||||
"conferences");
|
"conferences");
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,7 +78,7 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
|
|||||||
if (getLinkHandler().getContentFilters().contains(EVENTS)
|
if (getLinkHandler().getContentFilters().contains(EVENTS)
|
||||||
|| getLinkHandler().getContentFilters().contains(ALL)
|
|| getLinkHandler().getContentFilters().contains(ALL)
|
||||||
|| getLinkHandler().getContentFilters().isEmpty()) {
|
|| getLinkHandler().getContentFilters().isEmpty()) {
|
||||||
JsonArray events = doc.getArray("events");
|
final JsonArray events = doc.getArray("events");
|
||||||
for (int i = 0; i < events.size(); i++) {
|
for (int i = 0; i < events.size(); i++) {
|
||||||
// Ensure only uploaded talks are shown in the search results.
|
// Ensure only uploaded talks are shown in the search results.
|
||||||
// If the release date is null, the talk has not been held or uploaded yet
|
// If the release date is null, the talk has not been held or uploaded yet
|
||||||
@@ -109,7 +108,7 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
|
|||||||
site = downloader.get(url, getExtractorLocalization()).responseBody();
|
site = downloader.get(url, getExtractorLocalization()).responseBody();
|
||||||
try {
|
try {
|
||||||
doc = JsonParser.object().from(site);
|
doc = JsonParser.object().from(site);
|
||||||
} catch (JsonParserException jpe) {
|
} catch (final JsonParserException jpe) {
|
||||||
throw new ExtractionException("Could not parse JSON.", jpe);
|
throw new ExtractionException("Could not parse JSON.", jpe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +142,7 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVerified() throws ParsingException {
|
public boolean isVerified() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,8 +4,8 @@ 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.MediaFormat;
|
import org.schabi.newpipe.extractor.MediaFormat;
|
||||||
import org.schabi.newpipe.extractor.MetaInfo;
|
|
||||||
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;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
@@ -15,17 +15,21 @@ import org.schabi.newpipe.extractor.localization.DateWrapper;
|
|||||||
import org.schabi.newpipe.extractor.localization.Localization;
|
import org.schabi.newpipe.extractor.localization.Localization;
|
||||||
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.services.media_ccc.linkHandler.MediaCCCStreamLinkHandlerFactory;
|
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCStreamLinkHandlerFactory;
|
||||||
import org.schabi.newpipe.extractor.stream.*;
|
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||||
|
import org.schabi.newpipe.extractor.stream.Description;
|
||||||
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||||
|
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||||
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class MediaCCCStreamExtractor extends StreamExtractor {
|
public class MediaCCCStreamExtractor extends StreamExtractor {
|
||||||
private JsonObject data;
|
private JsonObject data;
|
||||||
private JsonObject conferenceData;
|
private JsonObject conferenceData;
|
||||||
@@ -158,7 +162,7 @@ public class MediaCCCStreamExtractor extends StreamExtractor {
|
|||||||
data = JsonParser.object().from(downloader.get(videoUrl).responseBody());
|
data = JsonParser.object().from(downloader.get(videoUrl).responseBody());
|
||||||
conferenceData = JsonParser.object()
|
conferenceData = JsonParser.object()
|
||||||
.from(downloader.get(data.getString("conference_url")).responseBody());
|
.from(downloader.get(data.getString("conference_url")).responseBody());
|
||||||
} catch (JsonParserException jpe) {
|
} catch (final JsonParserException jpe) {
|
||||||
throw new ExtractionException("Could not parse json returned by url: " + videoUrl, jpe);
|
throw new ExtractionException("Could not parse json returned by url: " + videoUrl, jpe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ import org.schabi.newpipe.extractor.stream.StreamType;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class MediaCCCStreamInfoItemExtractor implements StreamInfoItemExtractor {
|
public class MediaCCCStreamInfoItemExtractor implements StreamInfoItemExtractor {
|
||||||
private JsonObject event;
|
private final JsonObject event;
|
||||||
|
|
||||||
public MediaCCCStreamInfoItemExtractor(final JsonObject event) {
|
public MediaCCCStreamInfoItemExtractor(final JsonObject event) {
|
||||||
this.event = event;
|
this.event = event;
|
||||||
|
@@ -7,9 +7,12 @@ import org.schabi.newpipe.extractor.utils.Parser;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MediaCCCConferenceLinkHandlerFactory extends ListLinkHandlerFactory {
|
public class MediaCCCConferenceLinkHandlerFactory extends ListLinkHandlerFactory {
|
||||||
public static final String CONFERENCE_API_ENDPOINT = "https://api.media.ccc.de/public/conferences/";
|
public static final String CONFERENCE_API_ENDPOINT
|
||||||
|
= "https://api.media.ccc.de/public/conferences/";
|
||||||
public static final String CONFERENCE_PATH = "https://media.ccc.de/c/";
|
public static final String CONFERENCE_PATH = "https://media.ccc.de/c/";
|
||||||
private static final String ID_PATTERN = "(?:(?:(?:api\\.)?media\\.ccc\\.de/public/conferences/)|(?:media\\.ccc\\.de/[bc]/))([^/?&#]*)";
|
private static final String ID_PATTERN
|
||||||
|
= "(?:(?:(?:api\\.)?media\\.ccc\\.de/public/conferences/)"
|
||||||
|
+ "|(?:media\\.ccc\\.de/[bc]/))([^/?&#]*)";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(final String id,
|
public String getUrl(final String id,
|
||||||
@@ -27,7 +30,7 @@ public class MediaCCCConferenceLinkHandlerFactory extends ListLinkHandlerFactory
|
|||||||
public boolean onAcceptUrl(final String url) {
|
public boolean onAcceptUrl(final String url) {
|
||||||
try {
|
try {
|
||||||
return getId(url) != null;
|
return getId(url) != null;
|
||||||
} catch (ParsingException e) {
|
} catch (final ParsingException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,20 +7,22 @@ import java.util.List;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class MediaCCCLiveListLinkHandlerFactory extends ListLinkHandlerFactory {
|
public class MediaCCCLiveListLinkHandlerFactory extends ListLinkHandlerFactory {
|
||||||
private static final String streamPattern = "^(?:https?://)?media\\.ccc\\.de/live$";
|
private static final String STREAM_PATTERN = "^(?:https?://)?media\\.ccc\\.de/live$";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId(String url) throws ParsingException {
|
public String getId(final String url) throws ParsingException {
|
||||||
return "live";
|
return "live";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onAcceptUrl(String url) throws ParsingException {
|
public boolean onAcceptUrl(final String url) throws ParsingException {
|
||||||
return Pattern.matches(streamPattern, url);
|
return Pattern.matches(STREAM_PATTERN, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(String id, List<String> contentFilter, String sortFilter) throws ParsingException {
|
public String getUrl(final String id,
|
||||||
|
final List<String> contentFilter,
|
||||||
|
final String sortFilter) throws ParsingException {
|
||||||
// FIXME: wrong URL; should be https://streaming.media.ccc.de/{conference_slug}/{room_slug}
|
// FIXME: wrong URL; should be https://streaming.media.ccc.de/{conference_slug}/{room_slug}
|
||||||
return "https://media.ccc.de/live";
|
return "https://media.ccc.de/live";
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,9 @@ import org.schabi.newpipe.extractor.utils.Parser;
|
|||||||
public class MediaCCCLiveStreamLinkHandlerFactory extends LinkHandlerFactory {
|
public class MediaCCCLiveStreamLinkHandlerFactory extends LinkHandlerFactory {
|
||||||
public static final String VIDEO_API_ENDPOINT = "https://api.media.ccc.de/public/events/";
|
public static final String VIDEO_API_ENDPOINT = "https://api.media.ccc.de/public/events/";
|
||||||
private static final String VIDEO_PATH = "https://streaming.media.ccc.de/v/";
|
private static final String VIDEO_PATH = "https://streaming.media.ccc.de/v/";
|
||||||
private static final String ID_PATTERN = "(?:(?:(?:api\\.)?media\\.ccc\\.de/public/events/)|(?:media\\.ccc\\.de/v/))([^/?&#]*)";
|
private static final String ID_PATTERN
|
||||||
|
= "(?:(?:(?:api\\.)?media\\.ccc\\.de/public/events/)"
|
||||||
|
+ "|(?:media\\.ccc\\.de/v/))([^/?&#]*)";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId(final String url) throws ParsingException {
|
public String getId(final String url) throws ParsingException {
|
||||||
@@ -23,7 +25,7 @@ public class MediaCCCLiveStreamLinkHandlerFactory extends LinkHandlerFactory {
|
|||||||
public boolean onAcceptUrl(final String url) {
|
public boolean onAcceptUrl(final String url) {
|
||||||
try {
|
try {
|
||||||
return getId(url) != null;
|
return getId(url) != null;
|
||||||
} catch (ParsingException e) {
|
} catch (final ParsingException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,20 +6,22 @@ import java.util.List;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class MediaCCCRecentListLinkHandlerFactory extends ListLinkHandlerFactory {
|
public class MediaCCCRecentListLinkHandlerFactory extends ListLinkHandlerFactory {
|
||||||
private static final String pattern = "^(https?://)?media\\.ccc\\.de/recent/?$";
|
private static final String PATTERN = "^(https?://)?media\\.ccc\\.de/recent/?$";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId(String url) {
|
public String getId(final String url) {
|
||||||
return "recent";
|
return "recent";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onAcceptUrl(String url) {
|
public boolean onAcceptUrl(final String url) {
|
||||||
return Pattern.matches(pattern, url);
|
return Pattern.matches(PATTERN, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(String id, List<String> contentFilter, String sortFilter) {
|
public String getUrl(final String id,
|
||||||
|
final List<String> contentFilter,
|
||||||
|
final String sortFilter) {
|
||||||
return "https://media.ccc.de/recent";
|
return "https://media.ccc.de/recent";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,7 @@ public class MediaCCCSearchQueryHandlerFactory extends SearchQueryHandlerFactory
|
|||||||
try {
|
try {
|
||||||
return "https://media.ccc.de/public/events/search?q="
|
return "https://media.ccc.de/public/events/search?q="
|
||||||
+ URLEncoder.encode(query, UTF_8);
|
+ URLEncoder.encode(query, UTF_8);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (final UnsupportedEncodingException e) {
|
||||||
throw new ParsingException("Could not create search string with query: " + query, e);
|
throw new ParsingException("Could not create search string with query: " + query, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,19 +8,21 @@ import org.schabi.newpipe.extractor.utils.Parser;
|
|||||||
public class MediaCCCStreamLinkHandlerFactory extends LinkHandlerFactory {
|
public class MediaCCCStreamLinkHandlerFactory extends LinkHandlerFactory {
|
||||||
public static final String VIDEO_API_ENDPOINT = "https://api.media.ccc.de/public/events/";
|
public static final String VIDEO_API_ENDPOINT = "https://api.media.ccc.de/public/events/";
|
||||||
private static final String VIDEO_PATH = "https://media.ccc.de/v/";
|
private static final String VIDEO_PATH = "https://media.ccc.de/v/";
|
||||||
private static final String RECORDING_ID_PATTERN = "(?:(?:(?:api\\.)?media\\.ccc\\.de/public/events/)|(?:media\\.ccc\\.de/v/))([^/?&#]*)";
|
private static final String RECORDING_ID_PATTERN
|
||||||
private static final String LIVE_STREAM_API_ENDPOINT = "https://streaming.media.ccc.de/streams/v2.json";
|
= "(?:(?:(?:api\\.)?media\\.ccc\\.de/public/events/)"
|
||||||
|
+ "|(?:media\\.ccc\\.de/v/))([^/?&#]*)";
|
||||||
private static final String LIVE_STREAM_PATH = "https://streaming.media.ccc.de/";
|
private static final String LIVE_STREAM_PATH = "https://streaming.media.ccc.de/";
|
||||||
private static final String LIVE_STREAM_ID_PATTERN = "streaming\\.media\\.ccc\\.de\\/(\\w+\\/\\w+)";
|
private static final String LIVE_STREAM_ID_PATTERN
|
||||||
|
= "streaming\\.media\\.ccc\\.de\\/(\\w+\\/\\w+)";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId(final String url) throws ParsingException {
|
public String getId(final String url) throws ParsingException {
|
||||||
String streamId = null;
|
String streamId = null;
|
||||||
try {
|
try {
|
||||||
streamId = Parser.matchGroup1(LIVE_STREAM_ID_PATTERN, url);
|
streamId = Parser.matchGroup1(LIVE_STREAM_ID_PATTERN, url);
|
||||||
} catch (Parser.RegexException ignored) {
|
} catch (final Parser.RegexException ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streamId == null) {
|
if (streamId == null) {
|
||||||
return Parser.matchGroup1(RECORDING_ID_PATTERN, url);
|
return Parser.matchGroup1(RECORDING_ID_PATTERN, url);
|
||||||
}
|
}
|
||||||
@@ -39,7 +41,7 @@ public class MediaCCCStreamLinkHandlerFactory extends LinkHandlerFactory {
|
|||||||
public boolean onAcceptUrl(final String url) {
|
public boolean onAcceptUrl(final String url) {
|
||||||
try {
|
try {
|
||||||
return getId(url) != null;
|
return getId(url) != null;
|
||||||
} catch (ParsingException e) {
|
} catch (final ParsingException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user