From f3865445f5cf6d2ba00b3a91ae96f6c6cfe80c41 Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Sat, 10 Feb 2018 00:46:05 -0200 Subject: [PATCH] Improve ServiceList class - [Minor] Fix wrong arguments order in KioskInfo --- .../org/schabi/newpipe/extractor/NewPipe.java | 31 ++++++------- .../schabi/newpipe/extractor/ServiceList.java | 44 +++++++++---------- .../newpipe/extractor/StreamingService.java | 31 ++++++++++--- .../extractor/channel/ChannelInfo.java | 11 +---- .../newpipe/extractor/kiosk/KioskInfo.java | 20 +++------ .../extractor/playlist/PlaylistInfo.java | 12 ++--- .../soundcloud/SoundcloudService.java | 11 +++-- .../services/youtube/YoutubeService.java | 8 ++-- .../newpipe/extractor/stream/StreamInfo.java | 4 -- .../schabi/newpipe/extractor/NewPipeTest.java | 44 +++++++++---------- .../SoundcloudChannelExtractorTest.java | 2 +- .../SoundcloudChartsExtractorTest.java | 11 ++--- .../SoundcloudPlaylistExtractorTest.java | 2 +- .../SoundcloudSearchEngineAllTest.java | 3 +- .../SoundcloudSearchEngineChannelTest.java | 6 +-- .../SoundcloudSearchEnginePlaylistTest.java | 6 +-- .../SoundcloudSearchEngineStreamTest.java | 6 +-- .../SoundcloudStreamExtractorDefaultTest.java | 5 +-- .../SoundcloudSuggestionExtractorTest.java | 2 +- .../youtube/YoutubeChannelExtractorTest.java | 3 +- .../youtube/YoutubePlaylistExtractorTest.java | 4 +- .../youtube/YoutubeSearchEngineAllTest.java | 9 +--- .../YoutubeSearchEngineChannelTest.java | 7 ++- .../YoutubeSearchEnginePlaylistTest.java | 7 ++- .../YoutubeSearchEngineStreamTest.java | 7 ++- .../services/youtube/YoutubeServiceTest.java | 2 +- .../YoutubeStreamExtractorDefaultTest.java | 4 +- .../YoutubeStreamExtractorGemaTest.java | 2 +- .../YoutubeStreamExtractorRestrictedTest.java | 4 +- .../YoutubeSuggestionExtractorTest.java | 2 +- .../youtube/YoutubeTrendingExtractorTest.java | 6 +-- ...java => YoutubeTrendingKioskInfoTest.java} | 9 ++-- .../YoutubeTrendingUrlIdHandlerTest.java | 5 +-- 33 files changed, 153 insertions(+), 177 deletions(-) rename src/test/java/org/schabi/newpipe/extractor/services/youtube/{YoutubeTreindingKioskInfoTest.java => YoutubeTrendingKioskInfoTest.java} (86%) diff --git a/src/main/java/org/schabi/newpipe/extractor/NewPipe.java b/src/main/java/org/schabi/newpipe/extractor/NewPipe.java index 7b4057d9..0a6363f1 100644 --- a/src/main/java/org/schabi/newpipe/extractor/NewPipe.java +++ b/src/main/java/org/schabi/newpipe/extractor/NewPipe.java @@ -22,6 +22,8 @@ package org.schabi.newpipe.extractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import java.util.List; + /** * Provides access to streaming services supported by NewPipe. */ @@ -44,37 +46,32 @@ public class NewPipe { // Utils //////////////////////////////////////////////////////////////////////////*/ - public static StreamingService[] getServices() { - final ServiceList[] values = ServiceList.values(); - final StreamingService[] streamingServices = new StreamingService[values.length]; - - for (int i = 0; i < values.length; i++) streamingServices[i] = values[i].getService(); - - return streamingServices; + public static List getServices() { + return ServiceList.all(); } public static StreamingService getService(int serviceId) throws ExtractionException { - for (ServiceList item : ServiceList.values()) { - if (item.getService().getServiceId() == serviceId) { - return item.getService(); + for (StreamingService service : ServiceList.all()) { + if (service.getServiceId() == serviceId) { + return service; } } throw new ExtractionException("There's no service with the id = \"" + serviceId + "\""); } public static StreamingService getService(String serviceName) throws ExtractionException { - for (ServiceList item : ServiceList.values()) { - if (item.getService().getServiceInfo().name.equals(serviceName)) { - return item.getService(); + for (StreamingService service : ServiceList.all()) { + if (service.getServiceInfo().getName().equals(serviceName)) { + return service; } } throw new ExtractionException("There's no service with the name = \"" + serviceName + "\""); } public static StreamingService getServiceByUrl(String url) throws ExtractionException { - for (ServiceList item : ServiceList.values()) { - if (item.getService().getLinkTypeByUrl(url) != StreamingService.LinkType.NONE) { - return item.getService(); + for (StreamingService service : ServiceList.all()) { + if (service.getLinkTypeByUrl(url) != StreamingService.LinkType.NONE) { + return service; } } throw new ExtractionException("No service can handle the url = \"" + url + "\""); @@ -92,7 +89,7 @@ public class NewPipe { public static String getNameOfService(int id) { try { //noinspection ConstantConditions - return getService(id).getServiceInfo().name; + return getService(id).getServiceInfo().getName(); } catch (Exception e) { System.err.println("Service id not known"); e.printStackTrace(); diff --git a/src/main/java/org/schabi/newpipe/extractor/ServiceList.java b/src/main/java/org/schabi/newpipe/extractor/ServiceList.java index 1f493e40..a49905e0 100644 --- a/src/main/java/org/schabi/newpipe/extractor/ServiceList.java +++ b/src/main/java/org/schabi/newpipe/extractor/ServiceList.java @@ -3,34 +3,34 @@ package org.schabi.newpipe.extractor; import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudService; import org.schabi.newpipe.extractor.services.youtube.YoutubeService; +import java.util.List; + +import static java.util.Arrays.asList; +import static java.util.Collections.unmodifiableList; + /** * A list of supported services. */ -public enum ServiceList { - YouTube(new YoutubeService(0, "YouTube")), - SoundCloud(new SoundcloudService(1, "SoundCloud")); -// DailyMotion(new DailyMotionService(2, "DailyMotion")); - - private final StreamingService service; - - ServiceList(StreamingService service) { - this.service = service; +public final class ServiceList { + private ServiceList() { + //no instance } - public StreamingService getService() { - return service; - } + public static final YoutubeService YouTube; + public static final SoundcloudService SoundCloud; - public StreamingService.ServiceInfo getServiceInfo() { - return service.getServiceInfo(); - } + private static final List SERVICES = unmodifiableList(asList( + YouTube = new YoutubeService(0), + SoundCloud = new SoundcloudService(1) + // DailyMotion = new DailyMotionService(2); + )); - public int getId() { - return service.getServiceId(); - } - - @Override - public String toString() { - return service.getServiceInfo().name; + /** + * Get all the supported services. + * + * @return a unmodifiable list of all the supported services + */ + public static List all() { + return SERVICES; } } diff --git a/src/main/java/org/schabi/newpipe/extractor/StreamingService.java b/src/main/java/org/schabi/newpipe/extractor/StreamingService.java index 53935ba9..8bd02d4a 100644 --- a/src/main/java/org/schabi/newpipe/extractor/StreamingService.java +++ b/src/main/java/org/schabi/newpipe/extractor/StreamingService.java @@ -8,13 +8,29 @@ import org.schabi.newpipe.extractor.search.SearchEngine; import org.schabi.newpipe.extractor.stream.StreamExtractor; import java.io.IOException; +import java.util.Collections; +import java.util.List; public abstract class StreamingService { - public class ServiceInfo { - public final String name; + public static class ServiceInfo { + private final String name; + private final List mediaCapabilities; - public ServiceInfo(String name) { + public ServiceInfo(String name, List mediaCapabilities) { this.name = name; + this.mediaCapabilities = Collections.unmodifiableList(mediaCapabilities); + } + + public String getName() { + return name; + } + + public List getMediaCapabilities() { + return mediaCapabilities; + } + + public enum MediaCapability { + AUDIO, VIDEO, LIVE } } @@ -28,9 +44,9 @@ public abstract class StreamingService { private final int serviceId; private final ServiceInfo serviceInfo; - public StreamingService(int id, String name) { + public StreamingService(int id, String name, List capabilities) { this.serviceId = id; - this.serviceInfo = new ServiceInfo(name); + this.serviceInfo = new ServiceInfo(name, capabilities); } public final int getServiceId() { @@ -41,6 +57,11 @@ public abstract class StreamingService { return serviceInfo; } + @Override + public String toString() { + return serviceId + ":" + serviceInfo.getName(); + } + public abstract UrlIdHandler getStreamUrlIdHandler(); public abstract UrlIdHandler getChannelUrlIdHandler(); public abstract UrlIdHandler getPlaylistUrlIdHandler(); diff --git a/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java b/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java index 957d3d44..07b1aa05 100644 --- a/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java +++ b/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java @@ -3,7 +3,6 @@ package org.schabi.newpipe.extractor.channel; import org.schabi.newpipe.extractor.ListExtractor.NextItemsResult; import org.schabi.newpipe.extractor.ListInfo; import org.schabi.newpipe.extractor.NewPipe; -import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; @@ -38,11 +37,7 @@ public class ChannelInfo extends ListInfo { } - public static NextItemsResult getMoreItems(ServiceList serviceItem, String url, String nextStreamsUrl) throws IOException, ExtractionException { - return getMoreItems(serviceItem.getService(), url, nextStreamsUrl); - } - - public static NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException { + public static NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl, String contentLanguage) throws IOException, ExtractionException { return service.getChannelExtractor(url, nextStreamsUrl).getNextStreams(); } @@ -50,10 +45,6 @@ public class ChannelInfo extends ListInfo { return getInfo(NewPipe.getServiceByUrl(url), url); } - public static ChannelInfo getInfo(ServiceList serviceItem, String url) throws IOException, ExtractionException { - return getInfo(serviceItem.getService(), url); - } - public static ChannelInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException { ChannelExtractor extractor = service.getChannelExtractor(url); extractor.fetchPage(); diff --git a/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java b/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java index 6c3e744b..e1347c20 100644 --- a/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java +++ b/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java @@ -20,7 +20,10 @@ package org.schabi.newpipe.extractor.kiosk; * along with NewPipe. If not, see . */ -import org.schabi.newpipe.extractor.*; +import org.schabi.newpipe.extractor.ListExtractor; +import org.schabi.newpipe.extractor.ListInfo; +import org.schabi.newpipe.extractor.NewPipe; +import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.utils.ExtractorHelper; @@ -32,13 +35,6 @@ public class KioskInfo extends ListInfo { super(serviceId, id, url, name); } - public static ListExtractor.NextItemsResult getMoreItems(ServiceList serviceItem, - String url, - String nextStreamsUrl, - String contentCountry) throws IOException, ExtractionException { - return getMoreItems(serviceItem.getService(), url, nextStreamsUrl, contentCountry); - } - public static ListExtractor.NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl, @@ -54,12 +50,6 @@ public class KioskInfo extends ListInfo { return getInfo(NewPipe.getServiceByUrl(url), url, contentCountry); } - public static KioskInfo getInfo(ServiceList serviceItem, - String url, - String contentContry) throws IOException, ExtractionException { - return getInfo(serviceItem.getService(), url, contentContry); - } - public static KioskInfo getInfo(StreamingService service, String url, String contentCountry) throws IOException, ExtractionException { @@ -82,7 +72,7 @@ public class KioskInfo extends ListInfo { String id = extractor.getId(); String url = extractor.getCleanUrl(); - KioskInfo info = new KioskInfo(serviceId, name, id, url); + KioskInfo info = new KioskInfo(serviceId, id, name, url); info.related_streams = ExtractorHelper.getStreamsOrLogError(info, extractor); diff --git a/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java b/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java index 8297c58a..8124aa63 100644 --- a/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java +++ b/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java @@ -1,7 +1,9 @@ package org.schabi.newpipe.extractor.playlist; -import org.schabi.newpipe.extractor.*; import org.schabi.newpipe.extractor.ListExtractor.NextItemsResult; +import org.schabi.newpipe.extractor.ListInfo; +import org.schabi.newpipe.extractor.NewPipe; +import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; @@ -15,10 +17,6 @@ public class PlaylistInfo extends ListInfo { super(serviceId, id, url, name); } - public static NextItemsResult getMoreItems(ServiceList serviceItem, String url, String nextStreamsUrl) throws IOException, ExtractionException { - return getMoreItems(serviceItem.getService(), url, nextStreamsUrl); - } - public static NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException { return service.getPlaylistExtractor(url, nextStreamsUrl).getNextStreams(); } @@ -27,10 +25,6 @@ public class PlaylistInfo extends ListInfo { return getInfo(NewPipe.getServiceByUrl(url), url); } - public static PlaylistInfo getInfo(ServiceList serviceItem, String url) throws IOException, ExtractionException { - return getInfo(serviceItem.getService(), url); - } - public static PlaylistInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException { PlaylistExtractor extractor = service.getPlaylistExtractor(url); extractor.fetchPage(); diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java index 9e14c569..4d86233d 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java @@ -1,7 +1,5 @@ package org.schabi.newpipe.extractor.services.soundcloud; -import java.io.IOException; - import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.SuggestionExtractor; import org.schabi.newpipe.extractor.UrlIdHandler; @@ -13,10 +11,15 @@ import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.search.SearchEngine; import org.schabi.newpipe.extractor.stream.StreamExtractor; +import java.io.IOException; + +import static java.util.Collections.singletonList; +import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO; + public class SoundcloudService extends StreamingService { - public SoundcloudService(int id, String name) { - super(id, name); + public SoundcloudService(int id) { + super(id, "SoundCloud", singletonList(AUDIO)); } @Override diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java index 19cbc9d8..26f1e746 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java @@ -13,6 +13,9 @@ import org.schabi.newpipe.extractor.stream.StreamExtractor; import java.io.IOException; +import static java.util.Arrays.asList; +import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.*; + /* * Created by Christian Schabesberger on 23.08.15. @@ -36,8 +39,8 @@ import java.io.IOException; public class YoutubeService extends StreamingService { - public YoutubeService(int id, String name) { - super(id, name); + public YoutubeService(int id) { + super(id, "YouTube", asList(AUDIO, VIDEO, LIVE)); } @Override @@ -60,7 +63,6 @@ public class YoutubeService extends StreamingService { return YoutubePlaylistUrlIdHandler.getInstance(); } - @Override public StreamExtractor getStreamExtractor(String url) throws IOException, ExtractionException { return new YoutubeStreamExtractor(this, url); diff --git a/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java b/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java index 995bfb00..9119cc21 100644 --- a/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java +++ b/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java @@ -232,10 +232,6 @@ public class StreamInfo extends Info { return getInfo(NewPipe.getServiceByUrl(url), url); } - public static StreamInfo getInfo(ServiceList serviceItem, String url) throws IOException, ExtractionException { - return getInfo(serviceItem.getService(), url); - } - public static StreamInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException { return getInfo(service.getStreamExtractor(url)); } diff --git a/src/test/java/org/schabi/newpipe/extractor/NewPipeTest.java b/src/test/java/org/schabi/newpipe/extractor/NewPipeTest.java index eb367b29..b2c50fb8 100644 --- a/src/test/java/org/schabi/newpipe/extractor/NewPipeTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/NewPipeTest.java @@ -12,14 +12,14 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube; public class NewPipeTest { @Test public void getAllServicesTest() throws Exception { - assertEquals(NewPipe.getServices().length, ServiceList.values().length); + assertEquals(NewPipe.getServices().size(), ServiceList.all().size()); } @Test public void testAllServicesHaveDifferentId() throws Exception { HashSet servicesId = new HashSet<>(); for (StreamingService streamingService : NewPipe.getServices()) { - String errorMsg = "There are services with the same id = " + streamingService.getServiceId() + " (current service > " + streamingService.getServiceInfo().name + ")"; + String errorMsg = "There are services with the same id = " + streamingService.getServiceId() + " (current service > " + streamingService.getServiceInfo().getName() + ")"; assertTrue(errorMsg, servicesId.add(streamingService.getServiceId())); } @@ -27,46 +27,46 @@ public class NewPipeTest { @Test public void getServiceWithId() throws Exception { - assertEquals(NewPipe.getService(YouTube.getId()), YouTube.getService()); - assertEquals(NewPipe.getService(SoundCloud.getId()), SoundCloud.getService()); + assertEquals(NewPipe.getService(YouTube.getServiceId()), YouTube); + assertEquals(NewPipe.getService(SoundCloud.getServiceId()), SoundCloud); - assertNotEquals(NewPipe.getService(SoundCloud.getId()), YouTube.getService()); + assertNotEquals(NewPipe.getService(SoundCloud.getServiceId()), YouTube); } @Test public void getServiceWithName() throws Exception { - assertEquals(NewPipe.getService(YouTube.getServiceInfo().name), YouTube.getService()); - assertEquals(NewPipe.getService(SoundCloud.getServiceInfo().name), SoundCloud.getService()); + assertEquals(NewPipe.getService(YouTube.getServiceInfo().getName()), YouTube); + assertEquals(NewPipe.getService(SoundCloud.getServiceInfo().getName()), SoundCloud); - assertNotEquals(NewPipe.getService(YouTube.getServiceInfo().name), SoundCloud.getService()); + assertNotEquals(NewPipe.getService(YouTube.getServiceInfo().getName()), SoundCloud); } @Test public void getServiceWithUrl() throws Exception { - assertEquals(getServiceByUrl("https://www.youtube.com/watch?v=_r6CgaFNAGg"), YouTube.getService()); - assertEquals(getServiceByUrl("https://www.youtube.com/channel/UCi2bIyFtz-JdI-ou8kaqsqg"), YouTube.getService()); - assertEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), YouTube.getService()); - assertEquals(getServiceByUrl("https://soundcloud.com/shupemoosic/pegboard-nerds-try-this"), SoundCloud.getService()); - assertEquals(getServiceByUrl("https://soundcloud.com/deluxe314/sets/pegboard-nerds"), SoundCloud.getService()); - assertEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), SoundCloud.getService()); + assertEquals(getServiceByUrl("https://www.youtube.com/watch?v=_r6CgaFNAGg"), YouTube); + assertEquals(getServiceByUrl("https://www.youtube.com/channel/UCi2bIyFtz-JdI-ou8kaqsqg"), YouTube); + assertEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), YouTube); + assertEquals(getServiceByUrl("https://soundcloud.com/shupemoosic/pegboard-nerds-try-this"), SoundCloud); + assertEquals(getServiceByUrl("https://soundcloud.com/deluxe314/sets/pegboard-nerds"), SoundCloud); + assertEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), SoundCloud); - assertNotEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), YouTube.getService()); - assertNotEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), SoundCloud.getService()); + assertNotEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), YouTube); + assertNotEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), SoundCloud); } @Test public void getIdWithServiceName() throws Exception { - assertEquals(NewPipe.getIdOfService(YouTube.getServiceInfo().name), YouTube.getId()); - assertEquals(NewPipe.getIdOfService(SoundCloud.getServiceInfo().name), SoundCloud.getId()); + assertEquals(NewPipe.getIdOfService(YouTube.getServiceInfo().getName()), YouTube.getServiceId()); + assertEquals(NewPipe.getIdOfService(SoundCloud.getServiceInfo().getName()), SoundCloud.getServiceId()); - assertNotEquals(NewPipe.getIdOfService(SoundCloud.getServiceInfo().name), YouTube.getId()); + assertNotEquals(NewPipe.getIdOfService(SoundCloud.getServiceInfo().getName()), YouTube.getServiceId()); } @Test public void getServiceNameWithId() throws Exception { - assertEquals(NewPipe.getNameOfService(YouTube.getId()), YouTube.getServiceInfo().name); - assertEquals(NewPipe.getNameOfService(SoundCloud.getId()), SoundCloud.getServiceInfo().name); + assertEquals(NewPipe.getNameOfService(YouTube.getServiceId()), YouTube.getServiceInfo().getName()); + assertEquals(NewPipe.getNameOfService(SoundCloud.getServiceId()), SoundCloud.getServiceInfo().getName()); - assertNotEquals(NewPipe.getNameOfService(YouTube.getId()), SoundCloud.getServiceInfo().name); + assertNotEquals(NewPipe.getNameOfService(YouTube.getServiceId()), SoundCloud.getServiceInfo().getName()); } } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java index 1272842a..42e9420e 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java @@ -22,7 +22,7 @@ public class SoundcloudChannelExtractorTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - extractor = SoundCloud.getService() + extractor = SoundCloud .getChannelExtractor("https://soundcloud.com/liluzivert"); extractor.fetchPage(); } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java index a7d0a5c3..565bdac9 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java @@ -1,11 +1,5 @@ package org.schabi.newpipe.extractor.services.soundcloud; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; - import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; @@ -14,6 +8,9 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.kiosk.KioskExtractor; import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; +import static org.junit.Assert.*; +import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; + /** * Test for {@link SoundcloudChartsUrlIdHandler} */ @@ -24,7 +21,7 @@ public class SoundcloudChartsExtractorTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - extractor = SoundCloud.getService() + extractor = SoundCloud .getKioskList() .getExtractorById("Top 50", null); extractor.fetchPage(); diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java index 9813c474..52aef60a 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java @@ -21,7 +21,7 @@ public class SoundcloudPlaylistExtractorTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - extractor = SoundCloud.getService() + extractor = SoundCloud .getPlaylistExtractor("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r"); extractor.fetchPage(); } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngineAllTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngineAllTest.java index 0620b0d5..8e920115 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngineAllTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngineAllTest.java @@ -7,7 +7,6 @@ import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.search.SearchEngine; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; @@ -19,7 +18,7 @@ public class SoundcloudSearchEngineAllTest extends BaseSoundcloudSearchTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - SearchEngine engine = SoundCloud.getService().getSearchEngine(); + SearchEngine engine = SoundCloud.getSearchEngine(); // SoundCloud will suggest "lil uzi vert" instead of "lill uzi vert" // keep in mind that the suggestions can NOT change by country (the parameter "de") diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngineChannelTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngineChannelTest.java index 488b2e96..44c395d5 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngineChannelTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngineChannelTest.java @@ -7,9 +7,9 @@ import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.search.SearchEngine; -import org.schabi.newpipe.extractor.search.SearchResult; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; /** @@ -20,7 +20,7 @@ public class SoundcloudSearchEngineChannelTest extends BaseSoundcloudSearchTest @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - SearchEngine engine = SoundCloud.getService().getSearchEngine(); + SearchEngine engine = SoundCloud.getSearchEngine(); // SoundCloud will suggest "lil uzi vert" instead of "lill uzi vert" // keep in mind that the suggestions can NOT change by country (the parameter "de") diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEnginePlaylistTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEnginePlaylistTest.java index 074cfbbf..492911d4 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEnginePlaylistTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEnginePlaylistTest.java @@ -7,9 +7,9 @@ import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.search.SearchEngine; -import org.schabi.newpipe.extractor.search.SearchResult; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; @@ -41,7 +41,7 @@ public class SoundcloudSearchEnginePlaylistTest extends BaseSoundcloudSearchTest @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - SearchEngine engine = SoundCloud.getService().getSearchEngine(); + SearchEngine engine = SoundCloud.getSearchEngine(); // Search by country not yet implemented result = engine.search("parkmemme", 0, "", SearchEngine.Filter.PLAYLIST) diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngineStreamTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngineStreamTest.java index b4439afe..7aba4720 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngineStreamTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchEngineStreamTest.java @@ -7,9 +7,9 @@ import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.search.SearchEngine; -import org.schabi.newpipe.extractor.search.SearchResult; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; /** @@ -20,7 +20,7 @@ public class SoundcloudSearchEngineStreamTest extends BaseSoundcloudSearchTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - SearchEngine engine = SoundCloud.getService().getSearchEngine(); + SearchEngine engine = SoundCloud.getSearchEngine(); // SoundCloud will suggest "lil uzi vert" instead of "lill uzi vert", // keep in mind that the suggestions can NOT change by country (the parameter "de") diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java index 7becab62..bd773fd7 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java @@ -9,7 +9,6 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; import org.schabi.newpipe.extractor.stream.StreamType; -import org.schabi.newpipe.extractor.stream.SubtitlesFormat; import java.io.IOException; @@ -26,7 +25,7 @@ public class SoundcloudStreamExtractorDefaultTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - extractor = (SoundcloudStreamExtractor) SoundCloud.getService().getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon"); + extractor = (SoundcloudStreamExtractor) SoundCloud.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon"); extractor.fetchPage(); } @@ -38,7 +37,7 @@ public class SoundcloudStreamExtractorDefaultTest { @Test public void testGetValidTimeStamp() throws IOException, ExtractionException { - StreamExtractor extractor = SoundCloud.getService().getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon#t=69"); + StreamExtractor extractor = SoundCloud.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon#t=69"); assertEquals(extractor.getTimeStamp() + "", "69"); } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSuggestionExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSuggestionExtractorTest.java index c9dff3ae..b4ab8dbc 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSuggestionExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSuggestionExtractorTest.java @@ -21,7 +21,7 @@ public class SoundcloudSuggestionExtractorTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - suggestionExtractor = SoundCloud.getService().getSuggestionExtractor(); + suggestionExtractor = SoundCloud.getSuggestionExtractor(); } @Test diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java index 1b15c1db..96d29c24 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java @@ -7,7 +7,6 @@ import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.channel.ChannelExtractor; - import static org.junit.Assert.*; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors; import static org.schabi.newpipe.extractor.ServiceList.YouTube; @@ -42,7 +41,7 @@ public class YoutubeChannelExtractorTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - extractor = (YoutubeChannelExtractor) YouTube.getService() + extractor = (YoutubeChannelExtractor) YouTube .getChannelExtractor("https://www.youtube.com/user/Gronkh"); extractor.fetchPage(); } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java index a6b1b3f2..dd4e58c7 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java @@ -28,7 +28,7 @@ public class YoutubePlaylistExtractorTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - extractor = (YoutubePlaylistExtractor) YouTube.getService() + extractor = (YoutubePlaylistExtractor) YouTube .getPlaylistExtractor("https://www.youtube.com/watch?v=lp-EO5I60KA&list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj"); extractor.fetchPage(); } @@ -85,7 +85,7 @@ public class YoutubePlaylistExtractorTest { assertTrue(streams.size() > 60); assertFalse(streams.contains(null)); for(StreamInfoItem item: streams) { - assertEquals("Service id doesn't match", YouTube.getId(), item.getServiceId()); + assertEquals("Service id doesn't match", YouTube.getServiceId(), item.getServiceId()); assertNotNull("Stream type not set: " + item, item.getStreamType()); //assertNotEmpty("Upload date not set: " + item, item.getUploadDate()); assertNotEmpty("Uploader name not set: " + item, item.getUploaderName()); diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineAllTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineAllTest.java index b24956b1..cefb5665 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineAllTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineAllTest.java @@ -8,14 +8,9 @@ import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.search.SearchEngine; -import org.schabi.newpipe.extractor.search.SearchResult; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.List; - -import static org.junit.Assert.*; -import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /* * Created by Christian Schabesberger on 29.12.15. diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineChannelTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineChannelTest.java index 79f1b20a..a31a8c93 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineChannelTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineChannelTest.java @@ -7,10 +7,9 @@ import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.search.SearchEngine; -import org.schabi.newpipe.extractor.search.SearchResult; -import static org.junit.Assert.*; -import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.schabi.newpipe.extractor.ServiceList.YouTube; @@ -42,7 +41,7 @@ public class YoutubeSearchEngineChannelTest extends BaseYoutubeSearchTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - SearchEngine engine = YouTube.getService().getSearchEngine(); + SearchEngine engine = YouTube.getSearchEngine(); // Youtube will suggest "gronkh" instead of "grrunkh" // keep in mind that the suggestions can change by country (the parameter "de") diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEnginePlaylistTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEnginePlaylistTest.java index 82882954..a4bd8c5a 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEnginePlaylistTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEnginePlaylistTest.java @@ -8,10 +8,9 @@ import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem; import org.schabi.newpipe.extractor.search.SearchEngine; -import org.schabi.newpipe.extractor.search.SearchResult; -import static org.junit.Assert.*; -import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.schabi.newpipe.extractor.ServiceList.YouTube; @@ -43,7 +42,7 @@ public class YoutubeSearchEnginePlaylistTest extends BaseYoutubeSearchTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - SearchEngine engine = YouTube.getService().getSearchEngine(); + SearchEngine engine = YouTube.getSearchEngine(); // Youtube will suggest "gronkh" instead of "grrunkh" // keep in mind that the suggestions can change by country (the parameter "de") diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineStreamTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineStreamTest.java index 170419c5..619e290d 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineStreamTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngineStreamTest.java @@ -7,10 +7,9 @@ import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.search.SearchEngine; -import org.schabi.newpipe.extractor.search.SearchResult; -import static org.junit.Assert.*; -import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.schabi.newpipe.extractor.ServiceList.YouTube; @@ -42,7 +41,7 @@ public class YoutubeSearchEngineStreamTest extends BaseYoutubeSearchTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - SearchEngine engine = YouTube.getService().getSearchEngine(); + SearchEngine engine = YouTube.getSearchEngine(); // Youtube will suggest "results" instead of "rsults", // keep in mind that the suggestions can change by country (the parameter "de") diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeServiceTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeServiceTest.java index 8b362ace..8d572c32 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeServiceTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeServiceTest.java @@ -41,7 +41,7 @@ public class YoutubeServiceTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - service = YouTube.getService(); + service = YouTube; kioskList = service.getKioskList(); } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java index 2b44eb83..790ea4ac 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java @@ -44,7 +44,7 @@ public class YoutubeStreamExtractorDefaultTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - extractor = (YoutubeStreamExtractor) YouTube.getService() + extractor = (YoutubeStreamExtractor) YouTube .getStreamExtractor("https://www.youtube.com/watch?v=rYEDA3JcQqw"); extractor.fetchPage(); } @@ -57,7 +57,7 @@ public class YoutubeStreamExtractorDefaultTest { @Test public void testGetValidTimeStamp() throws IOException, ExtractionException { - StreamExtractor extractor = YouTube.getService().getStreamExtractor("https://youtu.be/FmG385_uUys?t=174"); + StreamExtractor extractor = YouTube.getStreamExtractor("https://youtu.be/FmG385_uUys?t=174"); assertEquals(extractor.getTimeStamp() + "", "174"); } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorGemaTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorGemaTest.java index 1c64c818..9813dc46 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorGemaTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorGemaTest.java @@ -43,7 +43,7 @@ public class YoutubeStreamExtractorGemaTest { public void testGemaError() throws IOException, ExtractionException { try { NewPipe.init(Downloader.getInstance()); - YouTube.getService().getStreamExtractor("https://www.youtube.com/watch?v=3O1_3zBUKM8"); + YouTube.getStreamExtractor("https://www.youtube.com/watch?v=3O1_3zBUKM8"); fail("GemaException should be thrown"); } catch (YoutubeStreamExtractor.GemaException ignored) { diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorRestrictedTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorRestrictedTest.java index 77fff6a6..93b0677b 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorRestrictedTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorRestrictedTest.java @@ -29,7 +29,7 @@ public class YoutubeStreamExtractorRestrictedTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - extractor = (YoutubeStreamExtractor) YouTube.getService() + extractor = (YoutubeStreamExtractor) YouTube .getStreamExtractor("https://www.youtube.com/watch?v=i6JTvzrpBy0"); extractor.fetchPage(); } @@ -41,7 +41,7 @@ public class YoutubeStreamExtractorRestrictedTest { @Test public void testGetValidTimeStamp() throws IOException, ExtractionException { - StreamExtractor extractor = YouTube.getService().getStreamExtractor("https://youtu.be/FmG385_uUys?t=174"); + StreamExtractor extractor = YouTube.getStreamExtractor("https://youtu.be/FmG385_uUys?t=174"); assertEquals(extractor.getTimeStamp() + "", "174"); } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSuggestionExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSuggestionExtractorTest.java index 1868a561..3e72ec34 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSuggestionExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSuggestionExtractorTest.java @@ -41,7 +41,7 @@ public class YoutubeSuggestionExtractorTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - suggestionExtractor = YouTube.getService().getSuggestionExtractor(); + suggestionExtractor = YouTube.getSuggestionExtractor(); } @Test diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java index 82e6c071..23b90bfe 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java @@ -28,9 +28,7 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; import org.schabi.newpipe.extractor.utils.Utils; import static junit.framework.TestCase.assertFalse; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors; import static org.schabi.newpipe.extractor.ServiceList.YouTube; @@ -45,7 +43,7 @@ public class YoutubeTrendingExtractorTest { @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - extractor = (YoutubeTrendingExtractor) YouTube.getService() + extractor = (YoutubeTrendingExtractor) YouTube .getKioskList() .getExtractorById("Trending", null); extractor.fetchPage(); diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTreindingKioskInfoTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java similarity index 86% rename from src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTreindingKioskInfoTest.java rename to src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java index 5e4cce93..2599df93 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTreindingKioskInfoTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java @@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor.services.youtube; * Created by Christian Schabesberger on 12.08.17. * * Copyright (C) Christian Schabesberger 2017 - * YoutubeTreindingKioskInfoTest.java is part of NewPipe. + * YoutubeTrendingKioskInfoTest.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 @@ -28,7 +28,6 @@ import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.UrlIdHandler; import org.schabi.newpipe.extractor.kiosk.KioskInfo; -import static junit.framework.TestCase.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.schabi.newpipe.extractor.ServiceList.YouTube; @@ -36,17 +35,17 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube; /** * Test for {@link KioskInfo} */ -public class YoutubeTreindingKioskInfoTest { +public class YoutubeTrendingKioskInfoTest { static KioskInfo kioskInfo; @BeforeClass public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); - StreamingService service = YouTube.getService(); + StreamingService service = YouTube; UrlIdHandler urlIdHandler = service.getKioskList().getUrlIdHandlerByType("Trending"); - kioskInfo = KioskInfo.getInfo(YouTube.getService(), urlIdHandler.getUrl("Trending"), null); + kioskInfo = KioskInfo.getInfo(YouTube, urlIdHandler.getUrl("Trending"), null); } @Test diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingUrlIdHandlerTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingUrlIdHandlerTest.java index 8c04a76d..7ee68a39 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingUrlIdHandlerTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingUrlIdHandlerTest.java @@ -26,11 +26,10 @@ import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.UrlIdHandler; -import static org.schabi.newpipe.extractor.ServiceList.YouTube; - import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.schabi.newpipe.extractor.ServiceList.YouTube; /** * Test for {@link YoutubeTrendingUrlIdHandler} @@ -40,7 +39,7 @@ public class YoutubeTrendingUrlIdHandlerTest { @BeforeClass public static void setUp() throws Exception { - urlIdHandler = YouTube.getService().getKioskList().getUrlIdHandlerByType("Trending"); + urlIdHandler = YouTube.getKioskList().getUrlIdHandlerByType("Trending"); NewPipe.init(Downloader.getInstance()); }