rename search filters
This commit is contained in:
parent
8ee068fd98
commit
558a973e43
7 changed files with 23 additions and 80 deletions
|
@ -15,7 +15,7 @@ public class SoundcloudSearchQueryHandlerFactory extends SearchQueryHandlerFacto
|
||||||
public static final String TRACKS = "tracks";
|
public static final String TRACKS = "tracks";
|
||||||
public static final String USERS = "users";
|
public static final String USERS = "users";
|
||||||
public static final String PLAYLIST = "playlist";
|
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;
|
public static final int ITEMS_PER_PAGE = 10;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ public class SoundcloudSearchQueryHandlerFactory extends SearchQueryHandlerFacto
|
||||||
case PLAYLIST:
|
case PLAYLIST:
|
||||||
url += "/playlists";
|
url += "/playlists";
|
||||||
break;
|
break;
|
||||||
case ANY:
|
case ALL:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public class SoundcloudSearchQueryHandlerFactory extends SearchQueryHandlerFacto
|
||||||
@Override
|
@Override
|
||||||
public String[] getAvailableContentFilter() {
|
public String[] getAvailableContentFilter() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
ANY,
|
ALL,
|
||||||
TRACKS,
|
TRACKS,
|
||||||
USERS,
|
USERS,
|
||||||
PLAYLIST};
|
PLAYLIST};
|
||||||
|
|
|
@ -11,10 +11,10 @@ public class YoutubeSearchQueryHandlerFactory extends SearchQueryHandlerFactory
|
||||||
|
|
||||||
public static final String CHARSET_UTF_8 = "UTF-8";
|
public static final String CHARSET_UTF_8 = "UTF-8";
|
||||||
|
|
||||||
public static final String STREAM = "stream";
|
public static final String VIDEOS = "videos";
|
||||||
public static final String CHANNEL = "channel";
|
public static final String CHANNELS = "channels";
|
||||||
public static final String PLAYLIST = "playlist";
|
public static final String PLAYLISTS = "playlists";
|
||||||
public static final String ANY = "any";
|
public static final String ALL = "all";
|
||||||
|
|
||||||
public static YoutubeSearchQueryHandlerFactory getInstance() {
|
public static YoutubeSearchQueryHandlerFactory getInstance() {
|
||||||
return new YoutubeSearchQueryHandlerFactory();
|
return new YoutubeSearchQueryHandlerFactory();
|
||||||
|
@ -28,10 +28,10 @@ public class YoutubeSearchQueryHandlerFactory extends SearchQueryHandlerFactory
|
||||||
|
|
||||||
if(contentFilters.size() > 0) {
|
if(contentFilters.size() > 0) {
|
||||||
switch (contentFilters.get(0)) {
|
switch (contentFilters.get(0)) {
|
||||||
case STREAM: return url + "&sp=EgIQAVAU";
|
case VIDEOS: return url + "&sp=EgIQAVAU";
|
||||||
case CHANNEL: return url + "&sp=EgIQAlAU";
|
case CHANNELS: return url + "&sp=EgIQAlAU";
|
||||||
case PLAYLIST: return url + "&sp=EgIQA1AU";
|
case PLAYLISTS: return url + "&sp=EgIQA1AU";
|
||||||
case ANY:
|
case ALL:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,9 @@ public class YoutubeSearchQueryHandlerFactory extends SearchQueryHandlerFactory
|
||||||
@Override
|
@Override
|
||||||
public String[] getAvailableContentFilter() {
|
public String[] getAvailableContentFilter() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
ANY,
|
ALL,
|
||||||
STREAM,
|
VIDEOS,
|
||||||
CHANNEL,
|
CHANNELS,
|
||||||
PLAYLIST};
|
PLAYLISTS};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.ListExtractor;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||||
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchExtractor;
|
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQueryHandlerFactory;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
@ -19,7 +20,7 @@ public class SoundcloudSearchExtractorChannelOnlyTest extends SoundcloudSearchEx
|
||||||
public static void setUpClass() throws Exception {
|
public static void setUpClass() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert",
|
extractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert",
|
||||||
asList(new String[]{"users"}), null, "de");
|
asList(SoundcloudSearchQueryHandlerFactory.USERS), null, "de");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
itemsPage = extractor.getInitialPage();
|
itemsPage = extractor.getInitialPage();
|
||||||
}
|
}
|
||||||
|
@ -27,7 +28,7 @@ public class SoundcloudSearchExtractorChannelOnlyTest extends SoundcloudSearchEx
|
||||||
@Test
|
@Test
|
||||||
public void testGetSecondPage() throws Exception {
|
public void testGetSecondPage() throws Exception {
|
||||||
SoundcloudSearchExtractor secondExtractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert",
|
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());
|
ListExtractor.InfoItemsPage<InfoItem> secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl());
|
||||||
assertTrue(Integer.toString(secondPage.getItems().size()),
|
assertTrue(Integer.toString(secondPage.getItems().size()),
|
||||||
secondPage.getItems().size() >= 3);
|
secondPage.getItems().size() >= 3);
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -43,7 +43,7 @@ public class YoutubeTrendingKioskInfoTest {
|
||||||
throws Exception {
|
throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
StreamingService service = YouTube;
|
StreamingService service = YouTube;
|
||||||
LinkHandlerFactory LinkHandlerFactory = service.getKioskList().getUIHFactoryByType("Trending");
|
LinkHandlerFactory LinkHandlerFactory = service.getKioskList().getListLinkHandlerFactoryByType("Trending");
|
||||||
|
|
||||||
kioskInfo = KioskInfo.getInfo(YouTube, LinkHandlerFactory.fromId("Trending").getUrl(), null);
|
kioskInfo = KioskInfo.getInfo(YouTube, LinkHandlerFactory.fromId("Trending").getUrl(), null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class YoutubeTrendingLinkHandlerFactoryTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
LinkHandlerFactory = YouTube.getKioskList().getUIHFactoryByType("Trending");
|
LinkHandlerFactory = YouTube.getKioskList().getListLinkHandlerFactoryByType("Trending");
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.ListExtractor;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor;
|
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 java.util.Arrays.asList;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
@ -19,7 +20,7 @@ public class YoutubeSearchExtractorChannelOnlyTest extends YoutubeSearchExtracto
|
||||||
public static void setUpClass() throws Exception {
|
public static void setUpClass() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie",
|
extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie",
|
||||||
asList(new String[]{"channel"}), null, "de");
|
asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, "de");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
itemsPage = extractor.getInitialPage();
|
itemsPage = extractor.getInitialPage();
|
||||||
}
|
}
|
||||||
|
@ -27,7 +28,7 @@ public class YoutubeSearchExtractorChannelOnlyTest extends YoutubeSearchExtracto
|
||||||
@Test
|
@Test
|
||||||
public void testGetSecondPage() throws Exception {
|
public void testGetSecondPage() throws Exception {
|
||||||
YoutubeSearchExtractor secondExtractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie",
|
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());
|
ListExtractor.InfoItemsPage<InfoItem> secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl());
|
||||||
assertTrue(Integer.toString(secondPage.getItems().size()),
|
assertTrue(Integer.toString(secondPage.getItems().size()),
|
||||||
secondPage.getItems().size() > 10);
|
secondPage.getItems().size() > 10);
|
||||||
|
|
Loading…
Reference in a new issue