From 79b0a19d1af158a07abfd067e155d75f413fb834 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Tue, 29 Jan 2019 16:49:37 +0100 Subject: [PATCH] make search filter empty be equal to all --- .../extractors/MediaCCCSearchExtractor.java | 14 ++++++++------ .../media_ccc/MediaCCCSearchExtractorAllTest.java | 4 +--- 2 files changed, 9 insertions(+), 9 deletions(-) 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 ef008afd6..af6724b62 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 @@ -6,7 +6,6 @@ import com.grack.nanojson.JsonParser; import com.grack.nanojson.JsonParserException; import org.schabi.newpipe.extractor.Downloader; import org.schabi.newpipe.extractor.InfoItem; -import org.schabi.newpipe.extractor.InfoItemsCollector; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor; @@ -16,7 +15,6 @@ 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.MediaCCCConferenceLinkHandlerFactory; import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferencesListLinkHandlerFactory; import org.schabi.newpipe.extractor.utils.Localization; import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.CONFERENCES; @@ -54,14 +52,16 @@ public class MediaCCCSearchExtractor extends SearchExtractor { InfoItemsSearchCollector searchItems = getInfoItemSearchCollector(); if(getLinkHandler().getContentFilters().contains(CONFERENCES) - || getLinkHandler().getContentFilters().contains(ALL)) { + || getLinkHandler().getContentFilters().contains(ALL) + || getLinkHandler().getContentFilters().isEmpty()) { searchConferences(getSearchString(), conferenceKiosk.getInitialPage().getItems(), searchItems); } if(getLinkHandler().getContentFilters().contains(EVENTS) - || getLinkHandler().getContentFilters().contains(ALL)) { + || getLinkHandler().getContentFilters().contains(ALL) + || getLinkHandler().getContentFilters().isEmpty()) { JsonArray events = doc.getArray("events"); for (int i = 0; i < events.size(); i++) { searchItems.commit(new MediaCCCStreamInfoItemExtractor( @@ -84,7 +84,8 @@ public class MediaCCCSearchExtractor extends SearchExtractor { @Override public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { if(getLinkHandler().getContentFilters().contains(EVENTS) - || getLinkHandler().getContentFilters().contains(ALL)) { + || getLinkHandler().getContentFilters().contains(ALL) + || getLinkHandler().getContentFilters().isEmpty()) { final String site; final String url = getUrl(); site = downloader.download(url, getLocalization()); @@ -95,7 +96,8 @@ public class MediaCCCSearchExtractor extends SearchExtractor { } } if(getLinkHandler().getContentFilters().contains(CONFERENCES) - || getLinkHandler().getContentFilters().contains(ALL)) + || getLinkHandler().getContentFilters().contains(ALL) + || getLinkHandler().getContentFilters().isEmpty()) conferenceKiosk.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCSearchExtractorAllTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCSearchExtractorAllTest.java index 9ce475b4a..8dfdb0a92 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCSearchExtractorAllTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCSearchExtractorAllTest.java @@ -30,7 +30,7 @@ public class MediaCCCSearchExtractorAllTest { public static void setUpClass() throws Exception { NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = MediaCCC.getSearchExtractor( new MediaCCCSearchQueryHandlerFactory() - .fromQuery("c3", Arrays.asList(new String[] {"all"}), "") + .fromQuery("c3", Arrays.asList(new String[0]), "") ,new Localization("GB", "en")); extractor.fetchPage(); itemsPage = extractor.getInitialPage(); @@ -40,7 +40,6 @@ public class MediaCCCSearchExtractorAllTest { public void testIfChannelInfoItemsAvailable() { boolean isAvialable = false; for(InfoItem item : itemsPage.getItems()) { - System.out.println(item); if(item instanceof ChannelInfoItem) { isAvialable = true; } @@ -52,7 +51,6 @@ public class MediaCCCSearchExtractorAllTest { public void testIfStreamInfoitemsAvailable() { boolean isAvialable = false; for(InfoItem item : itemsPage.getItems()) { - System.out.println(item); if(item instanceof StreamInfoItem) { isAvialable = true; }