merged upstream/dev
This commit is contained in:
@@ -1,256 +0,0 @@
|
||||
package org.schabi.newpipe;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import org.schabi.newpipe.extractor.DownloadRequest;
|
||||
import org.schabi.newpipe.extractor.DownloadResponse;
|
||||
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 28.01.16.
|
||||
*
|
||||
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
||||
* Downloader.java is part of NewPipe.
|
||||
*
|
||||
* NewPipe is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* NewPipe is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
||||
|
||||
private static final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0";
|
||||
private static String mCookies = "";
|
||||
|
||||
private static Downloader instance = null;
|
||||
|
||||
private Downloader() {
|
||||
}
|
||||
|
||||
public static Downloader getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (Downloader.class) {
|
||||
if (instance == null) {
|
||||
instance = new Downloader();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static synchronized void setCookies(String cookies) {
|
||||
Downloader.mCookies = cookies;
|
||||
}
|
||||
|
||||
public static synchronized String getCookies() {
|
||||
return Downloader.mCookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the text file at the supplied URL as in download(String), but set
|
||||
* the HTTP header field "Accept-Language" to the supplied string.
|
||||
*
|
||||
* @param siteUrl the URL of the text file to return the contents of
|
||||
|
||||
* @param localization the language and country (usually a 2-character code for both values)
|
||||
* @return the contents of the specified text file
|
||||
*/
|
||||
public String download(String siteUrl, Localization localization) throws IOException, ReCaptchaException {
|
||||
Map<String, String> requestProperties = new HashMap<>();
|
||||
requestProperties.put("Accept-Language", localization.getLanguage());
|
||||
return download(siteUrl, requestProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the text file at the supplied URL as in download(String), but set
|
||||
* the HTTP header field "Accept-Language" to the supplied string.
|
||||
*
|
||||
* @param siteUrl the URL of the text file to return the contents of
|
||||
* @param customProperties set request header properties
|
||||
* @return the contents of the specified text file
|
||||
* @throws IOException
|
||||
*/
|
||||
public String download(String siteUrl, Map<String, String> customProperties)
|
||||
throws IOException, ReCaptchaException {
|
||||
URL url = new URL(siteUrl);
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
for (Map.Entry<String, String> pair : customProperties.entrySet()) {
|
||||
con.setRequestProperty(pair.getKey(), pair.getValue());
|
||||
}
|
||||
return dl(con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common functionality between download(String url) and download(String url,
|
||||
* String language)
|
||||
*/
|
||||
private static String dl(HttpsURLConnection con) throws IOException, ReCaptchaException {
|
||||
StringBuilder response = new StringBuilder();
|
||||
BufferedReader in = null;
|
||||
|
||||
try {
|
||||
|
||||
con.setRequestMethod("GET");
|
||||
setDefaults(con);
|
||||
|
||||
in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
} catch (UnknownHostException uhe) {// thrown when there's no internet
|
||||
// connection
|
||||
throw new IOException("unknown host or no network", uhe);
|
||||
// Toast.makeText(getActivity(), uhe.getMessage(),
|
||||
// Toast.LENGTH_LONG).show();
|
||||
} catch (Exception e) {
|
||||
/*
|
||||
* HTTP 429 == Too Many Request Receive from Youtube.com = ReCaptcha challenge
|
||||
* request See : https://github.com/rg3/youtube-dl/issues/5138
|
||||
*/
|
||||
if (con.getResponseCode() == 429) {
|
||||
throw new ReCaptchaException("reCaptcha Challenge requested", con.getURL().toString());
|
||||
}
|
||||
|
||||
throw new IOException(con.getResponseCode() + " " + con.getResponseMessage(), e);
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
return response.toString();
|
||||
}
|
||||
|
||||
private static void setDefaults(HttpsURLConnection con) {
|
||||
|
||||
con.setConnectTimeout(30 * 1000);// 30s
|
||||
con.setReadTimeout(30 * 1000);// 30s
|
||||
|
||||
// set default user agent
|
||||
if (null == con.getRequestProperty("User-Agent")) {
|
||||
con.setRequestProperty("User-Agent", USER_AGENT);
|
||||
}
|
||||
|
||||
// add default cookies
|
||||
if (getCookies().length() > 0) {
|
||||
con.addRequestProperty("Cookie", getCookies());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download (via HTTP) the text file located at the supplied URL, and return its
|
||||
* contents. Primarily intended for downloading web pages.
|
||||
*
|
||||
* @param siteUrl the URL of the text file to download
|
||||
* @return the contents of the specified text file
|
||||
*/
|
||||
public String download(String siteUrl) throws IOException, ReCaptchaException {
|
||||
URL url = new URL(siteUrl);
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
// HttpsURLConnection con = NetCipher.getHttpsURLConnection(url);
|
||||
return dl(con);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadResponse head(String siteUrl) throws IOException, ReCaptchaException {
|
||||
final HttpsURLConnection con = (HttpsURLConnection) new URL(siteUrl).openConnection();
|
||||
|
||||
try {
|
||||
con.setRequestMethod("HEAD");
|
||||
setDefaults(con);
|
||||
} catch (Exception e) {
|
||||
/*
|
||||
* HTTP 429 == Too Many Request Receive from Youtube.com = ReCaptcha challenge
|
||||
* request See : https://github.com/rg3/youtube-dl/issues/5138
|
||||
*/
|
||||
if (con.getResponseCode() == 429) {
|
||||
throw new ReCaptchaException("reCaptcha Challenge requested", con.getURL().toString());
|
||||
}
|
||||
|
||||
throw new IOException(con.getResponseCode() + " " + con.getResponseMessage(), e);
|
||||
}
|
||||
|
||||
return new DownloadResponse(con.getResponseCode(), null, con.getHeaderFields());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadResponse get(String siteUrl, Localization localization) throws IOException, ReCaptchaException {
|
||||
final Map<String, List<String>> requestHeaders = new HashMap<>();
|
||||
requestHeaders.put("Accept-Language", singletonList(localization.getLanguage()));
|
||||
|
||||
return get(siteUrl, new DownloadRequest(null, requestHeaders));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadResponse get(String siteUrl, DownloadRequest request)
|
||||
throws IOException, ReCaptchaException {
|
||||
URL url = new URL(siteUrl);
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
for (Map.Entry<String, List<String>> pair : request.getRequestHeaders().entrySet()) {
|
||||
for(String value: pair.getValue()) {
|
||||
con.addRequestProperty(pair.getKey(), value);
|
||||
}
|
||||
}
|
||||
String responseBody = dl(con);
|
||||
return new DownloadResponse(con.getResponseCode(), responseBody, con.getHeaderFields());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadResponse get(String siteUrl) throws IOException, ReCaptchaException {
|
||||
return get(siteUrl, DownloadRequest.emptyRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadResponse post(String siteUrl, DownloadRequest request)
|
||||
throws IOException, ReCaptchaException {
|
||||
URL url = new URL(siteUrl);
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
for (Map.Entry<String, List<String>> pair : request.getRequestHeaders().entrySet()) {
|
||||
for(String value: pair.getValue()) {
|
||||
con.addRequestProperty(pair.getKey(), value);
|
||||
}
|
||||
}
|
||||
// set fields to default if not set already
|
||||
setDefaults(con);
|
||||
|
||||
if(null != request.getRequestBody()) {
|
||||
byte[] postDataBytes = request.getRequestBody().getBytes("UTF-8");
|
||||
con.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
|
||||
con.setDoOutput(true);
|
||||
con.getOutputStream().write(postDataBytes);
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
|
||||
String inputLine;
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
sb.append(inputLine);
|
||||
}
|
||||
}
|
||||
return new DownloadResponse(con.getResponseCode(), sb.toString(), con.getHeaderFields());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package org.schabi.newpipe;
|
||||
|
||||
import org.schabi.newpipe.extractor.downloader.Downloader;
|
||||
import org.schabi.newpipe.extractor.downloader.Request;
|
||||
import org.schabi.newpipe.extractor.downloader.Response;
|
||||
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
||||
import org.schabi.newpipe.extractor.localization.Localization;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DownloaderTestImpl extends Downloader {
|
||||
|
||||
private static final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0";
|
||||
private static final String DEFAULT_HTTP_ACCEPT_LANGUAGE = "en";
|
||||
|
||||
private static DownloaderTestImpl instance = null;
|
||||
|
||||
private DownloaderTestImpl() {
|
||||
}
|
||||
|
||||
public static DownloaderTestImpl getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (DownloaderTestImpl.class) {
|
||||
if (instance == null) {
|
||||
instance = new DownloaderTestImpl();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private void setDefaultHeaders(URLConnection connection) {
|
||||
connection.setRequestProperty("User-Agent", USER_AGENT);
|
||||
connection.setRequestProperty("Accept-Language", DEFAULT_HTTP_ACCEPT_LANGUAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response execute(@Nonnull Request request) throws IOException, ReCaptchaException {
|
||||
final String httpMethod = request.httpMethod();
|
||||
final String url = request.url();
|
||||
final Map<String, List<String>> headers = request.headers();
|
||||
@Nullable final byte[] dataToSend = request.dataToSend();
|
||||
@Nullable final Localization localization = request.localization();
|
||||
|
||||
final HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection();
|
||||
|
||||
connection.setConnectTimeout(30 * 1000); // 30s
|
||||
connection.setReadTimeout(30 * 1000); // 30s
|
||||
connection.setRequestMethod(httpMethod);
|
||||
|
||||
setDefaultHeaders(connection);
|
||||
|
||||
for (Map.Entry<String, List<String>> pair : headers.entrySet()) {
|
||||
final String headerName = pair.getKey();
|
||||
final List<String> headerValueList = pair.getValue();
|
||||
|
||||
if (headerValueList.size() > 1) {
|
||||
connection.setRequestProperty(headerName, null);
|
||||
for (String headerValue : headerValueList) {
|
||||
connection.addRequestProperty(headerName, headerValue);
|
||||
}
|
||||
} else if (headerValueList.size() == 1) {
|
||||
connection.setRequestProperty(headerName, headerValueList.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable OutputStream outputStream = null;
|
||||
@Nullable InputStreamReader input = null;
|
||||
try {
|
||||
if (dataToSend != null && dataToSend.length > 0) {
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestProperty("Content-Length", dataToSend.length + "");
|
||||
outputStream = connection.getOutputStream();
|
||||
outputStream.write(dataToSend);
|
||||
}
|
||||
|
||||
final InputStream inputStream = connection.getInputStream();
|
||||
final StringBuilder response = new StringBuilder();
|
||||
|
||||
// Not passing any charset for decoding here... something to keep in mind.
|
||||
input = new InputStreamReader(inputStream);
|
||||
|
||||
int readCount;
|
||||
char[] buffer = new char[32 * 1024];
|
||||
while ((readCount = input.read(buffer)) != -1) {
|
||||
response.append(buffer, 0, readCount);
|
||||
}
|
||||
|
||||
final int responseCode = connection.getResponseCode();
|
||||
final String responseMessage = connection.getResponseMessage();
|
||||
final Map<String, List<String>> responseHeaders = connection.getHeaderFields();
|
||||
|
||||
return new Response(responseCode, responseMessage, responseHeaders, response.toString());
|
||||
} catch (Exception e) {
|
||||
/*
|
||||
* HTTP 429 == Too Many Request
|
||||
* Receive from Youtube.com = ReCaptcha challenge request
|
||||
* See : https://github.com/rg3/youtube-dl/issues/5138
|
||||
*/
|
||||
if (connection.getResponseCode() == 429) {
|
||||
throw new ReCaptchaException("reCaptcha Challenge requested", url);
|
||||
}
|
||||
|
||||
throw new IOException(connection.getResponseCode() + " " + connection.getResponseMessage(), e);
|
||||
} finally {
|
||||
if (outputStream != null) outputStream.close();
|
||||
if (input != null) input.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,10 @@ package org.schabi.newpipe.extractor.services;
|
||||
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -27,6 +29,14 @@ public final class DefaultTests {
|
||||
StreamInfoItem streamInfoItem = (StreamInfoItem) item;
|
||||
assertNotEmpty("Uploader name not set: " + item, streamInfoItem.getUploaderName());
|
||||
assertNotEmpty("Uploader url not set: " + item, streamInfoItem.getUploaderUrl());
|
||||
|
||||
final String textualUploadDate = streamInfoItem.getTextualUploadDate();
|
||||
if (textualUploadDate != null && !textualUploadDate.isEmpty()) {
|
||||
final DateWrapper uploadDate = streamInfoItem.getUploadDate();
|
||||
assertNotNull("No parsed upload date", uploadDate);
|
||||
assertTrue("Upload date not in the past", uploadDate.date().before(Calendar.getInstance()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@ package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
|
||||
@@ -19,7 +18,7 @@ public class MediaCCCConferenceExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("en", "en_GB"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = MediaCCC.getChannelExtractor("https://api.media.ccc.de/public/conferences/froscon2017");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceKiosk;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
|
||||
|
||||
|
||||
/**
|
||||
@@ -24,7 +23,7 @@ public class MediaCCCConferenceListExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("en", "en_GB"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = MediaCCC.getKioskList().getDefaultKioskExtractor();
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@@ -2,13 +2,11 @@ package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
|
||||
@@ -22,7 +20,7 @@ public class MediaCCCOggTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
|
||||
extractor = MediaCCC.getStreamExtractor("https://api.media.ccc.de/public/events/1317");
|
||||
extractor.fetchPage();
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
@@ -11,7 +11,6 @@ import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -28,10 +27,9 @@ public class MediaCCCSearchExtractorAllTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = MediaCCC.getSearchExtractor( new MediaCCCSearchQueryHandlerFactory()
|
||||
.fromQuery("c3", Arrays.asList(new String[0]), "")
|
||||
,new Localization("GB", "en"));
|
||||
.fromQuery("c3", Arrays.asList(new String[0]), ""));
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
@@ -10,7 +10,6 @@ import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -27,10 +26,9 @@ public class MediaCCCSearchExtractorConferencesTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = MediaCCC.getSearchExtractor( new MediaCCCSearchQueryHandlerFactory()
|
||||
.fromQuery("c3", Arrays.asList(new String[] {"conferences"}), "")
|
||||
,new Localization("GB", "en"));
|
||||
.fromQuery("c3", Arrays.asList(new String[]{"conferences"}), ""));
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
@@ -10,7 +10,6 @@ import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -28,10 +27,9 @@ public class MediaCCCSearchExtractorEventsTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = MediaCCC.getSearchExtractor( new MediaCCCSearchQueryHandlerFactory()
|
||||
.fromQuery("linux", Arrays.asList(new String[] {"events"}), "")
|
||||
,new Localization("GB", "en"));
|
||||
.fromQuery("linux", Arrays.asList(new String[]{"events"}), ""));
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseExtractorTest;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
|
||||
|
||||
@@ -20,7 +26,7 @@ public class MediaCCCStreamExtractorTest implements BaseExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
|
||||
extractor = MediaCCC.getStreamExtractor("https://api.media.ccc.de/public/events/8afc16c2-d76a-53f6-85e4-90494665835d");
|
||||
extractor.fetchPage();
|
||||
@@ -80,4 +86,16 @@ public class MediaCCCStreamExtractorTest implements BaseExtractorTest {
|
||||
public void testAudioStreams() throws Exception {
|
||||
assertEquals(2, extractor.getAudioStreams().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTextualUploadDate() throws ParsingException {
|
||||
Assert.assertEquals("2018-05-11", extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(new SimpleDateFormat("yyyy-MM-dd").parse("2018-05-11"));
|
||||
assertEquals(instance, requireNonNull(extractor.getUploadDate()).date());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,12 @@ import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRela
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
/**
|
||||
* Test for {@link PeertubeChannelExtractor}
|
||||
@@ -30,7 +29,7 @@ public class PeertubeChannelExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host");
|
||||
extractor = (PeertubeChannelExtractor) PeerTube
|
||||
@@ -117,7 +116,7 @@ public class PeertubeChannelExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host");
|
||||
extractor = (PeertubeChannelExtractor) PeerTube
|
||||
|
||||
@@ -5,11 +5,10 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
/**
|
||||
* Test for {@link PeertubeChannelLinkHandlerFactory}
|
||||
@@ -21,7 +20,7 @@ public class PeertubeChannelLinkHandlerFactoryTest {
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
linkHandler = PeertubeChannelLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -10,14 +10,13 @@ import java.util.List;
|
||||
import org.jsoup.helper.StringUtil;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.comments.CommentsInfo;
|
||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeCommentsExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
public class PeertubeCommentsExtractorTest {
|
||||
|
||||
@@ -25,7 +24,7 @@ public class PeertubeCommentsExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (PeertubeCommentsExtractor) PeerTube
|
||||
.getCommentsExtractor("https://peertube.mastodon.host/videos/watch/04af977f-4201-4697-be67-a8d8cae6fa7a");
|
||||
}
|
||||
@@ -71,10 +70,10 @@ public class PeertubeCommentsExtractorTest {
|
||||
assertFalse(StringUtil.isBlank(c.getCommentId()));
|
||||
assertFalse(StringUtil.isBlank(c.getCommentText()));
|
||||
assertFalse(StringUtil.isBlank(c.getName()));
|
||||
assertFalse(StringUtil.isBlank(c.getPublishedTime()));
|
||||
assertFalse(StringUtil.isBlank(c.getTextualPublishedTime()));
|
||||
assertFalse(StringUtil.isBlank(c.getThumbnailUrl()));
|
||||
assertFalse(StringUtil.isBlank(c.getUrl()));
|
||||
assertFalse(c.getLikeCount() == null);
|
||||
assertFalse(c.getLikeCount() == -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,10 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeCommentsLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
/**
|
||||
* Test for {@link PeertubeCommentsLinkHandlerFactory}
|
||||
@@ -21,7 +20,7 @@ public class PeertubeCommentsLinkHandlerFactoryTest {
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
linkHandler = PeertubeCommentsLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -5,11 +5,10 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubePlaylistLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
/**
|
||||
* Test for {@link PeertubePlaylistLinkHandlerFactory}
|
||||
@@ -21,7 +20,7 @@ public class PeertubePlaylistLinkHandlerFactoryTest {
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
linkHandler = PeertubePlaylistLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.schabi.newpipe.extractor.services.peertube;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -7,11 +8,14 @@ import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
@@ -19,7 +23,6 @@ import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeStreamE
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
/**
|
||||
* Test for {@link StreamExtractor}
|
||||
@@ -29,7 +32,7 @@ public class PeertubeStreamExtractorDefaultTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host");
|
||||
extractor = (PeertubeStreamExtractor) PeerTube.getStreamExtractor("https://peertube.mastodon.host/videos/watch/afe5bf12-c58b-4efd-b56e-29c5a59e04bc");
|
||||
@@ -69,8 +72,11 @@ public class PeertubeStreamExtractorDefaultTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException {
|
||||
assertEquals("2018-09-30", extractor.getUploadDate());
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'").parse("2018-09-30T14:08:24.378Z"));
|
||||
assertEquals(instance, requireNonNull(extractor.getUploadDate()).date());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -5,11 +5,10 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeStreamLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
/**
|
||||
* Test for {@link PeertubeStreamLinkHandlerFactory}
|
||||
@@ -20,7 +19,7 @@ public class PeertubeStreamLinkHandlerFactoryTest {
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
linkHandler = PeertubeStreamLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -10,13 +10,12 @@ import java.util.List;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
||||
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeTrendingExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
/**
|
||||
* Test for {@link PeertubeTrendingExtractor}
|
||||
@@ -27,7 +26,7 @@ public class PeertubeTrendingExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host");
|
||||
extractor = PeerTube
|
||||
|
||||
@@ -6,12 +6,11 @@ import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeTrendingLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
/**
|
||||
* Test for {@link PeertubeTrendingLinkHandlerFactory}
|
||||
@@ -24,7 +23,7 @@ public class PeertubeTrendingLinkHandlerFactoryTest {
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host");
|
||||
LinkHandlerFactory = new PeertubeTrendingLinkHandlerFactory();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -7,13 +7,12 @@ import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
/**
|
||||
* Test for {@link PeertubeSearchExtractor}
|
||||
@@ -22,7 +21,7 @@ public class PeertubeSearchExtractorDefaultTest extends PeertubeSearchExtractorB
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host");
|
||||
extractor = (PeertubeSearchExtractor) PeerTube.getSearchExtractor("kde");
|
||||
|
||||
@@ -2,12 +2,11 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
|
||||
@@ -24,7 +23,7 @@ public class SoundcloudChannelExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (SoundcloudChannelExtractor) SoundCloud
|
||||
.getChannelExtractor("http://soundcloud.com/liluzivert/sets");
|
||||
extractor.fetchPage();
|
||||
@@ -108,7 +107,7 @@ public class SoundcloudChannelExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (SoundcloudChannelExtractor) SoundCloud
|
||||
.getChannelExtractor("https://soundcloud.com/dubmatix");
|
||||
extractor.fetchPage();
|
||||
|
||||
@@ -3,12 +3,11 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,7 +23,7 @@ public class SoundcloudChartsExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = SoundCloud
|
||||
.getKioskList()
|
||||
.getExtractorById("Top 50", null);
|
||||
|
||||
@@ -2,10 +2,9 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -20,7 +19,7 @@ public class SoundcloudChartsLinkHandlerFactoryTest {
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
linkHandler = new SoundcloudChartsLinkHandlerFactory();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.*;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SoundcloudParsingHelperTest {
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assertThatHardcodedClientIdIsValid() throws Exception {
|
||||
assertTrue("Hardcoded client id is not valid anymore",
|
||||
SoundcloudParsingHelper.checkIfHardcodedClientIdIsValid(Downloader.getInstance()));
|
||||
SoundcloudParsingHelper.checkIfHardcodedClientIdIsValid(DownloaderTestImpl.getInstance()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -4,14 +4,13 @@ import org.hamcrest.CoreMatchers;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.ServiceList;
|
||||
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
@@ -27,7 +26,7 @@ public class SoundcloudPlaylistExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
||||
.getPlaylistExtractor("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r?test=123");
|
||||
extractor.fetchPage();
|
||||
@@ -125,7 +124,7 @@ public class SoundcloudPlaylistExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
||||
.getPlaylistExtractor("https://soundcloud.com/micky96/sets/house");
|
||||
extractor.fetchPage();
|
||||
@@ -217,7 +216,7 @@ public class SoundcloudPlaylistExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
||||
.getPlaylistExtractor("https://soundcloud.com/user350509423/sets/edm-xxx");
|
||||
extractor.fetchPage();
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
@@ -25,7 +29,7 @@ public class SoundcloudStreamExtractorDefaultTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (SoundcloudStreamExtractor) SoundCloud.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
@@ -69,8 +73,15 @@ public class SoundcloudStreamExtractorDefaultTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException {
|
||||
assertEquals("2016-07-31", extractor.getUploadDate());
|
||||
public void testGetTextualUploadDate() throws ParsingException {
|
||||
Assert.assertEquals("2016/07/31 18:18:07 +0000", extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss +0000").parse("2016/07/31 18:18:07 +0000"));
|
||||
assertEquals(instance, requireNonNull(extractor.getUploadDate()).date());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -2,10 +2,9 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -21,7 +20,7 @@ public class SoundcloudStreamLinkHandlerFactoryTest {
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
linkHandler = SoundcloudStreamLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
||||
@@ -2,14 +2,13 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.ServiceList;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@@ -26,7 +25,7 @@ public class SoundcloudSubscriptionExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setupClass() {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
subscriptionExtractor = new SoundcloudSubscriptionExtractor(ServiceList.SoundCloud);
|
||||
urlHandler = ServiceList.SoundCloud.getChannelLHFactory();
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -21,7 +20,7 @@ public class SoundcloudSuggestionExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
suggestionExtractor = SoundCloud.getSuggestionExtractor();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ package org.schabi.newpipe.extractor.services.soundcloud.search;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.localization.Localization;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQueryHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.Assert.*;
|
||||
@@ -19,9 +19,9 @@ public class SoundcloudSearchExtractorChannelOnlyTest extends SoundcloudSearchEx
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("DE", "de"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance(), new Localization("de", "DE"));
|
||||
extractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert",
|
||||
asList(SoundcloudSearchQueryHandlerFactory.USERS), null, new Localization("DE", "de"));
|
||||
asList(SoundcloudSearchQueryHandlerFactory.USERS), null);
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class SoundcloudSearchExtractorChannelOnlyTest extends SoundcloudSearchEx
|
||||
@Test
|
||||
public void testGetSecondPage() throws Exception {
|
||||
SoundcloudSearchExtractor secondExtractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert",
|
||||
asList(SoundcloudSearchQueryHandlerFactory.USERS), null, new Localization("DE", "de"));
|
||||
asList(SoundcloudSearchQueryHandlerFactory.USERS), null);
|
||||
ListExtractor.InfoItemsPage<InfoItem> secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl());
|
||||
assertTrue(Integer.toString(secondPage.getItems().size()),
|
||||
secondPage.getItems().size() >= 3);
|
||||
|
||||
@@ -2,22 +2,19 @@ package org.schabi.newpipe.extractor.services.soundcloud.search;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQueryHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 27.05.18
|
||||
@@ -46,11 +43,10 @@ public class SoundcloudSearchExtractorDefaultTest extends SoundcloudSearchExtrac
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor(
|
||||
new SoundcloudSearchQueryHandlerFactory().fromQuery("lill uzi vert",
|
||||
Arrays.asList(new String[]{"tracks"}), ""),
|
||||
new Localization("GB", "en"));
|
||||
Arrays.asList(new String[]{"tracks"}), ""));
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
}
|
||||
|
||||
@@ -2,22 +2,19 @@ package org.schabi.newpipe.extractor.services.soundcloud.search;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQueryHandlerFactory.PLAYLISTS;
|
||||
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQueryHandlerFactory.TRACKS;
|
||||
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQueryHandlerFactory.USERS;
|
||||
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQueryHandlerFactory.*;
|
||||
|
||||
public class SoundcloudSearchQHTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
private static String removeClientId(String url) {
|
||||
|
||||
@@ -11,14 +11,14 @@ import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRela
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.ServiceList;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.localization.Localization;
|
||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
/**
|
||||
* Test for {@link ChannelExtractor}
|
||||
@@ -29,7 +29,7 @@ public class YoutubeChannelExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeChannelExtractor) YouTube
|
||||
.getChannelExtractor("http://www.youtube.com/user/Gronkh");
|
||||
extractor.fetchPage();
|
||||
@@ -119,7 +119,7 @@ public class YoutubeChannelExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeChannelExtractor) YouTube
|
||||
.getChannelExtractor("https://www.youtube.com/user/Vsauce");
|
||||
extractor.fetchPage();
|
||||
@@ -210,7 +210,7 @@ public class YoutubeChannelExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeChannelExtractor) YouTube
|
||||
.getChannelExtractor("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q");
|
||||
extractor.fetchPage();
|
||||
@@ -312,7 +312,7 @@ public class YoutubeChannelExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeChannelExtractor) YouTube
|
||||
.getChannelExtractor("https://www.youtube.com/user/CaptainDisillusion/videos");
|
||||
extractor.fetchPage();
|
||||
@@ -402,7 +402,7 @@ public class YoutubeChannelExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeChannelExtractor) YouTube
|
||||
.getChannelExtractor("https://www.youtube.com/user/EminemVEVO/");
|
||||
extractor.fetchPage();
|
||||
@@ -495,7 +495,7 @@ public class YoutubeChannelExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeChannelExtractor) YouTube
|
||||
.getChannelExtractor("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w");
|
||||
extractor.fetchPage();
|
||||
|
||||
@@ -2,11 +2,10 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -21,7 +20,7 @@ public class YoutubeChannelLinkHandlerFactoryTest {
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
linkHandler = YoutubeChannelLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.localization.Localization;
|
||||
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
|
||||
|
||||
/**
|
||||
* A class that tests multiple channels and ranges of "time ago".
|
||||
*/
|
||||
@Ignore("Should be ran manually from time to time, as it's too time consuming.")
|
||||
public class YoutubeChannelLocalizationTest {
|
||||
private static final boolean DEBUG = true;
|
||||
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
|
||||
@Test
|
||||
public void testAllSupportedLocalizations() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
|
||||
testLocalizationsFor("https://www.youtube.com/user/NBCNews");
|
||||
testLocalizationsFor("https://www.youtube.com/channel/UCcmpeVbSSQlZRvHfdC-CRwg/videos");
|
||||
testLocalizationsFor("https://www.youtube.com/channel/UC65afEgL62PGFWXY7n6CUbA");
|
||||
testLocalizationsFor("https://www.youtube.com/channel/UCEOXxzW2vU0P-0THehuIIeg");
|
||||
}
|
||||
|
||||
private void testLocalizationsFor(String channelUrl) throws Exception {
|
||||
|
||||
final List<Localization> supportedLocalizations = YouTube.getSupportedLocalizations();
|
||||
// final List<Localization> supportedLocalizations = Arrays.asList(Localization.DEFAULT, new Localization("sr"));
|
||||
final Map<Localization, List<StreamInfoItem>> results = new LinkedHashMap<>();
|
||||
|
||||
for (Localization currentLocalization : supportedLocalizations) {
|
||||
if (DEBUG) System.out.println("Testing localization = " + currentLocalization);
|
||||
|
||||
ListExtractor.InfoItemsPage<StreamInfoItem> itemsPage;
|
||||
try {
|
||||
final ChannelExtractor extractor = YouTube.getChannelExtractor(channelUrl);
|
||||
extractor.forceLocalization(currentLocalization);
|
||||
extractor.fetchPage();
|
||||
itemsPage = defaultTestRelatedItems(extractor, YouTube.getServiceId());
|
||||
} catch (Throwable e) {
|
||||
System.out.println("[!] " + currentLocalization + " → failed");
|
||||
throw e;
|
||||
}
|
||||
|
||||
final List<StreamInfoItem> items = itemsPage.getItems();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
final StreamInfoItem item = items.get(i);
|
||||
|
||||
String debugMessage = "[" + String.format("%02d", i) + "] "
|
||||
+ currentLocalization.getLocalizationCode() + " → " + item.getName()
|
||||
+ "\n:::: " + item.getStreamType() + ", views = " + item.getViewCount();
|
||||
final DateWrapper uploadDate = item.getUploadDate();
|
||||
if (uploadDate != null) {
|
||||
String dateAsText = dateFormat.format(uploadDate.date().getTime());
|
||||
debugMessage += "\n:::: " + item.getTextualUploadDate() +
|
||||
"\n:::: " + dateAsText;
|
||||
}
|
||||
if (DEBUG) System.out.println(debugMessage + "\n");
|
||||
}
|
||||
results.put(currentLocalization, itemsPage.getItems());
|
||||
|
||||
if (DEBUG) System.out.println("\n===============================\n");
|
||||
}
|
||||
|
||||
|
||||
// Check results
|
||||
final List<StreamInfoItem> referenceList = results.get(Localization.DEFAULT);
|
||||
boolean someFail = false;
|
||||
|
||||
for (Map.Entry<Localization, List<StreamInfoItem>> currentResultEntry : results.entrySet()) {
|
||||
if (currentResultEntry.getKey().equals(Localization.DEFAULT)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String currentLocalizationCode = currentResultEntry.getKey().getLocalizationCode();
|
||||
final String referenceLocalizationCode = Localization.DEFAULT.getLocalizationCode();
|
||||
if (DEBUG) {
|
||||
System.out.println("Comparing " + referenceLocalizationCode + " with " +
|
||||
currentLocalizationCode);
|
||||
}
|
||||
|
||||
final List<StreamInfoItem> currentList = currentResultEntry.getValue();
|
||||
if (referenceList.size() != currentList.size()) {
|
||||
if (DEBUG) System.out.println("[!] " + currentLocalizationCode + " → Lists are not equal");
|
||||
someFail = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < referenceList.size() - 1; i++) {
|
||||
final StreamInfoItem referenceItem = referenceList.get(i);
|
||||
final StreamInfoItem currentItem = currentList.get(i);
|
||||
|
||||
final DateWrapper referenceUploadDate = referenceItem.getUploadDate();
|
||||
final DateWrapper currentUploadDate = currentItem.getUploadDate();
|
||||
|
||||
final String referenceDateString = referenceUploadDate == null ? "null" :
|
||||
dateFormat.format(referenceUploadDate.date().getTime());
|
||||
final String currentDateString = currentUploadDate == null ? "null" :
|
||||
dateFormat.format(currentUploadDate.date().getTime());
|
||||
|
||||
long difference = -1;
|
||||
if (referenceUploadDate != null && currentUploadDate != null) {
|
||||
difference = Math.abs(referenceUploadDate.date().getTimeInMillis() - currentUploadDate.date().getTimeInMillis());
|
||||
}
|
||||
|
||||
final boolean areTimeEquals = difference < 5 * 60 * 1000L;
|
||||
|
||||
if (!areTimeEquals) {
|
||||
System.out.println("" +
|
||||
" [!] " + currentLocalizationCode + " → [" + i + "] dates are not equal\n" +
|
||||
" " + referenceLocalizationCode + ": " +
|
||||
referenceDateString + " → " + referenceItem.getTextualUploadDate() +
|
||||
"\n " + currentLocalizationCode + ": " +
|
||||
currentDateString + " → " + currentItem.getTextualUploadDate());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (someFail) {
|
||||
fail("Some localization failed");
|
||||
} else {
|
||||
if (DEBUG) System.out.print("All tests passed" +
|
||||
"\n\n===============================\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,23 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.jsoup.helper.StringUtil;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.comments.CommentsInfo;
|
||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.services.DefaultTests;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeCommentsExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
public class YoutubeCommentsExtractorTest {
|
||||
|
||||
@@ -25,7 +25,7 @@ public class YoutubeCommentsExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeCommentsExtractor) YouTube
|
||||
.getCommentsExtractor("https://www.youtube.com/watch?v=D00Au7k3i6o");
|
||||
}
|
||||
@@ -64,6 +64,8 @@ public class YoutubeCommentsExtractorTest {
|
||||
@Test
|
||||
public void testGetCommentsAllData() throws IOException, ExtractionException {
|
||||
InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage();
|
||||
|
||||
DefaultTests.defaultTestListOfItems(YouTube.getServiceId(), comments.getItems(), comments.getErrors());
|
||||
for(CommentsInfoItem c: comments.getItems()) {
|
||||
assertFalse(StringUtil.isBlank(c.getAuthorEndpoint()));
|
||||
assertFalse(StringUtil.isBlank(c.getAuthorName()));
|
||||
@@ -71,10 +73,11 @@ public class YoutubeCommentsExtractorTest {
|
||||
assertFalse(StringUtil.isBlank(c.getCommentId()));
|
||||
assertFalse(StringUtil.isBlank(c.getCommentText()));
|
||||
assertFalse(StringUtil.isBlank(c.getName()));
|
||||
assertFalse(StringUtil.isBlank(c.getPublishedTime()));
|
||||
assertFalse(StringUtil.isBlank(c.getTextualPublishedTime()));
|
||||
assertNotNull(c.getPublishedTime());
|
||||
assertFalse(StringUtil.isBlank(c.getThumbnailUrl()));
|
||||
assertFalse(StringUtil.isBlank(c.getUrl()));
|
||||
assertFalse(c.getLikeCount() == null);
|
||||
assertFalse(c.getLikeCount() < 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.ServiceList;
|
||||
@@ -12,7 +12,6 @@ import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubePlaylistExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -29,7 +28,7 @@ public class YoutubePlaylistExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubePlaylistExtractor) YouTube
|
||||
.getPlaylistExtractor("http://www.youtube.com/watch?v=lp-EO5I60KA&list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj");
|
||||
extractor.fetchPage();
|
||||
@@ -126,7 +125,7 @@ public class YoutubePlaylistExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubePlaylistExtractor) YouTube
|
||||
.getPlaylistExtractor("https://www.youtube.com/watch?v=8SbUC-UaAxE&list=PLWwAypAcFRgKAIIFqBr9oy-ZYZnixa_Fj");
|
||||
extractor.fetchPage();
|
||||
|
||||
@@ -2,11 +2,10 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubePlaylistLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -18,8 +17,8 @@ public class YoutubePlaylistLinkHandlerFactoryTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
linkHandler = YoutubePlaylistLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
||||
@@ -22,11 +22,10 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskList;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -41,7 +40,7 @@ public class YoutubeServiceTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
service = YouTube;
|
||||
kioskList = service.getKioskList();
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -24,7 +23,7 @@ public class YoutubeStreamLinkHandlerFactoryTest {
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
linkHandler = YoutubeStreamLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
||||
@@ -2,14 +2,13 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.ServiceList;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
@@ -28,7 +27,7 @@ public class YoutubeSubscriptionExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setupClass() {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
subscriptionExtractor = new YoutubeSubscriptionExtractor(ServiceList.YouTube);
|
||||
urlHandler = ServiceList.YouTube.getChannelLHFactory();
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.localization.Localization;
|
||||
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class YoutubeSuggestionExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("DE", "de"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance(), new Localization("de", "DE"));
|
||||
suggestionExtractor = YouTube.getSuggestionExtractor();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,13 +22,13 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.localization.ContentCountry;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeTrendingExtractor;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
@@ -46,10 +46,11 @@ public class YoutubeTrendingExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeTrendingExtractor) YouTube
|
||||
.getKioskList()
|
||||
.getExtractorById("Trending", null);
|
||||
extractor.forceContentCountry(new ContentCountry("de"));
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,11 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -42,7 +41,7 @@ public class YoutubeTrendingKioskInfoTest {
|
||||
@BeforeClass
|
||||
public static void setUp()
|
||||
throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
StreamingService service = YouTube;
|
||||
LinkHandlerFactory LinkHandlerFactory = service.getKioskList().getListLinkHandlerFactoryByType("Trending");
|
||||
|
||||
|
||||
@@ -22,12 +22,11 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -43,7 +42,7 @@ public class YoutubeTrendingLinkHandlerFactoryTest {
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
LinkHandlerFactory = YouTube.getKioskList().getListLinkHandlerFactoryByType("Trending");
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -2,12 +2,11 @@ package org.schabi.newpipe.extractor.services.youtube.search;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
@@ -20,9 +19,9 @@ public class YoutubeSearchCountTest {
|
||||
public static class YoutubeChannelViewCountTest extends YoutubeSearchExtractorBaseTest {
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie",
|
||||
singletonList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, new Localization("GB", "en"));
|
||||
singletonList(YoutubeSearchQueryHandlerFactory.CHANNELS), null);
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
}
|
||||
|
||||
@@ -4,14 +4,13 @@ import org.hamcrest.CoreMatchers;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.Assert.*;
|
||||
@@ -21,9 +20,9 @@ public class YoutubeSearchExtractorChannelOnlyTest extends YoutubeSearchExtracto
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie",
|
||||
asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, new Localization("GB", "en"));
|
||||
asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null);
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
}
|
||||
@@ -31,7 +30,7 @@ public class YoutubeSearchExtractorChannelOnlyTest extends YoutubeSearchExtracto
|
||||
@Test
|
||||
public void testGetSecondPage() throws Exception {
|
||||
YoutubeSearchExtractor secondExtractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie",
|
||||
asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, new Localization("GB", "en"));
|
||||
asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null);
|
||||
ListExtractor.InfoItemsPage<InfoItem> secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl());
|
||||
assertTrue(Integer.toString(secondPage.getItems().size()),
|
||||
secondPage.getItems().size() > 10);
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube.search;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
@@ -10,11 +10,8 @@ import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
/*
|
||||
@@ -44,7 +41,7 @@ public class YoutubeSearchExtractorDefaultTest extends YoutubeSearchExtractorBas
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie");
|
||||
extractor.fetchPage();
|
||||
itemsPage = extractor.getInitialPage();
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube.stream;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.MediaFormat;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
@@ -12,12 +11,15 @@ import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExt
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
@@ -31,7 +33,7 @@ public class YoutubeStreamExtractorAgeRestrictedTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=MmBeUZqv1QA");
|
||||
extractor.fetchPage();
|
||||
@@ -82,8 +84,15 @@ public class YoutubeStreamExtractorAgeRestrictedTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException {
|
||||
assertTrue(extractor.getUploadDate().length() > 0);
|
||||
public void testGetTextualUploadDate() throws ParsingException {
|
||||
assertEquals("2017-01-25", extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(new SimpleDateFormat("yyyy-MM-dd").parse("2017-01-25"));
|
||||
assertEquals(instance, requireNonNull(extractor.getUploadDate()).date());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.schabi.newpipe.extractor.services.youtube.stream;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.MediaFormat;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
@@ -12,12 +12,15 @@ import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExt
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
@@ -30,7 +33,7 @@ public class YoutubeStreamExtractorControversialTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=T4XJQO3qol8");
|
||||
extractor.fetchPage();
|
||||
@@ -82,8 +85,15 @@ public class YoutubeStreamExtractorControversialTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException {
|
||||
assertTrue(extractor.getUploadDate().length() > 0);
|
||||
public void testGetTextualUploadDate() throws ParsingException {
|
||||
assertEquals("2010-09-09", extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(new SimpleDateFormat("yyyy-MM-dd").parse("2010-09-09"));
|
||||
assertEquals(instance, requireNonNull(extractor.getUploadDate()).date());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube.stream;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ExtractorAsserts;
|
||||
import org.schabi.newpipe.extractor.MediaFormat;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
@@ -10,12 +11,15 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.*;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Objects.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
@@ -53,7 +57,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=YQHsXMglC9A");
|
||||
extractor.fetchPage();
|
||||
@@ -107,8 +111,15 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException {
|
||||
assertTrue(extractor.getUploadDate().length() > 0);
|
||||
public void testGetTextualUploadDate() throws ParsingException {
|
||||
Assert.assertEquals("2015-10-22", extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(new SimpleDateFormat("yyyy-MM-dd").parse("2015-10-22"));
|
||||
assertEquals(instance, requireNonNull(extractor.getUploadDate()).date());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -179,7 +190,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=fBc4Q_htqPg");
|
||||
extractor.fetchPage();
|
||||
@@ -208,7 +219,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=cV5TjZCJkuA");
|
||||
extractor.fetchPage();
|
||||
@@ -239,7 +250,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=HoK9shIJ2xQ");
|
||||
extractor.fetchPage();
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube.stream;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.MediaFormat;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
@@ -11,7 +11,6 @@ import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExt
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -25,7 +24,7 @@ public class YoutubeStreamExtractorLivestreamTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=EcEMX-63PKY");
|
||||
extractor.fetchPage();
|
||||
@@ -69,12 +68,13 @@ public class YoutubeStreamExtractorLivestreamTest {
|
||||
@Test
|
||||
public void testGetViewCount() throws ParsingException {
|
||||
long count = extractor.getViewCount();
|
||||
assertTrue(Long.toString(count), count >= 7148995);
|
||||
assertTrue(Long.toString(count), count > -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException {
|
||||
assertTrue(extractor.getUploadDate().length() > 0);
|
||||
assertNull(extractor.getUploadDate());
|
||||
assertNull(extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user