rename search filters

This commit is contained in:
Christian Schabesberger 2018-07-19 16:06:44 +02:00
parent 8ee068fd98
commit 558a973e43
7 changed files with 23 additions and 80 deletions

View file

@ -15,7 +15,7 @@ public class SoundcloudSearchQueryHandlerFactory extends SearchQueryHandlerFacto
public static final String TRACKS = "tracks";
public static final String USERS = "users";
public static final String PLAYLIST = "playlist";
public static final String ANY = "any";
public static final String ALL = "all";
public static final int ITEMS_PER_PAGE = 10;
@ -35,7 +35,7 @@ public class SoundcloudSearchQueryHandlerFactory extends SearchQueryHandlerFacto
case PLAYLIST:
url += "/playlists";
break;
case ANY:
case ALL:
default:
break;
}
@ -58,7 +58,7 @@ public class SoundcloudSearchQueryHandlerFactory extends SearchQueryHandlerFacto
@Override
public String[] getAvailableContentFilter() {
return new String[] {
ANY,
ALL,
TRACKS,
USERS,
PLAYLIST};

View file

@ -11,10 +11,10 @@ public class YoutubeSearchQueryHandlerFactory extends SearchQueryHandlerFactory
public static final String CHARSET_UTF_8 = "UTF-8";
public static final String STREAM = "stream";
public static final String CHANNEL = "channel";
public static final String PLAYLIST = "playlist";
public static final String ANY = "any";
public static final String VIDEOS = "videos";
public static final String CHANNELS = "channels";
public static final String PLAYLISTS = "playlists";
public static final String ALL = "all";
public static YoutubeSearchQueryHandlerFactory getInstance() {
return new YoutubeSearchQueryHandlerFactory();
@ -28,10 +28,10 @@ public class YoutubeSearchQueryHandlerFactory extends SearchQueryHandlerFactory
if(contentFilters.size() > 0) {
switch (contentFilters.get(0)) {
case STREAM: return url + "&sp=EgIQAVAU";
case CHANNEL: return url + "&sp=EgIQAlAU";
case PLAYLIST: return url + "&sp=EgIQA1AU";
case ANY:
case VIDEOS: return url + "&sp=EgIQAVAU";
case CHANNELS: return url + "&sp=EgIQAlAU";
case PLAYLISTS: return url + "&sp=EgIQA1AU";
case ALL:
default:
}
}
@ -45,9 +45,9 @@ public class YoutubeSearchQueryHandlerFactory extends SearchQueryHandlerFactory
@Override
public String[] getAvailableContentFilter() {
return new String[] {
ANY,
STREAM,
CHANNEL,
PLAYLIST};
ALL,
VIDEOS,
CHANNELS,
PLAYLISTS};
}
}

View file

@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchExtractor;
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQueryHandlerFactory;
import static java.util.Arrays.asList;
import static org.junit.Assert.*;
@ -19,7 +20,7 @@ public class SoundcloudSearchExtractorChannelOnlyTest extends SoundcloudSearchEx
public static void setUpClass() throws Exception {
NewPipe.init(Downloader.getInstance());
extractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert",
asList(new String[]{"users"}), null, "de");
asList(SoundcloudSearchQueryHandlerFactory.USERS), null, "de");
extractor.fetchPage();
itemsPage = extractor.getInitialPage();
}
@ -27,7 +28,7 @@ public class SoundcloudSearchExtractorChannelOnlyTest extends SoundcloudSearchEx
@Test
public void testGetSecondPage() throws Exception {
SoundcloudSearchExtractor secondExtractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert",
asList(new String[]{"users"}), null, "de");
asList(SoundcloudSearchQueryHandlerFactory.USERS), null, "de");
ListExtractor.InfoItemsPage<InfoItem> secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl());
assertTrue(Integer.toString(secondPage.getItems().size()),
secondPage.getItems().size() >= 3);

View file

@ -1,59 +0,0 @@
package org.schabi.newpipe.extractor.services.youtube;
/*
* Created by Christian Schabesberger on 30.12.15.
*
* Copyright (C) Christian Schabesberger 2018 <chris.schabesberger@mailbox.org>
* YoutubeStreamExtractorDonationTest.java is part of NewPipe.
*
* NewPipe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NewPipe is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
import org.junit.BeforeClass;
import org.junit.Test;
import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/**
* Test for {@link StreamExtractor}
*/
public class YoutubeStreamExtractorDonationTest {
private static YoutubeStreamExtractor extractor;
@BeforeClass
public static void setUp() throws Exception {
NewPipe.init(Downloader.getInstance());
extractor = (YoutubeStreamExtractor) YouTube
.getStreamExtractor("https://www.youtube.com/watch?v=pXb3jERMoI0");
extractor.fetchPage();
}
@Test
public void getDonationLinksTest() throws Exception {
assertTrue(String.valueOf(extractor.getDonationLinks().length),
extractor.getDonationLinks().length == 2);
}
@Test
public void getAffiliateLinksTest() throws Exception {
assertTrue(String.valueOf(extractor.getAffiliateLinks().length),
extractor.getAffiliateLinks().length == 1);
}
}

View file

@ -43,7 +43,7 @@ public class YoutubeTrendingKioskInfoTest {
throws Exception {
NewPipe.init(Downloader.getInstance());
StreamingService service = YouTube;
LinkHandlerFactory LinkHandlerFactory = service.getKioskList().getUIHFactoryByType("Trending");
LinkHandlerFactory LinkHandlerFactory = service.getKioskList().getListLinkHandlerFactoryByType("Trending");
kioskInfo = KioskInfo.getInfo(YouTube, LinkHandlerFactory.fromId("Trending").getUrl(), null);
}

View file

@ -41,7 +41,7 @@ public class YoutubeTrendingLinkHandlerFactoryTest {
@BeforeClass
public static void setUp() throws Exception {
LinkHandlerFactory = YouTube.getKioskList().getUIHFactoryByType("Trending");
LinkHandlerFactory = YouTube.getKioskList().getListLinkHandlerFactoryByType("Trending");
NewPipe.init(Downloader.getInstance());
}

View file

@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory;
import static java.util.Arrays.asList;
import static org.junit.Assert.*;
@ -19,7 +20,7 @@ public class YoutubeSearchExtractorChannelOnlyTest extends YoutubeSearchExtracto
public static void setUpClass() throws Exception {
NewPipe.init(Downloader.getInstance());
extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie",
asList(new String[]{"channel"}), null, "de");
asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, "de");
extractor.fetchPage();
itemsPage = extractor.getInitialPage();
}
@ -27,7 +28,7 @@ public class YoutubeSearchExtractorChannelOnlyTest extends YoutubeSearchExtracto
@Test
public void testGetSecondPage() throws Exception {
YoutubeSearchExtractor secondExtractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie",
asList(new String[]{"channel"}), null, "de");
asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, "de");
ListExtractor.InfoItemsPage<InfoItem> secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl());
assertTrue(Integer.toString(secondPage.getItems().size()),
secondPage.getItems().size() > 10);