Merge remote-tracking branch 'origin/dev' into bandcamp
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package org.schabi.newpipe.downloader;
|
||||
|
||||
import org.schabi.newpipe.extractor.downloader.Downloader;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DownloaderFactory {
|
||||
|
||||
public final static String RESOURCE_PATH = "src/test/resources/org/schabi/newpipe/extractor/";
|
||||
|
||||
private final static DownloaderType DEFAULT_DOWNLOADER = DownloaderType.REAL;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns a implementation of a {@link Downloader}.
|
||||
* </p>
|
||||
* <p>
|
||||
* If the system property "downloader" is set and is one of {@link DownloaderType},
|
||||
* then a downloader of that type is returned.
|
||||
* It can be passed in with gradle by adding the argument -Ddownloader=abcd,
|
||||
* where abcd is one of {@link DownloaderType}
|
||||
* </p>
|
||||
* <p>
|
||||
* Otherwise it falls back to {@link DownloaderFactory#DEFAULT_DOWNLOADER}.
|
||||
* Change this during development on the local machine to use a different downloader.
|
||||
* </p>
|
||||
*
|
||||
* @param path The path to the folder where mocks are saved/retrieved.
|
||||
* Preferably starting with {@link DownloaderFactory#RESOURCE_PATH}
|
||||
*/
|
||||
public Downloader getDownloader(String path) throws IOException {
|
||||
DownloaderType type;
|
||||
try {
|
||||
type = DownloaderType.valueOf(System.getProperty("downloader"));
|
||||
} catch (Exception e) {
|
||||
type = DEFAULT_DOWNLOADER;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case REAL:
|
||||
return DownloaderTestImpl.getInstance();
|
||||
case MOCK:
|
||||
return new MockDownloader(path);
|
||||
case RECORDING:
|
||||
return new RecordingDownloader(path);
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unknown downloader type: " + type.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.schabi.newpipe;
|
||||
package org.schabi.newpipe.downloader;
|
||||
|
||||
import org.schabi.newpipe.extractor.downloader.Downloader;
|
||||
import org.schabi.newpipe.extractor.downloader.Request;
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.schabi.newpipe.downloader;
|
||||
|
||||
public enum DownloaderType {
|
||||
REAL, MOCK, RECORDING
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.schabi.newpipe.downloader;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import org.schabi.newpipe.extractor.downloader.Downloader;
|
||||
import org.schabi.newpipe.extractor.downloader.Request;
|
||||
import org.schabi.newpipe.extractor.downloader.Response;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mocks requests by using json files created by {@link RecordingDownloader}
|
||||
* </p>
|
||||
*/
|
||||
class MockDownloader extends Downloader {
|
||||
|
||||
private final String path;
|
||||
private final Map<Request, Response> mocks;
|
||||
|
||||
public MockDownloader(@Nonnull String path) throws IOException {
|
||||
this.path = path;
|
||||
this.mocks = new HashMap<>();
|
||||
File folder = new File(path);
|
||||
for (File file : folder.listFiles()) {
|
||||
if (file.getName().startsWith(RecordingDownloader.FILE_NAME_PREFIX)) {
|
||||
final FileReader reader = new FileReader(file);
|
||||
final TestRequestResponse response = new GsonBuilder()
|
||||
.create()
|
||||
.fromJson(reader, TestRequestResponse.class);
|
||||
reader.close();
|
||||
mocks.put(response.getRequest(), response.getResponse());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response execute(@Nonnull Request request) {
|
||||
Response result = mocks.get(request);
|
||||
if (result == null) {
|
||||
throw new NullPointerException("No mock response for request with url '" + request.url()
|
||||
+ "' exists in path '" + path + "'.\nPlease make sure to run the tests with " +
|
||||
"the RecordingDownloader first after changes.");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package org.schabi.newpipe.downloader;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
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 java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Relays requests to {@link DownloaderTestImpl} and saves the request/response pair into a json file.
|
||||
* </p>
|
||||
* <p>
|
||||
* Those files are used by {@link MockDownloader}.
|
||||
* </p>
|
||||
* <p>
|
||||
* The files <b>must</b> be created on the local dev environment
|
||||
* and recreated when the requests made by a test class change.
|
||||
* </p>
|
||||
*/
|
||||
class RecordingDownloader extends Downloader {
|
||||
|
||||
public final static String FILE_NAME_PREFIX = "generated_mock_";
|
||||
|
||||
private int index = 0;
|
||||
private final String path;
|
||||
|
||||
/**
|
||||
* Creates the folder described by {@code stringPath} if it does not exists.
|
||||
* Deletes existing files starting with {@link RecordingDownloader#FILE_NAME_PREFIX}.
|
||||
* @param stringPath Path to the folder where the json files will be saved to.
|
||||
*/
|
||||
public RecordingDownloader(String stringPath) throws IOException {
|
||||
this.path = stringPath;
|
||||
Path path = Paths.get(stringPath);
|
||||
File folder = path.toFile();
|
||||
if (folder.exists()) {
|
||||
for (File file : folder.listFiles()) {
|
||||
if (file.getName().startsWith(RecordingDownloader.FILE_NAME_PREFIX)) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Files.createDirectories(path);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response execute(@Nonnull Request request) throws IOException, ReCaptchaException {
|
||||
Downloader downloader = DownloaderTestImpl.getInstance();
|
||||
Response response = downloader.execute(request);
|
||||
|
||||
File outputFile = new File(path + File.separator + FILE_NAME_PREFIX + index + ".json");
|
||||
index++;
|
||||
outputFile.createNewFile();
|
||||
FileWriter writer = new FileWriter(outputFile);
|
||||
new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.create()
|
||||
.toJson(new TestRequestResponse(request, response), writer);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.schabi.newpipe.downloader;
|
||||
|
||||
import org.schabi.newpipe.extractor.downloader.Request;
|
||||
import org.schabi.newpipe.extractor.downloader.Response;
|
||||
|
||||
final class TestRequestResponse {
|
||||
private final Request request;
|
||||
private final Response response;
|
||||
|
||||
public TestRequestResponse(Request request, Response response) {
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public Request getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public Response getResponse() {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,20 @@
|
||||
package org.schabi.newpipe.extractor.services;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.extractor.MetaInfo;
|
||||
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
|
||||
|
||||
@@ -20,6 +28,10 @@ public abstract class DefaultSearchExtractorTest extends DefaultListExtractorTes
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<MetaInfo> expectedMetaInfo() throws MalformedURLException {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSearchString() throws Exception {
|
||||
@@ -41,4 +53,34 @@ public abstract class DefaultSearchExtractorTest extends DefaultListExtractorTes
|
||||
public void testSearchCorrected() throws Exception {
|
||||
assertEquals(isCorrectedSearch(), extractor().isCorrectedSearch());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DefaultStreamExtractorTest#testMetaInfo()
|
||||
*/
|
||||
@Test
|
||||
public void testMetaInfo() throws Exception {
|
||||
final List<MetaInfo> metaInfoList = extractor().getMetaInfo();
|
||||
final List<MetaInfo> expectedMetaInfoList = expectedMetaInfo();
|
||||
|
||||
for (final MetaInfo expectedMetaInfo : expectedMetaInfoList) {
|
||||
final List<String> texts = metaInfoList.stream()
|
||||
.map(metaInfo -> metaInfo.getContent().getContent())
|
||||
.collect(Collectors.toList());
|
||||
final List<String> titles = metaInfoList.stream().map(MetaInfo::getTitle).collect(Collectors.toList());
|
||||
final List<URL> urls = metaInfoList.stream().flatMap(info -> info.getUrls().stream())
|
||||
.collect(Collectors.toList());
|
||||
final List<String> urlTexts = metaInfoList.stream().flatMap(info -> info.getUrlTexts().stream())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
assertTrue(texts.contains(expectedMetaInfo.getContent().getContent()));
|
||||
assertTrue(titles.contains(expectedMetaInfo.getTitle()));
|
||||
|
||||
for (final String expectedUrlText : expectedMetaInfo.getUrlTexts()) {
|
||||
assertTrue(urlTexts.contains(expectedUrlText));
|
||||
}
|
||||
for (final URL expectedUrl : expectedMetaInfo.getUrls()) {
|
||||
assertTrue(urls.contains(expectedUrl));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.schabi.newpipe.extractor.services;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.extractor.MediaFormat;
|
||||
import org.schabi.newpipe.extractor.MetaInfo;
|
||||
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||
import org.schabi.newpipe.extractor.stream.Description;
|
||||
@@ -15,9 +16,12 @@ import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
@@ -66,6 +70,8 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
|
||||
public Locale expectedLanguageInfo() { return null; } // default: no language info available
|
||||
public List<String> expectedTags() { return Collections.emptyList(); } // default: no tags
|
||||
public String expectedSupportInfo() { return ""; } // default: no support info available
|
||||
public int expectedStreamSegmentsCount() { return -1; } // return 0 or greater to test (default is -1 to ignore)
|
||||
public List<MetaInfo> expectedMetaInfo() throws MalformedURLException { return Collections.emptyList(); } // default: no metadata info available
|
||||
|
||||
@Test
|
||||
@Override
|
||||
@@ -332,6 +338,8 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
|
||||
assertIsValidUrl(url);
|
||||
assertIsSecureUrl(url);
|
||||
}
|
||||
assertTrue(f.getDurationPerFrame() > 0);
|
||||
assertEquals(f.getFrameBoundsAt(0)[3], f.getFrameWidth());
|
||||
}
|
||||
} else {
|
||||
assertTrue(frames.isEmpty());
|
||||
@@ -379,4 +387,42 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
|
||||
public void testSupportInfo() throws Exception {
|
||||
assertEquals(expectedSupportInfo(), extractor().getSupportInfo());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamSegmentsCount() throws Exception {
|
||||
if (expectedStreamSegmentsCount() >= 0) {
|
||||
assertEquals(expectedStreamSegmentsCount(), extractor().getStreamSegments().size());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DefaultSearchExtractorTest#testMetaInfo()
|
||||
*/
|
||||
@Test
|
||||
public void testMetaInfo() throws Exception {
|
||||
final List<MetaInfo> metaInfoList = extractor().getMetaInfo();
|
||||
final List<MetaInfo> expectedMetaInfoList = expectedMetaInfo();
|
||||
|
||||
for (final MetaInfo expectedMetaInfo : expectedMetaInfoList) {
|
||||
final List<String> texts = metaInfoList.stream()
|
||||
.map((metaInfo) -> metaInfo.getContent().getContent())
|
||||
.collect(Collectors.toList());
|
||||
final List<String> titles = metaInfoList.stream().map(MetaInfo::getTitle).collect(Collectors.toList());
|
||||
final List<URL> urls = metaInfoList.stream().flatMap(info -> info.getUrls().stream())
|
||||
.collect(Collectors.toList());
|
||||
final List<String> urlTexts = metaInfoList.stream().flatMap(info -> info.getUrlTexts().stream())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
assertTrue(texts.contains(expectedMetaInfo.getContent().getContent()));
|
||||
assertTrue(titles.contains(expectedMetaInfo.getTitle()));
|
||||
|
||||
for (final String expectedUrlText : expectedMetaInfo.getUrlTexts()) {
|
||||
assertTrue(urlTexts.contains(expectedUrlText));
|
||||
}
|
||||
for (final URL expectedUrl : expectedMetaInfo.getUrls()) {
|
||||
assertTrue(urls.contains(expectedUrl));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceExtractor;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferenceLinkHandlerFactory;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
||||
@@ -24,7 +24,7 @@ public class MediaCCCConferenceListExtractorTest {
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = MediaCCC.getKioskList().getDefaultKioskExtractor();
|
||||
extractor = MediaCCC.getKioskList().getExtractorById("conferences", null);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
|
||||
|
||||
public class MediaCCCLiveStreamListExtractorTest {
|
||||
private static KioskExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = MediaCCC.getKioskList().getExtractorById("live", null);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getConferencesListTest() throws Exception {
|
||||
final List<InfoItem> a = extractor.getInitialPage().getItems();
|
||||
for (int i = 0; i < a.size(); i++) {
|
||||
final InfoItem b = a.get(i);
|
||||
assertNotNull(a.get(i).getName());
|
||||
assertTrue(a.get(i).getName().length() >= 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
|
||||
|
||||
public class MediaCCCRecentListExtractorTest {
|
||||
private static KioskExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = MediaCCC.getKioskList().getExtractorById("recent", null);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testStreamList() throws Exception {
|
||||
final List<StreamInfoItem> items = extractor.getInitialPage().getItems();
|
||||
assertEquals(100, items.size());
|
||||
for (final StreamInfoItem item: items) {
|
||||
assertFalse(isNullOrEmpty(item.getName()));
|
||||
assertTrue(item.getDuration() > 0);
|
||||
assertTrue(isNullOrEmpty(item.getUploaderName())); // we do not get the uploader name
|
||||
assertTrue(item.getUploadDate().offsetDateTime().isBefore(OffsetDateTime.now()));
|
||||
assertTrue(item.getUploadDate().offsetDateTime().isAfter(OffsetDateTime.now().minusYears(1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
@@ -57,6 +57,7 @@ public class MediaCCCStreamExtractorTest {
|
||||
@Override public boolean expectedHasSubtitles() { return false; }
|
||||
@Override public boolean expectedHasFrames() { return false; }
|
||||
@Override public List<String> expectedTags() { return Arrays.asList("gpn18", "105"); }
|
||||
@Override public int expectedStreamSegmentsCount() { return 0; }
|
||||
|
||||
@Override
|
||||
@Test
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCStreamLinkHandlerFactory;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.schabi.newpipe.extractor.services.media_ccc.search;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.schabi.newpipe.extractor.services.peertube;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
@@ -19,16 +19,17 @@ import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
||||
* Test for {@link PeertubeAccountExtractor}
|
||||
*/
|
||||
public class PeertubeAccountExtractorTest {
|
||||
public static class KDE implements BaseChannelExtractorTest {
|
||||
|
||||
public static class Framasoft implements BaseChannelExtractorTest {
|
||||
private static PeertubeAccountExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));
|
||||
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
|
||||
extractor = (PeertubeAccountExtractor) PeerTube
|
||||
.getChannelExtractor("https://peertube.mastodon.host/accounts/kde");
|
||||
.getChannelExtractor("https://framatube.org/accounts/framasoft");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@@ -43,22 +44,22 @@ public class PeertubeAccountExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testName() throws ParsingException {
|
||||
assertEquals("The KDE Community", extractor.getName());
|
||||
assertEquals("Framasoft", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("accounts/kde", extractor.getId());
|
||||
assertEquals("accounts/framasoft", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/accounts/kde", extractor.getUrl());
|
||||
assertEquals("https://framatube.org/accounts/framasoft", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/accounts/kde", extractor.getOriginalUrl());
|
||||
assertEquals("https://framatube.org/accounts/framasoft", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
@@ -96,25 +97,26 @@ public class PeertubeAccountExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testFeedUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/feeds/videos.xml?accountId=32465", extractor.getFeedUrl());
|
||||
assertEquals("https://framatube.org/feeds/videos.xml?accountId=3", extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testSubscriberCount() throws ParsingException {
|
||||
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 5);
|
||||
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 500);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Booteille implements BaseChannelExtractorTest {
|
||||
public static class FreeSoftwareFoundation implements BaseChannelExtractorTest {
|
||||
private static PeertubeAccountExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));
|
||||
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
|
||||
extractor = (PeertubeAccountExtractor) PeerTube
|
||||
.getChannelExtractor("https://peertube.mastodon.host/api/v1/accounts/booteille");
|
||||
.getChannelExtractor("https://framatube.org/api/v1/accounts/fsf");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@@ -139,22 +141,22 @@ public class PeertubeAccountExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testName() throws ParsingException {
|
||||
assertEquals("booteille", extractor.getName());
|
||||
assertEquals("Free Software Foundation", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("accounts/booteille", extractor.getId());
|
||||
assertEquals("accounts/fsf", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/accounts/booteille", extractor.getUrl());
|
||||
assertEquals("https://framatube.org/accounts/fsf", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/accounts/booteille", extractor.getOriginalUrl());
|
||||
assertEquals("https://framatube.org/api/v1/accounts/fsf", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
@@ -185,20 +187,19 @@ public class PeertubeAccountExtractorTest {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testBannerUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getBannerUrl());
|
||||
assertNull(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFeedUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/feeds/videos.xml?accountId=1753", extractor.getFeedUrl());
|
||||
assertEquals("https://framatube.org/feeds/videos.xml?accountId=8178", extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriberCount() throws ParsingException {
|
||||
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 1);
|
||||
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.schabi.newpipe.extractor.services.peertube;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
@@ -19,16 +19,17 @@ import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
||||
* Test for {@link PeertubeChannelExtractor}
|
||||
*/
|
||||
public class PeertubeChannelExtractorTest {
|
||||
public static class DanDAugeTutoriels implements BaseChannelExtractorTest {
|
||||
|
||||
public static class LaQuadratureDuNet implements BaseChannelExtractorTest {
|
||||
private static PeertubeChannelExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));
|
||||
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
|
||||
extractor = (PeertubeChannelExtractor) PeerTube
|
||||
.getChannelExtractor("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa");
|
||||
.getChannelExtractor("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@@ -43,22 +44,22 @@ public class PeertubeChannelExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testName() throws ParsingException {
|
||||
assertEquals("Dan d'Auge tutoriels", extractor.getName());
|
||||
assertEquals("La Quadrature du Net", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa", extractor.getId());
|
||||
assertEquals("video-channels/lqdn_channel@video.lqdn.fr", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa", extractor.getUrl());
|
||||
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa", extractor.getOriginalUrl());
|
||||
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
@@ -86,12 +87,12 @@ public class PeertubeChannelExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testParentChannelName() throws ParsingException {
|
||||
assertEquals("libux", extractor.getParentChannelName());
|
||||
assertEquals("lqdn", extractor.getParentChannelName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParentChannelUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/accounts/libux", extractor.getParentChannelUrl());
|
||||
assertEquals("https://video.lqdn.fr/accounts/lqdn", extractor.getParentChannelUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -111,25 +112,26 @@ public class PeertubeChannelExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testFeedUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/feeds/videos.xml?videoChannelId=1361", extractor.getFeedUrl());
|
||||
assertEquals("https://framatube.org/feeds/videos.xml?videoChannelId=1126", extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriberCount() throws ParsingException {
|
||||
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 4);
|
||||
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 230);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Divers implements BaseChannelExtractorTest {
|
||||
public static class ChatSceptique implements BaseChannelExtractorTest {
|
||||
|
||||
private static PeertubeChannelExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));
|
||||
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
|
||||
extractor = (PeertubeChannelExtractor) PeerTube
|
||||
.getChannelExtractor("https://peertube.mastodon.host/api/v1/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457");
|
||||
.getChannelExtractor("https://framatube.org/api/v1/video-channels/chatsceptique@skeptikon.fr");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@@ -154,22 +156,22 @@ public class PeertubeChannelExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testName() throws ParsingException {
|
||||
assertEquals("Divers", extractor.getName());
|
||||
assertEquals("Chat Sceptique", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId() throws ParsingException {
|
||||
assertEquals("video-channels/35080089-79b6-45fc-96ac-37e4d46a4457", extractor.getId());
|
||||
assertEquals("video-channels/chatsceptique@skeptikon.fr", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457", extractor.getUrl());
|
||||
assertEquals("https://framatube.org/video-channels/chatsceptique@skeptikon.fr", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457", extractor.getOriginalUrl());
|
||||
assertEquals("https://framatube.org/api/v1/video-channels/chatsceptique@skeptikon.fr", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
@@ -197,12 +199,12 @@ public class PeertubeChannelExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testParentChannelName() throws ParsingException {
|
||||
assertEquals("booteille", extractor.getParentChannelName());
|
||||
assertEquals("nathan", extractor.getParentChannelName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParentChannelUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/accounts/booteille", extractor.getParentChannelUrl());
|
||||
assertEquals("https://skeptikon.fr/accounts/nathan", extractor.getParentChannelUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -215,20 +217,19 @@ public class PeertubeChannelExtractorTest {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testBannerUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getBannerUrl());
|
||||
assertNull(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFeedUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/feeds/videos.xml?videoChannelId=1227", extractor.getFeedUrl());
|
||||
assertEquals("https://framatube.org/feeds/videos.xml?videoChannelId=137", extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriberCount() throws ParsingException {
|
||||
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 2);
|
||||
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 700);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.peertube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelLinkHandlerFactory;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.peertube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.Page;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.peertube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeCommentsLinkHandlerFactory;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package org.schabi.newpipe.extractor.services.peertube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubePlaylistExtractor;
|
||||
@@ -44,11 +45,13 @@ public class PeertubePlaylistExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testGetUploaderName() throws ParsingException {
|
||||
assertEquals("Méta de Choc", extractor.getUploaderName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testGetStreamCount() throws ParsingException {
|
||||
assertEquals(35, extractor.getStreamCount());
|
||||
}
|
||||
@@ -59,6 +62,7 @@ public class PeertubePlaylistExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testGetSubChannelName() throws ParsingException {
|
||||
assertEquals("SHOCKING !", extractor.getSubChannelName());
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.peertube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubePlaylistLinkHandlerFactory;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package org.schabi.newpipe.extractor.services.peertube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
@@ -92,8 +93,17 @@ public class PeertubeStreamExtractorTest {
|
||||
@Override public String expectedLicence() { return "Attribution - Share Alike"; }
|
||||
@Override public Locale expectedLanguageInfo() { return Locale.forLanguageTag("en"); }
|
||||
@Override public List<String> expectedTags() { return Arrays.asList("framasoft", "peertube"); }
|
||||
@Override public int expectedStreamSegmentsCount() { return 0; }
|
||||
|
||||
@Override
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testSubChannelName() throws Exception {
|
||||
super.testSubChannelName();
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("TODO fix")
|
||||
public static class AgeRestricted extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "dbd8e5e1-c527-49b6-b70c-89101dbb9c08";
|
||||
private static final String INSTANCE = "https://nocensoring.net";
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.peertube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeStreamLinkHandlerFactory;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.peertube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||
@@ -13,6 +13,7 @@ import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
||||
|
||||
public class PeertubeTrendingExtractorTest {
|
||||
|
||||
public static class Trending implements BaseListExtractorTest {
|
||||
private static PeertubeTrendingExtractor extractor;
|
||||
|
||||
@@ -20,7 +21,7 @@ public class PeertubeTrendingExtractorTest {
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));
|
||||
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
|
||||
extractor = (PeertubeTrendingExtractor) PeerTube.getKioskList()
|
||||
.getExtractorById("Trending", null);
|
||||
extractor.fetchPage();
|
||||
@@ -47,12 +48,12 @@ public class PeertubeTrendingExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/videos?sort=-trending", extractor.getUrl());
|
||||
assertEquals("https://framatube.org/api/v1/videos?sort=-trending", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/videos?sort=-trending", extractor.getOriginalUrl());
|
||||
assertEquals("https://framatube.org/api/v1/videos?sort=-trending", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.peertube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.peertube.search;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
@@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.DefaultSearchExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeSearchQueryHandlerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -21,6 +22,29 @@ import static org.schabi.newpipe.extractor.services.peertube.linkHandler.Peertub
|
||||
public class PeertubeSearchExtractorTest {
|
||||
|
||||
public static class All extends DefaultSearchExtractorTest {
|
||||
private static SearchExtractor extractor;
|
||||
private static final String QUERY = "fsf";
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
|
||||
extractor = PeerTube.getSearchExtractor(QUERY);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Override public SearchExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return PeerTube; }
|
||||
@Override public String expectedName() { return QUERY; }
|
||||
@Override public String expectedId() { return QUERY; }
|
||||
@Override public String expectedUrlContains() { return "/search/videos?search=" + QUERY; }
|
||||
@Override public String expectedOriginalUrlContains() { return "/search/videos?search=" + QUERY; }
|
||||
@Override public String expectedSearchString() { return QUERY; }
|
||||
@Nullable @Override public String expectedSearchSuggestion() { return null; }
|
||||
}
|
||||
|
||||
public static class SepiaSearch extends DefaultSearchExtractorTest {
|
||||
private static SearchExtractor extractor;
|
||||
private static final String QUERY = "kde";
|
||||
|
||||
@@ -28,8 +52,8 @@ public class PeertubeSearchExtractorTest {
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));
|
||||
extractor = PeerTube.getSearchExtractor(QUERY);
|
||||
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
|
||||
extractor = PeerTube.getSearchExtractor(QUERY, singletonList(PeertubeSearchQueryHandlerFactory.SEPIA_VIDEOS), "");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package org.schabi.newpipe.extractor.services.peertube.search;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeSearchQueryHandlerFactory;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
|
||||
@@ -16,11 +19,14 @@ public class PeertubeSearchQHTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testRegularValues() throws Exception {
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/search/videos?search=asdf", PeerTube.getSearchQHFactory().fromQuery("asdf").getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/search/videos?search=hans", PeerTube.getSearchQHFactory().fromQuery("hans").getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/search/videos?search=Poifj%26jaijf", PeerTube.getSearchQHFactory().fromQuery("Poifj&jaijf").getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/search/videos?search=G%C3%BCl%C3%BCm", PeerTube.getSearchQHFactory().fromQuery("Gülüm").getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/search/videos?search=%3Fj%24%29H%C2%A7B", PeerTube.getSearchQHFactory().fromQuery("?j$)H§B").getUrl());
|
||||
assertEquals("https://sepiasearch.org/api/v1/search/videos?search=%3Fj%24%29H%C2%A7B", PeerTube.getSearchQHFactory().fromQuery("?j$)H§B", singletonList(PeertubeSearchQueryHandlerFactory.SEPIA_VIDEOS), "").getUrl());
|
||||
assertEquals("https://anotherpeertubeindex.com/api/v1/search/videos?search=%3Fj%24%29H%C2%A7B", PeerTube.getSearchQHFactory().fromQuery("?j$)H§B", singletonList(PeertubeSearchQueryHandlerFactory.SEPIA_VIDEOS), "", "https://anotherpeertubeindex.com").getUrl());
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudChartsLinkHandlerFactory;
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||
@@ -41,6 +42,7 @@ public class SoundcloudPlaylistExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testName() {
|
||||
assertEquals("THE PERFECT LUV TAPE®️", extractor.getName());
|
||||
}
|
||||
@@ -361,6 +363,7 @@ public class SoundcloudPlaylistExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
try {
|
||||
defaultTestMoreItems(extractor);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
@@ -55,6 +53,7 @@ public class SoundcloudStreamExtractorTest {
|
||||
@Override public boolean expectedHasVideoStreams() { return false; }
|
||||
@Override public boolean expectedHasSubtitles() { return false; }
|
||||
@Override public boolean expectedHasFrames() { return false; }
|
||||
@Override public int expectedStreamSegmentsCount() { return 0; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudStreamLinkHandlerFactory;
|
||||
@@ -25,6 +26,7 @@ public class SoundcloudStreamLinkHandlerFactoryTest {
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Ignore("TODO fix")
|
||||
public void getIdWithNullAsUrl() throws ParsingException {
|
||||
linkHandler.fromUrl(null).getId();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.ServiceList;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud.search;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
@@ -113,6 +114,7 @@ public class SoundcloudSearchExtractorTest {
|
||||
|
||||
public static class PagingTest {
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void duplicatedItemsCheck() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
final SearchExtractor extractor = SoundCloud.getSearchExtractor("cirque du soleil", singletonList(TRACKS), "");
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud.search;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
@@ -23,6 +24,7 @@ public class SoundcloudSearchQHTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testRegularValues() throws Exception {
|
||||
assertEquals("https://api-v2.soundcloud.com/search?q=asdf&limit=10&offset=0",
|
||||
removeClientId(SoundCloud.getSearchQHFactory().fromQuery("asdf").getUrl()));
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeCommentsLinkHandlerFactory;
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
@@ -119,6 +117,7 @@ public class YoutubeChannelExtractorTest {
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testDescription() throws Exception {
|
||||
assertTrue(extractor.getDescription().contains("Zart im Schmelz und süffig im Abgang. Ungebremster Spieltrieb"));
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.Page;
|
||||
@@ -16,10 +16,7 @@ import org.schabi.newpipe.extractor.utils.Utils;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
public class YoutubeCommentsExtractorTest {
|
||||
@@ -28,9 +25,8 @@ public class YoutubeCommentsExtractorTest {
|
||||
*/
|
||||
public static class Thomas {
|
||||
private static final String url = "https://www.youtube.com/watch?v=D00Au7k3i6o";
|
||||
private static YoutubeCommentsExtractor extractor;
|
||||
|
||||
private static final String commentContent = "Category: Education";
|
||||
private static YoutubeCommentsExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
@@ -116,8 +112,8 @@ public class YoutubeCommentsExtractorTest {
|
||||
* Test a video with an empty comment
|
||||
*/
|
||||
public static class EmptyComment {
|
||||
private static YoutubeCommentsExtractor extractor;
|
||||
private final static String url = "https://www.youtube.com/watch?v=VM_6n762j6M";
|
||||
private static YoutubeCommentsExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
@@ -152,4 +148,45 @@ public class YoutubeCommentsExtractorTest {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class HeartedByCreator {
|
||||
private final static String url = "https://www.youtube.com/watch?v=tR11b7uh17Y";
|
||||
private static YoutubeCommentsExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeCommentsExtractor) YouTube
|
||||
.getCommentsExtractor(url);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCommentsAllData() throws IOException, ExtractionException {
|
||||
final InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage();
|
||||
|
||||
DefaultTests.defaultTestListOfItems(YouTube, comments.getItems(), comments.getErrors());
|
||||
|
||||
boolean heartedByUploader = false;
|
||||
|
||||
for (CommentsInfoItem c : comments.getItems()) {
|
||||
assertFalse(Utils.isBlank(c.getUploaderUrl()));
|
||||
assertFalse(Utils.isBlank(c.getUploaderName()));
|
||||
assertFalse(Utils.isBlank(c.getUploaderAvatarUrl()));
|
||||
assertFalse(Utils.isBlank(c.getCommentId()));
|
||||
assertFalse(Utils.isBlank(c.getName()));
|
||||
assertFalse(Utils.isBlank(c.getTextualUploadDate()));
|
||||
assertNotNull(c.getUploadDate());
|
||||
assertFalse(Utils.isBlank(c.getThumbnailUrl()));
|
||||
assertFalse(Utils.isBlank(c.getUrl()));
|
||||
assertFalse(c.getLikeCount() < 0);
|
||||
assertFalse(Utils.isBlank(c.getCommentText()));
|
||||
if (c.getHeartedByUploader()) {
|
||||
heartedByUploader = true;
|
||||
}
|
||||
}
|
||||
assertTrue("No comments was hearted by uploader", heartedByUploader);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -10,7 +12,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderFactory;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
@@ -41,6 +43,7 @@ public class YoutubeMixPlaylistExtractorTest {
|
||||
private static final String VIDEO_ID = "_AzeUSL9lZc";
|
||||
private static final String VIDEO_TITLE =
|
||||
"Most Beautiful And Emotional Piano: Anime Music Shigatsu wa Kimi no Uso OST IMO";
|
||||
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/mix/";
|
||||
private static final Map<String, String> dummyCookie
|
||||
= Collections.singletonMap(YoutubeMixPlaylistExtractor.COOKIE_NAME, "whatever");
|
||||
|
||||
@@ -50,7 +53,8 @@ public class YoutubeMixPlaylistExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "mix"));
|
||||
extractor = (YoutubeMixPlaylistExtractor) YouTube
|
||||
.getPlaylistExtractor(
|
||||
"https://www.youtube.com/watch?v=" + VIDEO_ID + "&list=RD" + VIDEO_ID);
|
||||
@@ -127,7 +131,8 @@ public class YoutubeMixPlaylistExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "mixWithIndex"));
|
||||
extractor = (YoutubeMixPlaylistExtractor) YouTube
|
||||
.getPlaylistExtractor(
|
||||
"https://www.youtube.com/watch?v=" + VIDEO_ID_NUMBER_13 + "&list=RD"
|
||||
@@ -196,7 +201,8 @@ public class YoutubeMixPlaylistExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "myMix"));
|
||||
extractor = (YoutubeMixPlaylistExtractor) YouTube
|
||||
.getPlaylistExtractor(
|
||||
"https://www.youtube.com/watch?v=" + VIDEO_ID + "&list=RDMM"
|
||||
@@ -267,8 +273,9 @@ public class YoutubeMixPlaylistExtractorTest {
|
||||
public static class Invalid {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
public static void setUp() throws IOException {
|
||||
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "invalid"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -299,7 +306,8 @@ public class YoutubeMixPlaylistExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
YoutubeParsingHelper.resetClientVersionAndKey();
|
||||
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "channelMix"));
|
||||
extractor = (YoutubeMixPlaylistExtractor) YouTube
|
||||
.getPlaylistExtractor(
|
||||
"https://www.youtube.com/watch?v=" + VIDEO_ID_OF_CHANNEL
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
@@ -36,4 +36,12 @@ public class YoutubeParsingHelperTest {
|
||||
assertEquals(4445767, YoutubeParsingHelper.parseDurationString("1,234:56:07"));
|
||||
assertEquals(754, YoutubeParsingHelper.parseDurationString("12:34 "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertFromGoogleCacheUrl() throws ParsingException {
|
||||
assertEquals("https://mohfw.gov.in/",
|
||||
YoutubeParsingHelper.extractCachedUrlIfNeeded("https://webcache.googleusercontent.com/search?q=cache:https://mohfw.gov.in/"));
|
||||
assertEquals("https://www.infektionsschutz.de/coronavirus-sars-cov-2.html",
|
||||
YoutubeParsingHelper.extractCachedUrlIfNeeded("https://www.infektionsschutz.de/coronavirus-sars-cov-2.html"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
|
||||
@@ -52,6 +52,7 @@ public class YoutubePlaylistExtractorTest {
|
||||
}
|
||||
|
||||
@Test(expected = ContentNotAvailableException.class)
|
||||
@Ignore("TODO fix")
|
||||
public void invalidId() throws Exception {
|
||||
final PlaylistExtractor extractor =
|
||||
YouTube.getPlaylistExtractor("https://www.youtube.com/playlist?list=INVALID_ID");
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubePlaylistLinkHandlerFactory;
|
||||
|
||||
@@ -22,7 +22,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskList;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.ServiceList;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||
|
||||
@@ -22,7 +22,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.localization.Localization;
|
||||
|
||||
@@ -22,7 +22,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
|
||||
|
||||
@@ -22,7 +22,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube.search;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
@@ -10,9 +10,8 @@ import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.DefaultSearchExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube.search;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
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.StreamingService;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.*;
|
||||
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||
import org.schabi.newpipe.extractor.services.DefaultSearchExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.youtube.YoutubeService;
|
||||
import org.schabi.newpipe.extractor.stream.Description;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -211,4 +218,41 @@ public class YoutubeSearchExtractorTest {
|
||||
assertNoDuplicatedItems(YouTube, page1, page2);
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("TODO fix")
|
||||
public static class MetaInfoTest extends DefaultSearchExtractorTest {
|
||||
private static SearchExtractor extractor;
|
||||
private static final String QUERY = "Covid";
|
||||
|
||||
@Test
|
||||
public void clarificationTest() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = YouTube.getSearchExtractor(QUERY, singletonList(VIDEOS), "");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Override public String expectedSearchString() { return QUERY; }
|
||||
@Override public String expectedSearchSuggestion() { return null; }
|
||||
@Override public List<MetaInfo> expectedMetaInfo() throws MalformedURLException {
|
||||
final List<URL> urls = new ArrayList<>();
|
||||
urls.add(new URL("https://www.who.int/emergencies/diseases/novel-coronavirus-2019"));
|
||||
urls.add(new URL("https://www.who.int/emergencies/diseases/novel-coronavirus-2019/covid-19-vaccines"));
|
||||
final List<String> urlTexts = new ArrayList<>();
|
||||
urlTexts.add("LEARN MORE");
|
||||
urlTexts.add("Learn about vaccine progress from the WHO");
|
||||
return Collections.singletonList(new MetaInfo(
|
||||
"COVID-19",
|
||||
new Description("Get the latest information from the WHO about coronavirus.", Description.PLAIN_TEXT),
|
||||
urls,
|
||||
urlTexts
|
||||
));
|
||||
}
|
||||
@Override public SearchExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return YouTube; }
|
||||
@Override public String expectedName() { return QUERY; }
|
||||
@Override public String expectedId() { return QUERY; }
|
||||
@Override public String expectedUrlContains() { return "youtube.com/results?search_query=" + QUERY; }
|
||||
@Override public String expectedOriginalUrlContains() throws Exception { return "youtube.com/results?search_query=" + QUERY; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube.search;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
@@ -10,6 +11,7 @@ import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeS
|
||||
public class YoutubeSearchQHTest {
|
||||
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testRegularValues() throws Exception {
|
||||
assertEquals("https://www.youtube.com/results?search_query=asdf", YouTube.getSearchQHFactory().fromQuery("asdf").getUrl());
|
||||
assertEquals("https://www.youtube.com/results?search_query=hans", YouTube.getSearchQHFactory().fromQuery("hans").getUrl());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube.stream;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube.stream;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
@@ -51,4 +53,11 @@ public class YoutubeStreamExtractorControversialTest extends DefaultStreamExtrac
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2010-09-09"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return 13300; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return 2600; }
|
||||
|
||||
@Override
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testErrorMessage() throws Exception {
|
||||
super.testErrorMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,30 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube.stream;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.MetaInfo;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
import org.schabi.newpipe.extractor.stream.Description;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamSegment;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
/*
|
||||
@@ -96,8 +104,10 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2019-08-24"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return 5212900; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return 30600; }
|
||||
@Override public int expectedStreamSegmentsCount() { return 0; }
|
||||
}
|
||||
|
||||
@Ignore("TODO fix")
|
||||
public static class DescriptionTestUnboxing extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "cV5TjZCJkuA";
|
||||
private static final String URL = BASE_URL + ID;
|
||||
@@ -134,6 +144,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||
@Override public long expectedDislikeCountAtLeast() { return 18700; }
|
||||
}
|
||||
|
||||
@Ignore("TODO fix")
|
||||
public static class RatingsDisabledTest extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "HRKu0cvrr_o";
|
||||
private static final int TIMESTAMP = 17;
|
||||
@@ -166,4 +177,138 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||
@Override public long expectedLikeCountAtLeast() { return -1; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return -1; }
|
||||
}
|
||||
|
||||
public static class StreamSegmentsTestOstCollection extends DefaultStreamExtractorTest {
|
||||
// StreamSegment example with single macro-makers panel
|
||||
private static final String ID = "2RYrHwnLHw0";
|
||||
private static final String URL = BASE_URL + ID;
|
||||
private static StreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = YouTube.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return YouTube; }
|
||||
@Override public String expectedName() { return "1 Hour - Most Epic Anime Mix - Battle Anime OST"; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return BASE_URL + ID; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "MathCaires"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UChFoHg6IT18SCqiwCp_KY7Q"; }
|
||||
@Override public List<String> expectedDescriptionContains() {
|
||||
return Arrays.asList("soundtracks", "9:49", "YouSeeBIGGIRLTT");
|
||||
}
|
||||
@Override public long expectedLength() { return 3889; }
|
||||
@Override public long expectedViewCountAtLeast() { return 2463261; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2019-06-26 00:00:00.000"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2019-06-26"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return 32100; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return 750; }
|
||||
@Override public boolean expectedHasSubtitles() { return false; }
|
||||
|
||||
@Override public int expectedStreamSegmentsCount() { return 17; }
|
||||
@Test
|
||||
public void testStreamSegment() throws Exception {
|
||||
final StreamSegment segment = extractor.getStreamSegments().get(3);
|
||||
assertEquals(589, segment.getStartTimeSeconds());
|
||||
assertEquals("Attack on Titan S2 - YouSeeBIGGIRLTT", segment.getTitle());
|
||||
assertEquals(BASE_URL + ID + "?t=589", segment.getUrl());
|
||||
assertNotNull(segment.getPreviewUrl());
|
||||
}
|
||||
}
|
||||
|
||||
public static class StreamSegmentsTestMaiLab extends DefaultStreamExtractorTest {
|
||||
// StreamSegment example with macro-makers panel and transcription panel
|
||||
private static final String ID = "ud9d5cMDP_0";
|
||||
private static final String URL = BASE_URL + ID;
|
||||
private static StreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = YouTube.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return YouTube; }
|
||||
@Override public String expectedName() { return "Vitamin D wissenschaftlich gepr\u00fcft"; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return BASE_URL + ID; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "maiLab"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCyHDQ5C6z1NDmJ4g6SerW8g"; }
|
||||
@Override public List<String> expectedDescriptionContains() {
|
||||
return Arrays.asList("Vitamin", "2:44", "Was ist Vitamin D?");
|
||||
}
|
||||
@Override public long expectedLength() { return 1010; }
|
||||
@Override public long expectedViewCountAtLeast() { return 815500; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2020-11-18 00:00:00.000"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2020-11-18"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return 48500; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return 20000; }
|
||||
@Override public boolean expectedHasSubtitles() { return true; }
|
||||
|
||||
@Override public int expectedStreamSegmentsCount() { return 7; }
|
||||
@Test
|
||||
@Ignore("TODO fix")
|
||||
public void testStreamSegment() throws Exception {
|
||||
final StreamSegment segment = extractor.getStreamSegments().get(1);
|
||||
assertEquals(164, segment.getStartTimeSeconds());
|
||||
assertEquals("Was ist Vitamin D?", segment.getTitle());
|
||||
assertEquals(BASE_URL + ID + "?t=164", segment.getUrl());
|
||||
assertNotNull(segment.getPreviewUrl());
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("TODO fix")
|
||||
public static class PublicBroadcasterTest extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "q6fgbYWsMgw";
|
||||
private static final int TIMESTAMP = 0;
|
||||
private static final String URL = BASE_URL + ID;
|
||||
private static StreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = YouTube.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return YouTube; }
|
||||
@Override public String expectedName() { return "Was verbirgt sich am tiefsten Punkt des Ozeans?"; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return BASE_URL + ID; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "Dinge Erklärt – Kurzgesagt"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCwRH985XgMYXQ6NxXDo8npw"; }
|
||||
@Override public List<String> expectedDescriptionContains() { return Arrays.asList("Lasst uns abtauchen!", "Angebot von funk", "Dinge"); }
|
||||
@Override public long expectedLength() { return 631; }
|
||||
@Override public long expectedTimestamp() { return TIMESTAMP; }
|
||||
@Override public long expectedViewCountAtLeast() { return 1_600_000; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2019-06-12 00:00:00.000"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2019-06-12"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return 70000; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return 500; }
|
||||
@Override public List<MetaInfo> expectedMetaInfo() throws MalformedURLException {
|
||||
return Collections.singletonList(new MetaInfo(
|
||||
"",
|
||||
new Description("Funk is a German public broadcast service.", Description.PLAIN_TEXT),
|
||||
Collections.singletonList(new URL("https://de.wikipedia.org/wiki/Funk_(Medienangebot)?wprov=yicw1")),
|
||||
Collections.singletonList("Wikipedia (German)")
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube.stream;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube.stream;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"request": {
|
||||
"httpMethod": "GET",
|
||||
"url": "https://www.youtube.com/watch?v\u003dabcde\u0026list\u003dRDabcde\u0026pbj\u003d1",
|
||||
"headers": {
|
||||
"Accept-Language": [
|
||||
"en-GB, en;q\u003d0.9"
|
||||
],
|
||||
"X-YouTube-Client-Name": [
|
||||
"1"
|
||||
],
|
||||
"X-YouTube-Client-Version": [
|
||||
"2.20200214.04.00"
|
||||
]
|
||||
},
|
||||
"localization": {
|
||||
"languageCode": "en",
|
||||
"countryCode": "GB"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"responseCode": 200,
|
||||
"responseMessage": "",
|
||||
"responseHeaders": {
|
||||
"alt-svc": [
|
||||
"h3-29\u003d\":443\"; ma\u003d2592000,h3-T051\u003d\":443\"; ma\u003d2592000,h3-Q050\u003d\":443\"; ma\u003d2592000,h3-Q046\u003d\":443\"; ma\u003d2592000,h3-Q043\u003d\":443\"; ma\u003d2592000,quic\u003d\":443\"; ma\u003d2592000; v\u003d\"46,43\""
|
||||
],
|
||||
"cache-control": [
|
||||
"no-cache, no-store, max-age\u003d0, must-revalidate"
|
||||
],
|
||||
"content-disposition": [
|
||||
"attachment"
|
||||
],
|
||||
"content-type": [
|
||||
"application/json; charset\u003dutf-8"
|
||||
],
|
||||
"date": [
|
||||
"Fri, 15 Jan 2021 08:49:37 GMT"
|
||||
],
|
||||
"expires": [
|
||||
"Mon, 01 Jan 1990 00:00:00 GMT"
|
||||
],
|
||||
"p3p": [
|
||||
"CP\u003d\"This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl\u003den-GB for more info.\""
|
||||
],
|
||||
"pragma": [
|
||||
"no-cache"
|
||||
],
|
||||
"server": [
|
||||
"ESF"
|
||||
],
|
||||
"set-cookie": [
|
||||
"GPS\u003d1; Domain\u003d.youtube.com; Expires\u003dFri, 15-Jan-2021 09:19:37 GMT; Path\u003d/; Secure; HttpOnly",
|
||||
"YSC\u003dfJuL0ZusLzo; Domain\u003d.youtube.com; Path\u003d/; Secure; HttpOnly; SameSite\u003dnone",
|
||||
"VISITOR_INFO1_LIVE\u003du4AIon0YCwY; Domain\u003d.youtube.com; Expires\u003dWed, 14-Jul-2021 08:49:37 GMT; Path\u003d/; Secure; HttpOnly; SameSite\u003dnone",
|
||||
"CONSENT\u003dWP.28f654; expires\u003dFri, 01-Jan-2038 00:00:00 GMT; path\u003d/; domain\u003d.youtube.com"
|
||||
],
|
||||
"strict-transport-security": [
|
||||
"max-age\u003d31536000"
|
||||
],
|
||||
"x-content-type-options": [
|
||||
"nosniff"
|
||||
],
|
||||
"x-frame-options": [
|
||||
"SAMEORIGIN"
|
||||
],
|
||||
"x-spf-response-type": [
|
||||
"multipart"
|
||||
],
|
||||
"x-xss-protection": [
|
||||
"0"
|
||||
]
|
||||
},
|
||||
"responseBody": "[\r\n{\"page\": \"watch\",\"rootVe\": \"3832\"},\r\n{\"page\": \"watch\",\"preconnect\": [\"https:\\/\\/r4---sn-h0jeenek.googlevideo.com\\/generate_204\",\"https:\\/\\/r4---sn-h0jeenek.googlevideo.com\\/generate_204?conn2\"]},\r\n{\"page\": \"watch\",\"playerResponse\": {\"responseContext\":{\"serviceTrackingParams\":[{\"service\":\"GFEEDBACK\",\"params\":[{\"key\":\"is_viewed_live\",\"value\":\"False\"},{\"key\":\"logged_in\",\"value\":\"0\"},{\"key\":\"e\",\"value\":\"23955615,23882685,23969934,23891344,23839597,23948841,23932523,23976578,23970529,23969486,23804281,23942633,23972994,23884386,23950597,23890959,23911055,23903329,23744176,23951620,23974595,23986077,23961732,23944779,1714242,23981908,23858057,23991912,23968386,23986030,23987935,23969485,23968363,23966110,23946420,23918597,23876171,23973488,23940248,23981965,23934970,23987363\"}]},{\"service\":\"CSI\",\"params\":[{\"key\":\"c\",\"value\":\"WEB\"},{\"key\":\"cver\",\"value\":\"2.20200214.04.00\"},{\"key\":\"yt_li\",\"value\":\"0\"},{\"key\":\"GetPlayer_rid\",\"value\":\"0x313c07ac79033ade\"}]},{\"service\":\"GUIDED_HELP\",\"params\":[{\"key\":\"logged_in\",\"value\":\"0\"}]},{\"service\":\"ECATCHER\",\"params\":[{\"key\":\"client.version\",\"value\":\"2.20201112\"},{\"key\":\"client.name\",\"value\":\"WEB\"}]}],\"webResponseContextExtensionData\":{\"hasDecorated\":true}},\"playabilityStatus\":{\"status\":\"ERROR\",\"reason\":\"Video unavailable\",\"errorScreen\":{\"playerErrorMessageRenderer\":{\"reason\":{\"simpleText\":\"Video unavailable\"},\"thumbnail\":{\"thumbnails\":[{\"url\":\"//s.ytimg.com/yts/img/meh7-vflGevej7.png\",\"width\":140,\"height\":100}]},\"icon\":{\"iconType\":\"ERROR_OUTLINE\"}}},\"contextParams\":\"Q0FBU0FnZ0E\u003d\"},\"trackingParams\":\"CAAQu2kiEwj16qaex53uAhWYBuAKHY4_AKM\u003d\"}},\r\n{\"page\": \"watch\",\"response\": {\"responseContext\":{\"webResponseContextExtensionData\":{\"ytConfigData\":{\"visitorData\":\"Cgt1NEFJb24wWUN3WSihroWABg%3D%3D\",\"rootVisualElementType\":3832}}}},\"xsrf_token\": \"QUFFLUhqbkRYUkZKam81N052NV9hT0NVOEF5c2htMFJPZ3xBQ3Jtc0trQ2ZUdFNGV2FuZzhKb3hrdU5HcFI1dmEyU2g3N193dk9xRmpmcUluY3p5U25xblRheEJyOFRLeERqaUppRkY2TXdGUnNQcFpkVDNBTElOYlZ4WDJYVVk5R05rU0xzN0NfaHJQVGkxODRMNTI5RFNxdw\\u003d\\u003d\",\"url\": \"/watch?v\\u003dabcde\\u0026list\\u003dRDabcde\",\"endpoint\": {\"clickTrackingParams\":\"IhMIzuSlnsed7gIVxyjgCh1VGgEfMghleHRlcm5hbA\u003d\u003d\",\"commandMetadata\":{\"webCommandMetadata\":{\"url\":\"/watch?v\u003dabcde\",\"webPageType\":\"WEB_PAGE_TYPE_WATCH\",\"rootVe\":3832}},\"watchEndpoint\":{\"videoId\":\"abcde\"}}},\r\n{\"page\": \"watch\",\"timing\": {\"info\": {\"st\": 0.0 }}}]\r\n",
|
||||
"latestUrl": "https://www.youtube.com/watch?v\u003dabcde\u0026list\u003dRDabcde\u0026pbj\u003d1"
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user