Improve ServiceList class
- [Minor] Fix wrong arguments order in KioskInfo
This commit is contained in:
parent
42411099db
commit
f3865445f5
|
@ -22,6 +22,8 @@ package org.schabi.newpipe.extractor;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to streaming services supported by NewPipe.
|
* Provides access to streaming services supported by NewPipe.
|
||||||
*/
|
*/
|
||||||
|
@ -44,37 +46,32 @@ public class NewPipe {
|
||||||
// Utils
|
// Utils
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
public static StreamingService[] getServices() {
|
public static List<StreamingService> getServices() {
|
||||||
final ServiceList[] values = ServiceList.values();
|
return ServiceList.all();
|
||||||
final StreamingService[] streamingServices = new StreamingService[values.length];
|
|
||||||
|
|
||||||
for (int i = 0; i < values.length; i++) streamingServices[i] = values[i].getService();
|
|
||||||
|
|
||||||
return streamingServices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StreamingService getService(int serviceId) throws ExtractionException {
|
public static StreamingService getService(int serviceId) throws ExtractionException {
|
||||||
for (ServiceList item : ServiceList.values()) {
|
for (StreamingService service : ServiceList.all()) {
|
||||||
if (item.getService().getServiceId() == serviceId) {
|
if (service.getServiceId() == serviceId) {
|
||||||
return item.getService();
|
return service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new ExtractionException("There's no service with the id = \"" + serviceId + "\"");
|
throw new ExtractionException("There's no service with the id = \"" + serviceId + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StreamingService getService(String serviceName) throws ExtractionException {
|
public static StreamingService getService(String serviceName) throws ExtractionException {
|
||||||
for (ServiceList item : ServiceList.values()) {
|
for (StreamingService service : ServiceList.all()) {
|
||||||
if (item.getService().getServiceInfo().name.equals(serviceName)) {
|
if (service.getServiceInfo().getName().equals(serviceName)) {
|
||||||
return item.getService();
|
return service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new ExtractionException("There's no service with the name = \"" + serviceName + "\"");
|
throw new ExtractionException("There's no service with the name = \"" + serviceName + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StreamingService getServiceByUrl(String url) throws ExtractionException {
|
public static StreamingService getServiceByUrl(String url) throws ExtractionException {
|
||||||
for (ServiceList item : ServiceList.values()) {
|
for (StreamingService service : ServiceList.all()) {
|
||||||
if (item.getService().getLinkTypeByUrl(url) != StreamingService.LinkType.NONE) {
|
if (service.getLinkTypeByUrl(url) != StreamingService.LinkType.NONE) {
|
||||||
return item.getService();
|
return service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new ExtractionException("No service can handle the url = \"" + url + "\"");
|
throw new ExtractionException("No service can handle the url = \"" + url + "\"");
|
||||||
|
@ -92,7 +89,7 @@ public class NewPipe {
|
||||||
public static String getNameOfService(int id) {
|
public static String getNameOfService(int id) {
|
||||||
try {
|
try {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
return getService(id).getServiceInfo().name;
|
return getService(id).getServiceInfo().getName();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Service id not known");
|
System.err.println("Service id not known");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -3,34 +3,34 @@ package org.schabi.newpipe.extractor;
|
||||||
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudService;
|
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudService;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.YoutubeService;
|
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.
|
* A list of supported services.
|
||||||
*/
|
*/
|
||||||
public enum ServiceList {
|
public final class ServiceList {
|
||||||
YouTube(new YoutubeService(0, "YouTube")),
|
private ServiceList() {
|
||||||
SoundCloud(new SoundcloudService(1, "SoundCloud"));
|
//no instance
|
||||||
// DailyMotion(new DailyMotionService(2, "DailyMotion"));
|
|
||||||
|
|
||||||
private final StreamingService service;
|
|
||||||
|
|
||||||
ServiceList(StreamingService service) {
|
|
||||||
this.service = service;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamingService getService() {
|
public static final YoutubeService YouTube;
|
||||||
return service;
|
public static final SoundcloudService SoundCloud;
|
||||||
}
|
|
||||||
|
|
||||||
public StreamingService.ServiceInfo getServiceInfo() {
|
private static final List<StreamingService> SERVICES = unmodifiableList(asList(
|
||||||
return service.getServiceInfo();
|
YouTube = new YoutubeService(0),
|
||||||
}
|
SoundCloud = new SoundcloudService(1)
|
||||||
|
// DailyMotion = new DailyMotionService(2);
|
||||||
|
));
|
||||||
|
|
||||||
public int getId() {
|
/**
|
||||||
return service.getServiceId();
|
* Get all the supported services.
|
||||||
}
|
*
|
||||||
|
* @return a unmodifiable list of all the supported services
|
||||||
@Override
|
*/
|
||||||
public String toString() {
|
public static List<StreamingService> all() {
|
||||||
return service.getServiceInfo().name;
|
return SERVICES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,29 @@ import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class StreamingService {
|
public abstract class StreamingService {
|
||||||
public class ServiceInfo {
|
public static class ServiceInfo {
|
||||||
public final String name;
|
private final String name;
|
||||||
|
private final List<MediaCapability> mediaCapabilities;
|
||||||
|
|
||||||
public ServiceInfo(String name) {
|
public ServiceInfo(String name, List<MediaCapability> mediaCapabilities) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.mediaCapabilities = Collections.unmodifiableList(mediaCapabilities);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MediaCapability> getMediaCapabilities() {
|
||||||
|
return mediaCapabilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum MediaCapability {
|
||||||
|
AUDIO, VIDEO, LIVE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,9 +44,9 @@ public abstract class StreamingService {
|
||||||
private final int serviceId;
|
private final int serviceId;
|
||||||
private final ServiceInfo serviceInfo;
|
private final ServiceInfo serviceInfo;
|
||||||
|
|
||||||
public StreamingService(int id, String name) {
|
public StreamingService(int id, String name, List<ServiceInfo.MediaCapability> capabilities) {
|
||||||
this.serviceId = id;
|
this.serviceId = id;
|
||||||
this.serviceInfo = new ServiceInfo(name);
|
this.serviceInfo = new ServiceInfo(name, capabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getServiceId() {
|
public final int getServiceId() {
|
||||||
|
@ -41,6 +57,11 @@ public abstract class StreamingService {
|
||||||
return serviceInfo;
|
return serviceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return serviceId + ":" + serviceInfo.getName();
|
||||||
|
}
|
||||||
|
|
||||||
public abstract UrlIdHandler getStreamUrlIdHandler();
|
public abstract UrlIdHandler getStreamUrlIdHandler();
|
||||||
public abstract UrlIdHandler getChannelUrlIdHandler();
|
public abstract UrlIdHandler getChannelUrlIdHandler();
|
||||||
public abstract UrlIdHandler getPlaylistUrlIdHandler();
|
public abstract UrlIdHandler getPlaylistUrlIdHandler();
|
||||||
|
|
|
@ -3,7 +3,6 @@ package org.schabi.newpipe.extractor.channel;
|
||||||
import org.schabi.newpipe.extractor.ListExtractor.NextItemsResult;
|
import org.schabi.newpipe.extractor.ListExtractor.NextItemsResult;
|
||||||
import org.schabi.newpipe.extractor.ListInfo;
|
import org.schabi.newpipe.extractor.ListInfo;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
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 {
|
public static NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl, String contentLanguage) throws IOException, ExtractionException {
|
||||||
return getMoreItems(serviceItem.getService(), url, nextStreamsUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
|
||||||
return service.getChannelExtractor(url, nextStreamsUrl).getNextStreams();
|
return service.getChannelExtractor(url, nextStreamsUrl).getNextStreams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,10 +45,6 @@ public class ChannelInfo extends ListInfo {
|
||||||
return getInfo(NewPipe.getServiceByUrl(url), url);
|
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 {
|
public static ChannelInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
||||||
ChannelExtractor extractor = service.getChannelExtractor(url);
|
ChannelExtractor extractor = service.getChannelExtractor(url);
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
|
|
|
@ -20,7 +20,10 @@ package org.schabi.newpipe.extractor.kiosk;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
||||||
|
|
||||||
|
@ -32,13 +35,6 @@ public class KioskInfo extends ListInfo {
|
||||||
super(serviceId, id, url, name);
|
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,
|
public static ListExtractor.NextItemsResult getMoreItems(StreamingService service,
|
||||||
String url,
|
String url,
|
||||||
String nextStreamsUrl,
|
String nextStreamsUrl,
|
||||||
|
@ -54,12 +50,6 @@ public class KioskInfo extends ListInfo {
|
||||||
return getInfo(NewPipe.getServiceByUrl(url), url, contentCountry);
|
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,
|
public static KioskInfo getInfo(StreamingService service,
|
||||||
String url,
|
String url,
|
||||||
String contentCountry) throws IOException, ExtractionException {
|
String contentCountry) throws IOException, ExtractionException {
|
||||||
|
@ -82,7 +72,7 @@ public class KioskInfo extends ListInfo {
|
||||||
String id = extractor.getId();
|
String id = extractor.getId();
|
||||||
String url = extractor.getCleanUrl();
|
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);
|
info.related_streams = ExtractorHelper.getStreamsOrLogError(info, extractor);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package org.schabi.newpipe.extractor.playlist;
|
package org.schabi.newpipe.extractor.playlist;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.*;
|
|
||||||
import org.schabi.newpipe.extractor.ListExtractor.NextItemsResult;
|
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.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
|
||||||
|
@ -15,10 +17,6 @@ public class PlaylistInfo extends ListInfo {
|
||||||
super(serviceId, id, url, name);
|
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 {
|
public static NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||||
return service.getPlaylistExtractor(url, nextStreamsUrl).getNextStreams();
|
return service.getPlaylistExtractor(url, nextStreamsUrl).getNextStreams();
|
||||||
}
|
}
|
||||||
|
@ -27,10 +25,6 @@ public class PlaylistInfo extends ListInfo {
|
||||||
return getInfo(NewPipe.getServiceByUrl(url), url);
|
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 {
|
public static PlaylistInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
||||||
PlaylistExtractor extractor = service.getPlaylistExtractor(url);
|
PlaylistExtractor extractor = service.getPlaylistExtractor(url);
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||||
import org.schabi.newpipe.extractor.UrlIdHandler;
|
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.search.SearchEngine;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
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 class SoundcloudService extends StreamingService {
|
||||||
|
|
||||||
public SoundcloudService(int id, String name) {
|
public SoundcloudService(int id) {
|
||||||
super(id, name);
|
super(id, "SoundCloud", singletonList(AUDIO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,6 +13,9 @@ import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||||
|
|
||||||
import java.io.IOException;
|
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.
|
* Created by Christian Schabesberger on 23.08.15.
|
||||||
|
@ -36,8 +39,8 @@ import java.io.IOException;
|
||||||
|
|
||||||
public class YoutubeService extends StreamingService {
|
public class YoutubeService extends StreamingService {
|
||||||
|
|
||||||
public YoutubeService(int id, String name) {
|
public YoutubeService(int id) {
|
||||||
super(id, name);
|
super(id, "YouTube", asList(AUDIO, VIDEO, LIVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,7 +63,6 @@ public class YoutubeService extends StreamingService {
|
||||||
return YoutubePlaylistUrlIdHandler.getInstance();
|
return YoutubePlaylistUrlIdHandler.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StreamExtractor getStreamExtractor(String url) throws IOException, ExtractionException {
|
public StreamExtractor getStreamExtractor(String url) throws IOException, ExtractionException {
|
||||||
return new YoutubeStreamExtractor(this, url);
|
return new YoutubeStreamExtractor(this, url);
|
||||||
|
|
|
@ -232,10 +232,6 @@ public class StreamInfo extends Info {
|
||||||
return getInfo(NewPipe.getServiceByUrl(url), url);
|
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 {
|
public static StreamInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
||||||
return getInfo(service.getStreamExtractor(url));
|
return getInfo(service.getStreamExtractor(url));
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,14 +12,14 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
public class NewPipeTest {
|
public class NewPipeTest {
|
||||||
@Test
|
@Test
|
||||||
public void getAllServicesTest() throws Exception {
|
public void getAllServicesTest() throws Exception {
|
||||||
assertEquals(NewPipe.getServices().length, ServiceList.values().length);
|
assertEquals(NewPipe.getServices().size(), ServiceList.all().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllServicesHaveDifferentId() throws Exception {
|
public void testAllServicesHaveDifferentId() throws Exception {
|
||||||
HashSet<Integer> servicesId = new HashSet<>();
|
HashSet<Integer> servicesId = new HashSet<>();
|
||||||
for (StreamingService streamingService : NewPipe.getServices()) {
|
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()));
|
assertTrue(errorMsg, servicesId.add(streamingService.getServiceId()));
|
||||||
}
|
}
|
||||||
|
@ -27,46 +27,46 @@ public class NewPipeTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getServiceWithId() throws Exception {
|
public void getServiceWithId() throws Exception {
|
||||||
assertEquals(NewPipe.getService(YouTube.getId()), YouTube.getService());
|
assertEquals(NewPipe.getService(YouTube.getServiceId()), YouTube);
|
||||||
assertEquals(NewPipe.getService(SoundCloud.getId()), SoundCloud.getService());
|
assertEquals(NewPipe.getService(SoundCloud.getServiceId()), SoundCloud);
|
||||||
|
|
||||||
assertNotEquals(NewPipe.getService(SoundCloud.getId()), YouTube.getService());
|
assertNotEquals(NewPipe.getService(SoundCloud.getServiceId()), YouTube);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getServiceWithName() throws Exception {
|
public void getServiceWithName() throws Exception {
|
||||||
assertEquals(NewPipe.getService(YouTube.getServiceInfo().name), YouTube.getService());
|
assertEquals(NewPipe.getService(YouTube.getServiceInfo().getName()), YouTube);
|
||||||
assertEquals(NewPipe.getService(SoundCloud.getServiceInfo().name), SoundCloud.getService());
|
assertEquals(NewPipe.getService(SoundCloud.getServiceInfo().getName()), SoundCloud);
|
||||||
|
|
||||||
assertNotEquals(NewPipe.getService(YouTube.getServiceInfo().name), SoundCloud.getService());
|
assertNotEquals(NewPipe.getService(YouTube.getServiceInfo().getName()), SoundCloud);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getServiceWithUrl() throws Exception {
|
public void getServiceWithUrl() throws Exception {
|
||||||
assertEquals(getServiceByUrl("https://www.youtube.com/watch?v=_r6CgaFNAGg"), YouTube.getService());
|
assertEquals(getServiceByUrl("https://www.youtube.com/watch?v=_r6CgaFNAGg"), YouTube);
|
||||||
assertEquals(getServiceByUrl("https://www.youtube.com/channel/UCi2bIyFtz-JdI-ou8kaqsqg"), YouTube.getService());
|
assertEquals(getServiceByUrl("https://www.youtube.com/channel/UCi2bIyFtz-JdI-ou8kaqsqg"), YouTube);
|
||||||
assertEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), YouTube.getService());
|
assertEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), YouTube);
|
||||||
assertEquals(getServiceByUrl("https://soundcloud.com/shupemoosic/pegboard-nerds-try-this"), SoundCloud.getService());
|
assertEquals(getServiceByUrl("https://soundcloud.com/shupemoosic/pegboard-nerds-try-this"), SoundCloud);
|
||||||
assertEquals(getServiceByUrl("https://soundcloud.com/deluxe314/sets/pegboard-nerds"), SoundCloud.getService());
|
assertEquals(getServiceByUrl("https://soundcloud.com/deluxe314/sets/pegboard-nerds"), SoundCloud);
|
||||||
assertEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), SoundCloud.getService());
|
assertEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), SoundCloud);
|
||||||
|
|
||||||
assertNotEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), YouTube.getService());
|
assertNotEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), YouTube);
|
||||||
assertNotEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), SoundCloud.getService());
|
assertNotEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), SoundCloud);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getIdWithServiceName() throws Exception {
|
public void getIdWithServiceName() throws Exception {
|
||||||
assertEquals(NewPipe.getIdOfService(YouTube.getServiceInfo().name), YouTube.getId());
|
assertEquals(NewPipe.getIdOfService(YouTube.getServiceInfo().getName()), YouTube.getServiceId());
|
||||||
assertEquals(NewPipe.getIdOfService(SoundCloud.getServiceInfo().name), SoundCloud.getId());
|
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
|
@Test
|
||||||
public void getServiceNameWithId() throws Exception {
|
public void getServiceNameWithId() throws Exception {
|
||||||
assertEquals(NewPipe.getNameOfService(YouTube.getId()), YouTube.getServiceInfo().name);
|
assertEquals(NewPipe.getNameOfService(YouTube.getServiceId()), YouTube.getServiceInfo().getName());
|
||||||
assertEquals(NewPipe.getNameOfService(SoundCloud.getId()), SoundCloud.getServiceInfo().name);
|
assertEquals(NewPipe.getNameOfService(SoundCloud.getServiceId()), SoundCloud.getServiceInfo().getName());
|
||||||
|
|
||||||
assertNotEquals(NewPipe.getNameOfService(YouTube.getId()), SoundCloud.getServiceInfo().name);
|
assertNotEquals(NewPipe.getNameOfService(YouTube.getServiceId()), SoundCloud.getServiceInfo().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class SoundcloudChannelExtractorTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = SoundCloud.getService()
|
extractor = SoundCloud
|
||||||
.getChannelExtractor("https://soundcloud.com/liluzivert");
|
.getChannelExtractor("https://soundcloud.com/liluzivert");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
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.BeforeClass;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
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.kiosk.KioskExtractor;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link SoundcloudChartsUrlIdHandler}
|
* Test for {@link SoundcloudChartsUrlIdHandler}
|
||||||
*/
|
*/
|
||||||
|
@ -24,7 +21,7 @@ public class SoundcloudChartsExtractorTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = SoundCloud.getService()
|
extractor = SoundCloud
|
||||||
.getKioskList()
|
.getKioskList()
|
||||||
.getExtractorById("Top 50", null);
|
.getExtractorById("Top 50", null);
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class SoundcloudPlaylistExtractorTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = SoundCloud.getService()
|
extractor = SoundCloud
|
||||||
.getPlaylistExtractor("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r");
|
.getPlaylistExtractor("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||||
|
|
||||||
|
@ -19,7 +18,7 @@ public class SoundcloudSearchEngineAllTest extends BaseSoundcloudSearchTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
SearchEngine engine = SoundCloud.getService().getSearchEngine();
|
SearchEngine engine = SoundCloud.getSearchEngine();
|
||||||
|
|
||||||
// SoundCloud will suggest "lil uzi vert" instead of "lill uzi vert"
|
// 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")
|
// keep in mind that the suggestions can NOT change by country (the parameter "de")
|
||||||
|
|
|
@ -7,9 +7,9 @@ import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
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;
|
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +20,7 @@ public class SoundcloudSearchEngineChannelTest extends BaseSoundcloudSearchTest
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
SearchEngine engine = SoundCloud.getService().getSearchEngine();
|
SearchEngine engine = SoundCloud.getSearchEngine();
|
||||||
|
|
||||||
// SoundCloud will suggest "lil uzi vert" instead of "lill uzi vert"
|
// 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")
|
// keep in mind that the suggestions can NOT change by country (the parameter "de")
|
||||||
|
|
|
@ -7,9 +7,9 @@ import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
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;
|
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class SoundcloudSearchEnginePlaylistTest extends BaseSoundcloudSearchTest
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
SearchEngine engine = SoundCloud.getService().getSearchEngine();
|
SearchEngine engine = SoundCloud.getSearchEngine();
|
||||||
|
|
||||||
// Search by country not yet implemented
|
// Search by country not yet implemented
|
||||||
result = engine.search("parkmemme", 0, "", SearchEngine.Filter.PLAYLIST)
|
result = engine.search("parkmemme", 0, "", SearchEngine.Filter.PLAYLIST)
|
||||||
|
|
|
@ -7,9 +7,9 @@ import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
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;
|
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +20,7 @@ public class SoundcloudSearchEngineStreamTest extends BaseSoundcloudSearchTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
SearchEngine engine = SoundCloud.getService().getSearchEngine();
|
SearchEngine engine = SoundCloud.getSearchEngine();
|
||||||
|
|
||||||
// SoundCloud will suggest "lil uzi vert" instead of "lill uzi vert",
|
// 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")
|
// keep in mind that the suggestions can NOT change by country (the parameter "de")
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||||
import org.schabi.newpipe.extractor.stream.SubtitlesFormat;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -26,7 +25,7 @@ public class SoundcloudStreamExtractorDefaultTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
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();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ public class SoundcloudStreamExtractorDefaultTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
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");
|
assertEquals(extractor.getTimeStamp() + "", "69");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class SoundcloudSuggestionExtractorTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
suggestionExtractor = SoundCloud.getService().getSuggestionExtractor();
|
suggestionExtractor = SoundCloud.getSuggestionExtractor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.schabi.newpipe.extractor.ListExtractor;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors;
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
@ -42,7 +41,7 @@ public class YoutubeChannelExtractorTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = (YoutubeChannelExtractor) YouTube.getService()
|
extractor = (YoutubeChannelExtractor) YouTube
|
||||||
.getChannelExtractor("https://www.youtube.com/user/Gronkh");
|
.getChannelExtractor("https://www.youtube.com/user/Gronkh");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class YoutubePlaylistExtractorTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = (YoutubePlaylistExtractor) YouTube.getService()
|
extractor = (YoutubePlaylistExtractor) YouTube
|
||||||
.getPlaylistExtractor("https://www.youtube.com/watch?v=lp-EO5I60KA&list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj");
|
.getPlaylistExtractor("https://www.youtube.com/watch?v=lp-EO5I60KA&list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public class YoutubePlaylistExtractorTest {
|
||||||
assertTrue(streams.size() > 60);
|
assertTrue(streams.size() > 60);
|
||||||
assertFalse(streams.contains(null));
|
assertFalse(streams.contains(null));
|
||||||
for(StreamInfoItem item: streams) {
|
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());
|
assertNotNull("Stream type not set: " + item, item.getStreamType());
|
||||||
//assertNotEmpty("Upload date not set: " + item, item.getUploadDate());
|
//assertNotEmpty("Upload date not set: " + item, item.getUploadDate());
|
||||||
assertNotEmpty("Uploader name not set: " + item, item.getUploaderName());
|
assertNotEmpty("Uploader name not set: " + item, item.getUploaderName());
|
||||||
|
|
|
@ -8,14 +8,9 @@ import org.schabi.newpipe.extractor.InfoItem;
|
||||||
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.search.SearchEngine;
|
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||||
import org.schabi.newpipe.extractor.search.SearchResult;
|
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import static org.junit.Assert.assertEquals;
|
||||||
import java.net.URL;
|
import static org.junit.Assert.assertTrue;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Created by Christian Schabesberger on 29.12.15.
|
* Created by Christian Schabesberger on 29.12.15.
|
||||||
|
|
|
@ -7,10 +7,9 @@ import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
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.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +41,7 @@ public class YoutubeSearchEngineChannelTest extends BaseYoutubeSearchTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
SearchEngine engine = YouTube.getService().getSearchEngine();
|
SearchEngine engine = YouTube.getSearchEngine();
|
||||||
|
|
||||||
// Youtube will suggest "gronkh" instead of "grrunkh"
|
// Youtube will suggest "gronkh" instead of "grrunkh"
|
||||||
// keep in mind that the suggestions can change by country (the parameter "de")
|
// keep in mind that the suggestions can change by country (the parameter "de")
|
||||||
|
|
|
@ -8,10 +8,9 @@ import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
||||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
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.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@ public class YoutubeSearchEnginePlaylistTest extends BaseYoutubeSearchTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
SearchEngine engine = YouTube.getService().getSearchEngine();
|
SearchEngine engine = YouTube.getSearchEngine();
|
||||||
|
|
||||||
// Youtube will suggest "gronkh" instead of "grrunkh"
|
// Youtube will suggest "gronkh" instead of "grrunkh"
|
||||||
// keep in mind that the suggestions can change by country (the parameter "de")
|
// keep in mind that the suggestions can change by country (the parameter "de")
|
||||||
|
|
|
@ -7,10 +7,9 @@ import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
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.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +41,7 @@ public class YoutubeSearchEngineStreamTest extends BaseYoutubeSearchTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
SearchEngine engine = YouTube.getService().getSearchEngine();
|
SearchEngine engine = YouTube.getSearchEngine();
|
||||||
|
|
||||||
// Youtube will suggest "results" instead of "rsults",
|
// Youtube will suggest "results" instead of "rsults",
|
||||||
// keep in mind that the suggestions can change by country (the parameter "de")
|
// keep in mind that the suggestions can change by country (the parameter "de")
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class YoutubeServiceTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
service = YouTube.getService();
|
service = YouTube;
|
||||||
kioskList = service.getKioskList();
|
kioskList = service.getKioskList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = (YoutubeStreamExtractor) YouTube.getService()
|
extractor = (YoutubeStreamExtractor) YouTube
|
||||||
.getStreamExtractor("https://www.youtube.com/watch?v=rYEDA3JcQqw");
|
.getStreamExtractor("https://www.youtube.com/watch?v=rYEDA3JcQqw");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
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");
|
assertEquals(extractor.getTimeStamp() + "", "174");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class YoutubeStreamExtractorGemaTest {
|
||||||
public void testGemaError() throws IOException, ExtractionException {
|
public void testGemaError() throws IOException, ExtractionException {
|
||||||
try {
|
try {
|
||||||
NewPipe.init(Downloader.getInstance());
|
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");
|
fail("GemaException should be thrown");
|
||||||
} catch (YoutubeStreamExtractor.GemaException ignored) {
|
} catch (YoutubeStreamExtractor.GemaException ignored) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class YoutubeStreamExtractorRestrictedTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = (YoutubeStreamExtractor) YouTube.getService()
|
extractor = (YoutubeStreamExtractor) YouTube
|
||||||
.getStreamExtractor("https://www.youtube.com/watch?v=i6JTvzrpBy0");
|
.getStreamExtractor("https://www.youtube.com/watch?v=i6JTvzrpBy0");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class YoutubeStreamExtractorRestrictedTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
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");
|
assertEquals(extractor.getTimeStamp() + "", "174");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class YoutubeSuggestionExtractorTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
suggestionExtractor = YouTube.getService().getSuggestionExtractor();
|
suggestionExtractor = YouTube.getSuggestionExtractor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -28,9 +28,7 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
||||||
import org.schabi.newpipe.extractor.utils.Utils;
|
import org.schabi.newpipe.extractor.utils.Utils;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertFalse;
|
import static junit.framework.TestCase.assertFalse;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors;
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
|
@ -45,7 +43,7 @@ public class YoutubeTrendingExtractorTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = (YoutubeTrendingExtractor) YouTube.getService()
|
extractor = (YoutubeTrendingExtractor) YouTube
|
||||||
.getKioskList()
|
.getKioskList()
|
||||||
.getExtractorById("Trending", null);
|
.getExtractorById("Trending", null);
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
|
|
|
@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||||
* Created by Christian Schabesberger on 12.08.17.
|
* Created by Christian Schabesberger on 12.08.17.
|
||||||
*
|
*
|
||||||
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
||||||
* YoutubeTreindingKioskInfoTest.java is part of NewPipe.
|
* YoutubeTrendingKioskInfoTest.java is part of NewPipe.
|
||||||
*
|
*
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
* NewPipe is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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.UrlIdHandler;
|
||||||
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
|
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
@ -36,17 +35,17 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
/**
|
/**
|
||||||
* Test for {@link KioskInfo}
|
* Test for {@link KioskInfo}
|
||||||
*/
|
*/
|
||||||
public class YoutubeTreindingKioskInfoTest {
|
public class YoutubeTrendingKioskInfoTest {
|
||||||
static KioskInfo kioskInfo;
|
static KioskInfo kioskInfo;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp()
|
public static void setUp()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
StreamingService service = YouTube.getService();
|
StreamingService service = YouTube;
|
||||||
UrlIdHandler urlIdHandler = service.getKioskList().getUrlIdHandlerByType("Trending");
|
UrlIdHandler urlIdHandler = service.getKioskList().getUrlIdHandlerByType("Trending");
|
||||||
|
|
||||||
kioskInfo = KioskInfo.getInfo(YouTube.getService(), urlIdHandler.getUrl("Trending"), null);
|
kioskInfo = KioskInfo.getInfo(YouTube, urlIdHandler.getUrl("Trending"), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
|
@ -26,11 +26,10 @@ import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.UrlIdHandler;
|
import org.schabi.newpipe.extractor.UrlIdHandler;
|
||||||
|
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertFalse;
|
import static junit.framework.TestCase.assertFalse;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link YoutubeTrendingUrlIdHandler}
|
* Test for {@link YoutubeTrendingUrlIdHandler}
|
||||||
|
@ -40,7 +39,7 @@ public class YoutubeTrendingUrlIdHandlerTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
urlIdHandler = YouTube.getService().getKioskList().getUrlIdHandlerByType("Trending");
|
urlIdHandler = YouTube.getKioskList().getUrlIdHandlerByType("Trending");
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue