diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCService.java index f2d9b673a..523584e60 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCService.java @@ -6,7 +6,12 @@ import org.schabi.newpipe.extractor.comments.CommentsExtractor; 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.linkhandler.*; +import org.schabi.newpipe.extractor.linkhandler.LinkHandler; +import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; +import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler; +import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandlerFactory; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceExtractor; @@ -21,19 +26,17 @@ import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor; -import java.io.IOException; - 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 MediaCCCService(int id) { + public MediaCCCService(final int id) { super(id, "MediaCCC", asList(AUDIO, VIDEO)); } @Override - public SearchExtractor getSearchExtractor(SearchQueryHandler query) { + public SearchExtractor getSearchExtractor(final SearchQueryHandler query) { return new MediaCCCSearchExtractor(this, query); } @@ -58,17 +61,17 @@ public class MediaCCCService extends StreamingService { } @Override - public StreamExtractor getStreamExtractor(LinkHandler linkHandler) { + public StreamExtractor getStreamExtractor(final LinkHandler linkHandler) { return new MediaCCCStreamExtractor(this, linkHandler); } @Override - public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler) { + public ChannelExtractor getChannelExtractor(final ListLinkHandler linkHandler) { return new MediaCCCConferenceExtractor(this, linkHandler); } @Override - public PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler) { + public PlaylistExtractor getPlaylistExtractor(final ListLinkHandler linkHandler) { return null; } @@ -85,9 +88,9 @@ public class MediaCCCService extends StreamingService { try { list.addKioskEntry(new KioskList.KioskExtractorFactory() { @Override - public KioskExtractor createNewKiosk(StreamingService streamingService, - String url, - String kioskId) throws ExtractionException, IOException { + public KioskExtractor createNewKiosk(final StreamingService streamingService, + final String url, final String kioskId) + throws ExtractionException { return new MediaCCCConferenceKiosk(MediaCCCService.this, new MediaCCCConferencesListLinkHandlerFactory().fromUrl(url), kioskId); } @@ -111,8 +114,7 @@ public class MediaCCCService extends StreamingService { } @Override - public CommentsExtractor getCommentsExtractor(ListLinkHandler linkHandler) - throws ExtractionException { + public CommentsExtractor getCommentsExtractor(final ListLinkHandler linkHandler) { return null; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java index 5c4079aed..4cd21c060 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java @@ -4,6 +4,7 @@ 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; @@ -14,45 +15,46 @@ import org.schabi.newpipe.extractor.services.media_ccc.extractors.infoItems.Medi import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; -import javax.annotation.Nonnull; import java.io.IOException; -public class MediaCCCConferenceExtractor extends ChannelExtractor { +import javax.annotation.Nonnull; +public class MediaCCCConferenceExtractor extends ChannelExtractor { private JsonObject conferenceData; - public MediaCCCConferenceExtractor(StreamingService service, ListLinkHandler linkHandler) { + public MediaCCCConferenceExtractor(final StreamingService service, + final ListLinkHandler linkHandler) { super(service, linkHandler); } @Override - public String getAvatarUrl() throws ParsingException { + public String getAvatarUrl() { return conferenceData.getString("logo_url"); } @Override - public String getBannerUrl() throws ParsingException { + public String getBannerUrl() { return conferenceData.getString("logo_url"); } @Override - public String getFeedUrl() throws ParsingException { + public String getFeedUrl() { return null; } @Override - public long getSubscriberCount() throws ParsingException { + public long getSubscriberCount() { return -1; } @Override - public String getDescription() throws ParsingException { + public String getDescription() { return null; } @Nonnull @Override - public InfoItemsPage getInitialPage() throws IOException, ExtractionException { + public InfoItemsPage getInitialPage() { StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); JsonArray events = conferenceData.getArray("events"); for (int i = 0; i < events.size(); i++) { @@ -62,17 +64,18 @@ public class MediaCCCConferenceExtractor extends ChannelExtractor { } @Override - public String getNextPageUrl() throws IOException, ExtractionException { + public String getNextPageUrl() { return null; } @Override - public InfoItemsPage getPage(String pageUrl) throws IOException, ExtractionException { + public InfoItemsPage getPage(final String pageUrl) { return null; } @Override - public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { + public void onFetchPage(@Nonnull final Downloader downloader) + throws IOException, ExtractionException { try { conferenceData = JsonParser.object().from(downloader.get(getUrl()).responseBody()); } catch (JsonParserException jpe) { @@ -88,7 +91,7 @@ public class MediaCCCConferenceExtractor extends ChannelExtractor { @Nonnull @Override - public String getOriginalUrl() throws ParsingException { + public String getOriginalUrl() { return "https://media.ccc.de/c/" + conferenceData.getString("acronym"); } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceKiosk.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceKiosk.java index f9800b46f..010d3881a 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceKiosk.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceKiosk.java @@ -4,6 +4,7 @@ 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.ChannelInfoItem; import org.schabi.newpipe.extractor.channel.ChannelInfoItemsCollector; @@ -14,22 +15,22 @@ import org.schabi.newpipe.extractor.kiosk.KioskExtractor; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.services.media_ccc.extractors.infoItems.MediaCCCConferenceInfoItemExtractor; -import javax.annotation.Nonnull; import java.io.IOException; -public class MediaCCCConferenceKiosk extends KioskExtractor { +import javax.annotation.Nonnull; +public class MediaCCCConferenceKiosk extends KioskExtractor { private JsonObject doc; - public MediaCCCConferenceKiosk(StreamingService streamingService, - ListLinkHandler linkHandler, - String kioskId) { + public MediaCCCConferenceKiosk(final StreamingService streamingService, + final ListLinkHandler linkHandler, + final String kioskId) { super(streamingService, linkHandler, kioskId); } @Nonnull @Override - public InfoItemsPage getInitialPage() throws IOException, ExtractionException { + public InfoItemsPage getInitialPage() { JsonArray conferences = doc.getArray("conferences"); ChannelInfoItemsCollector collector = new ChannelInfoItemsCollector(getServiceId()); for (int i = 0; i < conferences.size(); i++) { @@ -40,18 +41,20 @@ public class MediaCCCConferenceKiosk extends KioskExtractor { } @Override - public String getNextPageUrl() throws IOException, ExtractionException { + public String getNextPageUrl() { return ""; } @Override - public InfoItemsPage getPage(String pageUrl) throws IOException, ExtractionException { + public InfoItemsPage getPage(final String pageUrl) { return InfoItemsPage.emptyPage(); } @Override - public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { - String site = downloader.get(getLinkHandler().getUrl(), getExtractorLocalization()).responseBody(); + public void onFetchPage(@Nonnull final Downloader downloader) + throws IOException, ExtractionException { + final String site = downloader.get(getLinkHandler().getUrl(), getExtractorLocalization()) + .responseBody(); try { doc = JsonParser.object().from(site); } catch (JsonParserException jpe) { diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCParsingHelper.java index 0a51af2aa..9e5baaf9c 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCParsingHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCParsingHelper.java @@ -7,11 +7,10 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; -public class MediaCCCParsingHelper { - private MediaCCCParsingHelper() { - } +public final class MediaCCCParsingHelper { + private MediaCCCParsingHelper() { } - public static Calendar parseDateFrom(String textualUploadDate) throws ParsingException { + public static Calendar parseDateFrom(final String textualUploadDate) throws ParsingException { Date date; try { date = new SimpleDateFormat("yyyy-MM-dd").parse(textualUploadDate); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSearchExtractor.java index 96618fd94..d5ced534b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSearchExtractor.java @@ -4,31 +4,34 @@ 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.InfoItem; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor; 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.SearchQueryHandler; import org.schabi.newpipe.extractor.search.InfoItemsSearchCollector; import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.services.media_ccc.extractors.infoItems.MediaCCCStreamInfoItemExtractor; import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferencesListLinkHandlerFactory; -import javax.annotation.Nonnull; import java.io.IOException; import java.util.List; -import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.*; +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 { - private JsonObject doc; private MediaCCCConferenceKiosk conferenceKiosk; - public MediaCCCSearchExtractor(StreamingService service, SearchQueryHandler linkHandler) { + public MediaCCCSearchExtractor(final StreamingService service, + final SearchQueryHandler linkHandler) { super(service, linkHandler); try { conferenceKiosk = new MediaCCCConferenceKiosk(service, @@ -40,13 +43,13 @@ public class MediaCCCSearchExtractor extends SearchExtractor { } @Override - public String getSearchSuggestion() throws ParsingException { + public String getSearchSuggestion() { return null; } @Nonnull @Override - public InfoItemsPage getInitialPage() throws IOException, ExtractionException { + public InfoItemsPage getInitialPage() { final InfoItemsSearchCollector searchItems = new InfoItemsSearchCollector(getServiceId()); if (getLinkHandler().getContentFilters().contains(CONFERENCES) @@ -70,17 +73,18 @@ public class MediaCCCSearchExtractor extends SearchExtractor { } @Override - public String getNextPageUrl() throws IOException, ExtractionException { + public String getNextPageUrl() { return ""; } @Override - public InfoItemsPage getPage(String pageUrl) throws IOException, ExtractionException { + public InfoItemsPage getPage(final String pageUrl) { return InfoItemsPage.emptyPage(); } @Override - public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { + public void onFetchPage(@Nonnull final Downloader downloader) + throws IOException, ExtractionException { if (getLinkHandler().getContentFilters().contains(EVENTS) || getLinkHandler().getContentFilters().contains(ALL) || getLinkHandler().getContentFilters().isEmpty()) { @@ -95,44 +99,45 @@ public class MediaCCCSearchExtractor extends SearchExtractor { } if (getLinkHandler().getContentFilters().contains(CONFERENCES) || getLinkHandler().getContentFilters().contains(ALL) - || getLinkHandler().getContentFilters().isEmpty()) + || getLinkHandler().getContentFilters().isEmpty()) { conferenceKiosk.fetchPage(); + } } - private void searchConferences(String searchString, - List channelItems, - InfoItemsSearchCollector collector) { + private void searchConferences(final String searchString, + final List channelItems, + final InfoItemsSearchCollector collector) { for (final ChannelInfoItem item : channelItems) { if (item.getName().toUpperCase().contains( searchString.toUpperCase())) { collector.commit(new ChannelInfoItemExtractor() { @Override - public String getDescription() throws ParsingException { + public String getDescription() { return item.getDescription(); } @Override - public long getSubscriberCount() throws ParsingException { + public long getSubscriberCount() { return item.getSubscriberCount(); } @Override - public long getStreamCount() throws ParsingException { + public long getStreamCount() { return item.getStreamCount(); } @Override - public String getName() throws ParsingException { + public String getName() { return item.getName(); } @Override - public String getUrl() throws ParsingException { + public String getUrl() { return item.getUrl(); } @Override - public String getThumbnailUrl() throws ParsingException { + public String getThumbnailUrl() { return item.getThumbnailUrl(); } }); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java index 59bfe1f4f..894a0f0db 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java @@ -4,6 +4,7 @@ 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.MediaFormat; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.downloader.Downloader; @@ -11,27 +12,34 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.LinkHandler; import org.schabi.newpipe.extractor.localization.DateWrapper; -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.StreamInfoItem; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; +import org.schabi.newpipe.extractor.stream.StreamType; +import org.schabi.newpipe.extractor.stream.SubtitlesStream; +import org.schabi.newpipe.extractor.stream.VideoStream; -import javax.annotation.Nonnull; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; -public class MediaCCCStreamExtractor extends StreamExtractor { +import javax.annotation.Nonnull; +public class MediaCCCStreamExtractor extends StreamExtractor { private JsonObject data; private JsonObject conferenceData; - public MediaCCCStreamExtractor(StreamingService service, LinkHandler linkHandler) { + public MediaCCCStreamExtractor(final StreamingService service, final LinkHandler linkHandler) { super(service, linkHandler); } @Nonnull @Override - public String getTextualUploadDate() throws ParsingException { + public String getTextualUploadDate() { return data.getString("release_date"); } @@ -43,79 +51,79 @@ public class MediaCCCStreamExtractor extends StreamExtractor { @Nonnull @Override - public String getThumbnailUrl() throws ParsingException { + public String getThumbnailUrl() { return data.getString("thumb_url"); } @Nonnull @Override - public Description getDescription() throws ParsingException { + public Description getDescription() { return new Description(data.getString("description"), Description.PLAIN_TEXT); } @Override - public int getAgeLimit() throws ParsingException { + public int getAgeLimit() { return 0; } @Override - public long getLength() throws ParsingException { + public long getLength() { return data.getInt("length"); } @Override - public long getTimeStamp() throws ParsingException { + public long getTimeStamp() { return 0; } @Override - public long getViewCount() throws ParsingException { + public long getViewCount() { return data.getInt("view_count"); } @Override - public long getLikeCount() throws ParsingException { + public long getLikeCount() { return -1; } @Override - public long getDislikeCount() throws ParsingException { + public long getDislikeCount() { return -1; } @Nonnull @Override - public String getUploaderUrl() throws ParsingException { + public String getUploaderUrl() { return data.getString("conference_url"); } @Nonnull @Override - public String getUploaderName() throws ParsingException { + public String getUploaderName() { return data.getString("conference_url") - .replace("https://api.media.ccc.de/public/conferences/", ""); + .replaceFirst("https://(api\\.)?media\\.ccc\\.de/public/conferences/", ""); } @Nonnull @Override - public String getUploaderAvatarUrl() throws ParsingException { + public String getUploaderAvatarUrl() { return conferenceData.getString("logo_url"); } @Nonnull @Override - public String getDashMpdUrl() throws ParsingException { + public String getDashMpdUrl() { return ""; } @Nonnull @Override - public String getHlsUrl() throws ParsingException { + public String getHlsUrl() { return ""; } @Override - public List getAudioStreams() throws IOException, ExtractionException { + public List getAudioStreams() throws ExtractionException { final JsonArray recordings = data.getArray("recordings"); final List audioStreams = new ArrayList<>(); for (int i = 0; i < recordings.size(); i++) { @@ -134,14 +142,15 @@ public class MediaCCCStreamExtractor extends StreamExtractor { throw new ExtractionException("Unknown media format: " + mimeType); } - audioStreams.add(new AudioStream(recording.getString("recording_url"), mediaFormat, -1)); + audioStreams.add(new AudioStream(recording.getString("recording_url"), + mediaFormat, -1)); } } return audioStreams; } @Override - public List getVideoStreams() throws IOException, ExtractionException { + public List getVideoStreams() throws ExtractionException { final JsonArray recordings = data.getArray("recordings"); final List videoStreams = new ArrayList<>(); for (int i = 0; i < recordings.size(); i++) { @@ -167,34 +176,34 @@ public class MediaCCCStreamExtractor extends StreamExtractor { } @Override - public List getVideoOnlyStreams() throws IOException, ExtractionException { + public List getVideoOnlyStreams() { return null; } @Nonnull @Override - public List getSubtitlesDefault() throws IOException, ExtractionException { + public List getSubtitlesDefault() { return Collections.emptyList(); } @Nonnull @Override - public List getSubtitles(final MediaFormat format) throws IOException, ExtractionException { + public List getSubtitles(final MediaFormat format) { return Collections.emptyList(); } @Override - public StreamType getStreamType() throws ParsingException { + public StreamType getStreamType() { return StreamType.VIDEO_STREAM; } @Override - public StreamInfoItem getNextStream() throws IOException, ExtractionException { + public StreamInfoItem getNextStream() { return null; } @Override - public StreamInfoItemsCollector getRelatedStreams() throws IOException, ExtractionException { + public StreamInfoItemsCollector getRelatedStreams() { return new StreamInfoItemsCollector(getServiceId()); } @@ -204,14 +213,16 @@ public class MediaCCCStreamExtractor extends StreamExtractor { } @Override - public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { + public void onFetchPage(@Nonnull final Downloader downloader) + throws IOException, ExtractionException { try { data = JsonParser.object().from( downloader.get(getLinkHandler().getUrl()).responseBody()); conferenceData = JsonParser.object() .from(downloader.get(getUploaderUrl()).responseBody()); } catch (JsonParserException jpe) { - throw new ExtractionException("Could not parse json returned by url: " + getLinkHandler().getUrl(), jpe); + throw new ExtractionException("Could not parse json returned by url: " + + getLinkHandler().getUrl(), jpe); } } @@ -223,44 +234,44 @@ public class MediaCCCStreamExtractor extends StreamExtractor { @Nonnull @Override - public String getOriginalUrl() throws ParsingException { + public String getOriginalUrl() { return data.getString("frontend_link"); } @Override - public String getHost() throws ParsingException { + public String getHost() { return ""; } @Override - public String getPrivacy() throws ParsingException { + public String getPrivacy() { return ""; } @Override - public String getCategory() throws ParsingException { + public String getCategory() { return ""; } @Override - public String getLicence() throws ParsingException { + public String getLicence() { return ""; } @Override - public Locale getLanguageInfo() throws ParsingException { + public Locale getLanguageInfo() { return null; } @Nonnull @Override - public List getTags() throws ParsingException { + public List getTags() { return new ArrayList<>(); } @Nonnull @Override - public String getSupportInfo() throws ParsingException { + public String getSupportInfo() { return ""; } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSuggestionExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSuggestionExtractor.java deleted file mode 100644 index b84230758..000000000 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSuggestionExtractor.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.schabi.newpipe.extractor.services.media_ccc.extractors; - -import org.schabi.newpipe.extractor.StreamingService; -import org.schabi.newpipe.extractor.exceptions.ExtractionException; -import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class MediaCCCSuggestionExtractor extends SuggestionExtractor { - - public MediaCCCSuggestionExtractor(StreamingService service) { - super(service); - } - - @Override - public List suggestionList(String query) throws IOException, ExtractionException { - return new ArrayList<>(0); - } -} diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/infoItems/MediaCCCConferenceInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/infoItems/MediaCCCConferenceInfoItemExtractor.java index 05914dd75..9099cb1a7 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/infoItems/MediaCCCConferenceInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/infoItems/MediaCCCConferenceInfoItemExtractor.java @@ -5,25 +5,24 @@ import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor; import org.schabi.newpipe.extractor.exceptions.ParsingException; public class MediaCCCConferenceInfoItemExtractor implements ChannelInfoItemExtractor { + private JsonObject conference; - JsonObject conference; - - public MediaCCCConferenceInfoItemExtractor(JsonObject conference) { + public MediaCCCConferenceInfoItemExtractor(final JsonObject conference) { this.conference = conference; } @Override - public String getDescription() throws ParsingException { + public String getDescription() { return ""; } @Override - public long getSubscriberCount() throws ParsingException { + public long getSubscriberCount() { return -1; } @Override - public long getStreamCount() throws ParsingException { + public long getStreamCount() { return -1; } @@ -38,7 +37,7 @@ public class MediaCCCConferenceInfoItemExtractor implements ChannelInfoItemExtra } @Override - public String getThumbnailUrl() throws ParsingException { + public String getThumbnailUrl() { return conference.getString("logo_url"); } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/infoItems/MediaCCCStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/infoItems/MediaCCCStreamInfoItemExtractor.java index 76347b39b..23a6aa931 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/infoItems/MediaCCCStreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/infoItems/MediaCCCStreamInfoItemExtractor.java @@ -10,47 +10,46 @@ import org.schabi.newpipe.extractor.stream.StreamType; import javax.annotation.Nullable; public class MediaCCCStreamInfoItemExtractor implements StreamInfoItemExtractor { + private JsonObject event; - JsonObject event; - - public MediaCCCStreamInfoItemExtractor(JsonObject event) { + public MediaCCCStreamInfoItemExtractor(final JsonObject event) { this.event = event; } @Override - public StreamType getStreamType() throws ParsingException { + public StreamType getStreamType() { return StreamType.VIDEO_STREAM; } @Override - public boolean isAd() throws ParsingException { + public boolean isAd() { return false; } @Override - public long getDuration() throws ParsingException { + public long getDuration() { return event.getInt("length"); } @Override - public long getViewCount() throws ParsingException { + public long getViewCount() { return event.getInt("view_count"); } @Override - public String getUploaderName() throws ParsingException { + public String getUploaderName() { return event.getString("conference_url") - .replace("https://api.media.ccc.de/public/conferences/", ""); + .replaceFirst("https://(api\\.)?media\\.ccc\\.de/public/conferences/", ""); } @Override - public String getUploaderUrl() throws ParsingException { + public String getUploaderUrl() { return event.getString("conference_url"); } @Nullable @Override - public String getTextualUploadDate() throws ParsingException { + public String getTextualUploadDate() { return event.getString("release_date"); } @@ -67,12 +66,12 @@ public class MediaCCCStreamInfoItemExtractor implements StreamInfoItemExtractor @Override public String getUrl() throws ParsingException { - return "https://api.media.ccc.de/public/events/" + - event.getString("guid"); + return "https://media.ccc.de/public/events/" + + event.getString("guid"); } @Override - public String getThumbnailUrl() throws ParsingException { + public String getThumbnailUrl() { return event.getString("thumb_url"); } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCConferenceLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCConferenceLinkHandlerFactory.java index f4074c0d1..5dc903d88 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCConferenceLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCConferenceLinkHandlerFactory.java @@ -7,16 +7,17 @@ import org.schabi.newpipe.extractor.utils.Parser; import java.util.List; public class MediaCCCConferenceLinkHandlerFactory extends ListLinkHandlerFactory { - @Override - public String getUrl(String id, List contentFilter, String sortFilter) throws ParsingException { - return "https://api.media.ccc.de/public/conferences/" + id; + public String getUrl(final String id, final List contentFilter, final String sortFilter) + throws ParsingException { + return "https://media.ccc.de/public/conferences/" + id; } @Override - public String getId(String url) throws ParsingException { - if (url.startsWith("https://api.media.ccc.de/public/conferences/")) { - return url.replace("https://api.media.ccc.de/public/conferences/", ""); + public String getId(final String url) throws ParsingException { + if (url.startsWith("https://media.ccc.de/public/conferences/") + || url.startsWith("https://api.media.ccc.de/public/conferences/")) { + return url.replaceFirst("https://(api\\.)?media\\.ccc\\.de/public/conferences/", ""); } else if (url.startsWith("https://media.ccc.de/c/")) { return Parser.matchGroup1("https://media.ccc.de/c/([^?#]*)", url); } else if (url.startsWith("https://media.ccc.de/b/")) { @@ -26,7 +27,7 @@ public class MediaCCCConferenceLinkHandlerFactory extends ListLinkHandlerFactory } @Override - public boolean onAcceptUrl(String url) throws ParsingException { + public boolean onAcceptUrl(final String url) { try { getId(url); return true; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCConferencesListLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCConferencesListLinkHandlerFactory.java index d44dc538b..f5dc8c6cf 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCConferencesListLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCConferencesListLinkHandlerFactory.java @@ -7,18 +7,20 @@ import java.util.List; public class MediaCCCConferencesListLinkHandlerFactory extends ListLinkHandlerFactory { @Override - public String getId(String url) throws ParsingException { + public String getId(final String url) throws ParsingException { return "conferences"; } @Override - public String getUrl(String id, List contentFilter, String sortFilter) throws ParsingException { - return "https://api.media.ccc.de/public/conferences"; + public String getUrl(final String id, final List contentFilter, + final String sortFilter) throws ParsingException { + return "https://media.ccc.de/public/conferences"; } @Override - public boolean onAcceptUrl(String url) throws ParsingException { + public boolean onAcceptUrl(final String url) { return url.equals("https://media.ccc.de/b/conferences") + || url.equals("https://media.ccc.de/public/conferences") || url.equals("https://api.media.ccc.de/public/conferences"); } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCSearchQueryHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCSearchQueryHandlerFactory.java index dcc0b29bc..0fd62806a 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCSearchQueryHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCSearchQueryHandlerFactory.java @@ -8,7 +8,6 @@ import java.net.URLEncoder; import java.util.List; public class MediaCCCSearchQueryHandlerFactory extends SearchQueryHandlerFactory { - public static final String ALL = "all"; public static final String CONFERENCES = "conferences"; public static final String EVENTS = "events"; @@ -28,11 +27,13 @@ public class MediaCCCSearchQueryHandlerFactory extends SearchQueryHandlerFactory } @Override - public String getUrl(String querry, List contentFilter, String sortFilter) throws ParsingException { + public String getUrl(final String query, final List contentFilter, + final String sortFilter) throws ParsingException { try { - return "https://api.media.ccc.de/public/events/search?q=" + URLEncoder.encode(querry, "UTF-8"); + return "https://media.ccc.de/public/events/search?q=" + + URLEncoder.encode(query, "UTF-8"); } catch (UnsupportedEncodingException e) { - throw new ParsingException("Could not create search string with querry: " + querry, e); + throw new ParsingException("Could not create search string with querry: " + query, e); } } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCStreamLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCStreamLinkHandlerFactory.java index 2c91d0564..a335abf86 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCStreamLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCStreamLinkHandlerFactory.java @@ -1,6 +1,5 @@ package org.schabi.newpipe.extractor.services.media_ccc.linkHandler; -import org.schabi.newpipe.extractor.exceptions.FoundAdException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; import org.schabi.newpipe.extractor.utils.Utils; @@ -9,11 +8,15 @@ import java.net.MalformedURLException; import java.net.URL; public class MediaCCCStreamLinkHandlerFactory extends LinkHandlerFactory { - @Override - public String getId(String urlString) throws ParsingException { - if (urlString.startsWith("https://api.media.ccc.de/public/events/") && - !urlString.contains("?q=")) { + public String getId(final String urlString) throws ParsingException { + if (urlString.startsWith("https://media.ccc.de/public/events/") + && !urlString.contains("?q=")) { + return urlString.substring(35); //remove …/public/events part + } + + if (urlString.startsWith("https://api.media.ccc.de/public/events/") + && !urlString.contains("?q=")) { return urlString.substring(39); //remove api…/public/events part } @@ -38,12 +41,12 @@ public class MediaCCCStreamLinkHandlerFactory extends LinkHandlerFactory { } @Override - public String getUrl(String id) throws ParsingException { - return "https://api.media.ccc.de/public/events/" + id; + public String getUrl(final String id) throws ParsingException { + return "https://media.ccc.de/public/events/" + id; } @Override - public boolean onAcceptUrl(String url) throws ParsingException { + public boolean onAcceptUrl(final String url) { try { getId(url); return true; diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCConferenceExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCConferenceExtractorTest.java index 258a55b00..98b6203c9 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCConferenceExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCConferenceExtractorTest.java @@ -14,7 +14,6 @@ import static org.schabi.newpipe.extractor.ServiceList.MediaCCC; * Test {@link MediaCCCConferenceExtractor} */ public class MediaCCCConferenceExtractorTest { - public static class FrOSCon2017 { private static MediaCCCConferenceExtractor extractor; @@ -32,7 +31,7 @@ public class MediaCCCConferenceExtractorTest { @Test public void testGetUrl() throws Exception { - assertEquals("https://api.media.ccc.de/public/conferences/froscon2017", extractor.getUrl()); + assertEquals("https://media.ccc.de/public/conferences/froscon2017", extractor.getUrl()); } @Test @@ -68,7 +67,7 @@ public class MediaCCCConferenceExtractorTest { @Test public void testGetUrl() throws Exception { - assertEquals("https://api.media.ccc.de/public/conferences/oscal19", extractor.getUrl()); + assertEquals("https://media.ccc.de/public/conferences/oscal19", extractor.getUrl()); } @Test diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCOggTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCOggTest.java index 25116af32..21a49da32 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCOggTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCOggTest.java @@ -15,14 +15,14 @@ import static org.schabi.newpipe.extractor.ServiceList.MediaCCC; * Test {@link MediaCCCStreamExtractor} */ public class MediaCCCOggTest { - // test against https://api.media.ccc.de/public/events/1317 + // test against https://media.ccc.de/public/events/1317 private static StreamExtractor extractor; @BeforeClass public static void setUpClass() throws Exception { NewPipe.init(DownloaderTestImpl.getInstance()); - extractor = MediaCCC.getStreamExtractor("https://api.media.ccc.de/public/events/1317"); + extractor = MediaCCC.getStreamExtractor("https://media.ccc.de/public/events/1317"); extractor.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCStreamExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCStreamExtractorTest.java index 8120e07a8..f376b9f4d 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCStreamExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCStreamExtractorTest.java @@ -9,7 +9,6 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor; import org.schabi.newpipe.extractor.stream.AudioStream; import org.schabi.newpipe.extractor.stream.VideoStream; -import org.schabi.newpipe.extractor.utils.UtilsTest; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -25,7 +24,6 @@ import static org.schabi.newpipe.extractor.ServiceList.MediaCCC; * Test {@link MediaCCCStreamExtractor} */ public class MediaCCCStreamExtractorTest { - public static class Gpn18Tmux { private static MediaCCCStreamExtractor extractor; @@ -55,7 +53,7 @@ public class MediaCCCStreamExtractorTest { @Test public void testUrl() throws Exception { assertIsSecureUrl(extractor.getUrl()); - assertEquals("https://api.media.ccc.de/public/events/gpn18-105-tmux-warum-ein-schwarzes-fenster-am-bildschirm-reicht", extractor.getUrl()); + assertEquals("https://media.ccc.de/public/events/gpn18-105-tmux-warum-ein-schwarzes-fenster-am-bildschirm-reicht", extractor.getUrl()); } @Test @@ -141,7 +139,7 @@ public class MediaCCCStreamExtractorTest { @Test public void testUrl() throws Exception { assertIsSecureUrl(extractor.getUrl()); - assertEquals("https://api.media.ccc.de/public/events/36c3-10565-what_s_left_for_private_messaging", extractor.getUrl()); + assertEquals("https://media.ccc.de/public/events/36c3-10565-what_s_left_for_private_messaging", extractor.getUrl()); } @Test @@ -164,7 +162,7 @@ public class MediaCCCStreamExtractorTest { @Test public void testUploaderUrl() throws Exception { assertIsSecureUrl(extractor.getUploaderUrl()); - assertEquals("https://api.media.ccc.de/public/conferences/36c3", extractor.getUploaderUrl()); + assertEquals("https://media.ccc.de/public/conferences/36c3", extractor.getUploaderUrl()); } @Test @@ -203,4 +201,4 @@ public class MediaCCCStreamExtractorTest { assertEquals(instance, requireNonNull(extractor.getUploadDate()).date()); } } -} \ No newline at end of file +} diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/search/MediaCCCSearchExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/search/MediaCCCSearchExtractorTest.java index 812d6367a..50e0021c3 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/search/MediaCCCSearchExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/search/MediaCCCSearchExtractorTest.java @@ -16,7 +16,6 @@ import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaC import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.EVENTS; public class MediaCCCSearchExtractorTest { - public static class All extends DefaultSearchExtractorTest { private static SearchExtractor extractor; private static final String QUERY = "kde"; @@ -32,8 +31,8 @@ public class MediaCCCSearchExtractorTest { @Override public StreamingService expectedService() { return MediaCCC; } @Override public String expectedName() { return QUERY; } @Override public String expectedId() { return QUERY; } - @Override public String expectedUrlContains() { return "api.media.ccc.de/public/events/search?q=" + QUERY; } - @Override public String expectedOriginalUrlContains() { return "api.media.ccc.de/public/events/search?q=" + QUERY; } + @Override public String expectedUrlContains() { return "media.ccc.de/public/events/search?q=" + QUERY; } + @Override public String expectedOriginalUrlContains() { return "media.ccc.de/public/events/search?q=" + QUERY; } @Override public String expectedSearchString() { return QUERY; } @Nullable @Override public String expectedSearchSuggestion() { return null; } @@ -55,8 +54,8 @@ public class MediaCCCSearchExtractorTest { @Override public StreamingService expectedService() { return MediaCCC; } @Override public String expectedName() { return QUERY; } @Override public String expectedId() { return QUERY; } - @Override public String expectedUrlContains() { return "api.media.ccc.de/public/events/search?q=" + QUERY; } - @Override public String expectedOriginalUrlContains() { return "api.media.ccc.de/public/events/search?q=" + QUERY; } + @Override public String expectedUrlContains() { return "media.ccc.de/public/events/search?q=" + QUERY; } + @Override public String expectedOriginalUrlContains() { return "media.ccc.de/public/events/search?q=" + QUERY; } @Override public String expectedSearchString() { return QUERY; } @Nullable @Override public String expectedSearchSuggestion() { return null; } @@ -79,8 +78,8 @@ public class MediaCCCSearchExtractorTest { @Override public StreamingService expectedService() { return MediaCCC; } @Override public String expectedName() { return QUERY; } @Override public String expectedId() { return QUERY; } - @Override public String expectedUrlContains() { return "api.media.ccc.de/public/events/search?q=" + QUERY; } - @Override public String expectedOriginalUrlContains() { return "api.media.ccc.de/public/events/search?q=" + QUERY; } + @Override public String expectedUrlContains() { return "media.ccc.de/public/events/search?q=" + QUERY; } + @Override public String expectedOriginalUrlContains() { return "media.ccc.de/public/events/search?q=" + QUERY; } @Override public String expectedSearchString() { return QUERY; } @Nullable @Override public String expectedSearchSuggestion() { return null; }