make search filter empty be equal to all

This commit is contained in:
Christian Schabesberger 2019-01-29 16:49:37 +01:00
parent d0efe8bd47
commit 79b0a19d1a
2 changed files with 9 additions and 9 deletions

View File

@ -6,7 +6,6 @@ import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException; import com.grack.nanojson.JsonParserException;
import org.schabi.newpipe.extractor.Downloader; import org.schabi.newpipe.extractor.Downloader;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.InfoItemsCollector;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor; 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.InfoItemsSearchCollector;
import org.schabi.newpipe.extractor.search.SearchExtractor; 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.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.services.media_ccc.linkHandler.MediaCCCConferencesListLinkHandlerFactory;
import org.schabi.newpipe.extractor.utils.Localization; import org.schabi.newpipe.extractor.utils.Localization;
import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.CONFERENCES; import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.CONFERENCES;
@ -54,14 +52,16 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
InfoItemsSearchCollector searchItems = getInfoItemSearchCollector(); InfoItemsSearchCollector searchItems = getInfoItemSearchCollector();
if(getLinkHandler().getContentFilters().contains(CONFERENCES) if(getLinkHandler().getContentFilters().contains(CONFERENCES)
|| getLinkHandler().getContentFilters().contains(ALL)) { || getLinkHandler().getContentFilters().contains(ALL)
|| getLinkHandler().getContentFilters().isEmpty()) {
searchConferences(getSearchString(), searchConferences(getSearchString(),
conferenceKiosk.getInitialPage().getItems(), conferenceKiosk.getInitialPage().getItems(),
searchItems); searchItems);
} }
if(getLinkHandler().getContentFilters().contains(EVENTS) if(getLinkHandler().getContentFilters().contains(EVENTS)
|| getLinkHandler().getContentFilters().contains(ALL)) { || getLinkHandler().getContentFilters().contains(ALL)
|| getLinkHandler().getContentFilters().isEmpty()) {
JsonArray events = doc.getArray("events"); JsonArray events = doc.getArray("events");
for (int i = 0; i < events.size(); i++) { for (int i = 0; i < events.size(); i++) {
searchItems.commit(new MediaCCCStreamInfoItemExtractor( searchItems.commit(new MediaCCCStreamInfoItemExtractor(
@ -84,7 +84,8 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
@Override @Override
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
if(getLinkHandler().getContentFilters().contains(EVENTS) if(getLinkHandler().getContentFilters().contains(EVENTS)
|| getLinkHandler().getContentFilters().contains(ALL)) { || getLinkHandler().getContentFilters().contains(ALL)
|| getLinkHandler().getContentFilters().isEmpty()) {
final String site; final String site;
final String url = getUrl(); final String url = getUrl();
site = downloader.download(url, getLocalization()); site = downloader.download(url, getLocalization());
@ -95,7 +96,8 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
} }
} }
if(getLinkHandler().getContentFilters().contains(CONFERENCES) if(getLinkHandler().getContentFilters().contains(CONFERENCES)
|| getLinkHandler().getContentFilters().contains(ALL)) || getLinkHandler().getContentFilters().contains(ALL)
|| getLinkHandler().getContentFilters().isEmpty())
conferenceKiosk.fetchPage(); conferenceKiosk.fetchPage();
} }

View File

@ -30,7 +30,7 @@ public class MediaCCCSearchExtractorAllTest {
public static void setUpClass() throws Exception { public static void setUpClass() throws Exception {
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
extractor = MediaCCC.getSearchExtractor( new MediaCCCSearchQueryHandlerFactory() extractor = MediaCCC.getSearchExtractor( new MediaCCCSearchQueryHandlerFactory()
.fromQuery("c3", Arrays.asList(new String[] {"all"}), "") .fromQuery("c3", Arrays.asList(new String[0]), "")
,new Localization("GB", "en")); ,new Localization("GB", "en"));
extractor.fetchPage(); extractor.fetchPage();
itemsPage = extractor.getInitialPage(); itemsPage = extractor.getInitialPage();
@ -40,7 +40,6 @@ public class MediaCCCSearchExtractorAllTest {
public void testIfChannelInfoItemsAvailable() { public void testIfChannelInfoItemsAvailable() {
boolean isAvialable = false; boolean isAvialable = false;
for(InfoItem item : itemsPage.getItems()) { for(InfoItem item : itemsPage.getItems()) {
System.out.println(item);
if(item instanceof ChannelInfoItem) { if(item instanceof ChannelInfoItem) {
isAvialable = true; isAvialable = true;
} }
@ -52,7 +51,6 @@ public class MediaCCCSearchExtractorAllTest {
public void testIfStreamInfoitemsAvailable() { public void testIfStreamInfoitemsAvailable() {
boolean isAvialable = false; boolean isAvialable = false;
for(InfoItem item : itemsPage.getItems()) { for(InfoItem item : itemsPage.getItems()) {
System.out.println(item);
if(item instanceof StreamInfoItem) { if(item instanceof StreamInfoItem) {
isAvialable = true; isAvialable = true;
} }