Merge TNP/dev into fynngodau/dev
This commit is contained in:
94
extractor/src/test/java/org/schabi/newpipe/FileUtils.java
Normal file
94
extractor/src/test/java/org/schabi/newpipe/FileUtils.java
Normal file
@@ -0,0 +1,94 @@
|
||||
package org.schabi.newpipe;
|
||||
|
||||
import com.grack.nanojson.JsonArray;
|
||||
import com.grack.nanojson.JsonObject;
|
||||
import com.grack.nanojson.JsonWriter;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* Util class to write file to disk
|
||||
* <p>
|
||||
* Can be used to debug and test, for example writing a service's JSON response
|
||||
* (especially useful if the response provided by the service is not documented)
|
||||
*/
|
||||
public class FileUtils {
|
||||
|
||||
public static void createFile(String path, JsonObject content) throws IOException {
|
||||
createFile(path, jsonObjToString(content));
|
||||
}
|
||||
|
||||
public static void createFile(String path, JsonArray array) throws IOException {
|
||||
createFile(path, jsonArrayToString(array));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file given a path and its content. Create subdirectories if needed
|
||||
*
|
||||
* @param path the path to write the file, including the filename (and its extension)
|
||||
* @param content the content to write
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void createFile(final String path, final String content) throws IOException {
|
||||
final String[] dirs = path.split("/");
|
||||
if (dirs.length > 1) {
|
||||
String pathWithoutFileName = path.replace(dirs[dirs.length - 1], "");
|
||||
if (!Files.exists(Paths.get(pathWithoutFileName))) { //create dirs if they don't exist
|
||||
if (!new File(pathWithoutFileName).mkdirs()) {
|
||||
throw new IOException("An error occurred while creating directories");
|
||||
}
|
||||
}
|
||||
}
|
||||
writeFile(path, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a file to disk
|
||||
*
|
||||
* @param filename the file name (and its extension if wanted)
|
||||
* @param content the content to write
|
||||
* @throws IOException
|
||||
*/
|
||||
private static void writeFile(final String filename, final String content) throws IOException {
|
||||
final BufferedWriter writer = new BufferedWriter(new FileWriter(filename));
|
||||
writer.write(content);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the test resource file based on its filename. Looks in
|
||||
* {@code extractor/src/test/resources/} and {@code src/test/resources/}
|
||||
* @param filename the resource filename
|
||||
* @return the resource file
|
||||
*/
|
||||
public static File resolveTestResource(final String filename) {
|
||||
final File file = new File("extractor/src/test/resources/" + filename);
|
||||
if (file.exists()) {
|
||||
return file;
|
||||
} else {
|
||||
return new File("src/test/resources/" + filename);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a JSON object to String
|
||||
* toString() does not produce a valid JSON string
|
||||
*/
|
||||
public static String jsonObjToString(JsonObject object) {
|
||||
return JsonWriter.string(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a JSON array to String
|
||||
* toString() does not produce a valid JSON string
|
||||
*/
|
||||
public static String jsonArrayToString(JsonArray array) {
|
||||
return JsonWriter.string(array);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,19 @@
|
||||
package org.schabi.newpipe.extractor;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ExtractorAsserts {
|
||||
public static void assertEmptyErrors(String message, List<Throwable> errors) {
|
||||
@@ -56,4 +63,22 @@ public class ExtractorAsserts {
|
||||
assertTrue(message, stringToCheck.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertAtLeast(long expected, long actual) {
|
||||
assertTrue(actual + " is not at least " + expected, actual >= expected);
|
||||
}
|
||||
|
||||
// this assumes that sorting a and b in-place is not an issue, so it's only intended for tests
|
||||
public static void assertEqualsOrderIndependent(List<String> expected, List<String> actual) {
|
||||
if (expected == null) {
|
||||
assertNull(actual);
|
||||
return;
|
||||
} else {
|
||||
assertNotNull(actual);
|
||||
}
|
||||
|
||||
Collections.sort(expected);
|
||||
Collections.sort(actual);
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.HashSet;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.NewPipe.getServiceByUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
public class NewPipeTest {
|
||||
@@ -39,8 +40,10 @@ public class NewPipeTest {
|
||||
assertEquals(getServiceByUrl("https://www.youtube.com/watch?v=_r6CgaFNAGg"), YouTube);
|
||||
assertEquals(getServiceByUrl("https://www.youtube.com/channel/UCi2bIyFtz-JdI-ou8kaqsqg"), YouTube);
|
||||
assertEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), YouTube);
|
||||
assertEquals(getServiceByUrl("https://www.google.it/url?sa=t&rct=j&q=&esrc=s&cd=&cad=rja&uact=8&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DHu80uDzh8RY&source=video"), YouTube);
|
||||
|
||||
assertNotEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), YouTube);
|
||||
assertEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), SoundCloud);
|
||||
assertEquals(getServiceByUrl("https://www.google.com/url?sa=t&url=https%3A%2F%2Fsoundcloud.com%2Fciaoproduction&rct=j&q=&esrc=s&source=web&cd="), SoundCloud);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.schabi.newpipe.extractor.services;
|
||||
|
||||
public interface BaseStreamExtractorTest extends BaseExtractorTest {
|
||||
void testStreamType() throws Exception;
|
||||
void testUploaderName() throws Exception;
|
||||
void testUploaderUrl() throws Exception;
|
||||
void testUploaderAvatarUrl() throws Exception;
|
||||
void testSubChannelName() throws Exception;
|
||||
void testSubChannelUrl() throws Exception;
|
||||
void testSubChannelAvatarUrl() throws Exception;
|
||||
void testThumbnailUrl() throws Exception;
|
||||
void testDescription() throws Exception;
|
||||
void testLength() throws Exception;
|
||||
void testTimestamp() throws Exception;
|
||||
void testViewCount() throws Exception;
|
||||
void testUploadDate() throws Exception;
|
||||
void testTextualUploadDate() throws Exception;
|
||||
void testLikeCount() throws Exception;
|
||||
void testDislikeCount() throws Exception;
|
||||
void testRelatedStreams() throws Exception;
|
||||
void testAgeLimit() throws Exception;
|
||||
void testErrorMessage() throws Exception;
|
||||
void testAudioStreams() throws Exception;
|
||||
void testVideoStreams() throws Exception;
|
||||
void testSubtitles() throws Exception;
|
||||
void testGetDashMpdUrl() throws Exception;
|
||||
void testFrames() throws Exception;
|
||||
void testHost() throws Exception;
|
||||
void testPrivacy() throws Exception;
|
||||
void testCategory() throws Exception;
|
||||
void testLicence() throws Exception;
|
||||
void testLanguageInfo() throws Exception;
|
||||
void testTags() throws Exception;
|
||||
void testSupportInfo() throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,382 @@
|
||||
package org.schabi.newpipe.extractor.services;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.extractor.MediaFormat;
|
||||
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||
import org.schabi.newpipe.extractor.stream.Description;
|
||||
import org.schabi.newpipe.extractor.stream.Frameset;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
import org.schabi.newpipe.extractor.stream.SubtitlesStream;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertAtLeast;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEqualsOrderIndependent;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestListOfItems;
|
||||
|
||||
/**
|
||||
* Test for {@link StreamExtractor}
|
||||
*/
|
||||
public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<StreamExtractor>
|
||||
implements BaseStreamExtractorTest {
|
||||
|
||||
public abstract StreamType expectedStreamType();
|
||||
public abstract String expectedUploaderName();
|
||||
public abstract String expectedUploaderUrl();
|
||||
public String expectedSubChannelName() { return ""; } // default: there is no subchannel
|
||||
public String expectedSubChannelUrl() { return ""; } // default: there is no subchannel
|
||||
public abstract List<String> expectedDescriptionContains(); // e.g. for full links
|
||||
public abstract long expectedLength();
|
||||
public long expectedTimestamp() { return 0; } // default: there is no timestamp
|
||||
public abstract long expectedViewCountAtLeast();
|
||||
@Nullable public abstract String expectedUploadDate(); // format: "yyyy-MM-dd HH:mm:ss.SSS"
|
||||
@Nullable public abstract String expectedTextualUploadDate();
|
||||
public abstract long expectedLikeCountAtLeast(); // return -1 if ratings are disabled
|
||||
public abstract long expectedDislikeCountAtLeast(); // return -1 if ratings are disabled
|
||||
public boolean expectedHasRelatedStreams() { return true; } // default: there are related videos
|
||||
public int expectedAgeLimit() { return StreamExtractor.NO_AGE_LIMIT; } // default: no limit
|
||||
@Nullable public String expectedErrorMessage() { return null; } // default: no error message
|
||||
public boolean expectedHasVideoStreams() { return true; } // default: there are video streams
|
||||
public boolean expectedHasAudioStreams() { return true; } // default: there are audio streams
|
||||
public boolean expectedHasSubtitles() { return true; } // default: there are subtitles streams
|
||||
@Nullable public String expectedDashMpdUrlContains() { return null; } // default: no dash mpd
|
||||
public boolean expectedHasFrames() { return true; } // default: there are frames
|
||||
public String expectedHost() { return ""; } // default: no host for centralized platforms
|
||||
public String expectedPrivacy() { return ""; } // default: no privacy policy available
|
||||
public String expectedCategory() { return ""; } // default: no category
|
||||
public String expectedLicence() { return ""; } // default: no licence
|
||||
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
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testStreamType() throws Exception {
|
||||
assertEquals(expectedStreamType(), extractor().getStreamType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUploaderName() throws Exception {
|
||||
assertEquals(expectedUploaderName(), extractor().getUploaderName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUploaderUrl() throws Exception {
|
||||
final String uploaderUrl = extractor().getUploaderUrl();
|
||||
assertIsSecureUrl(uploaderUrl);
|
||||
assertEquals(expectedUploaderUrl(), uploaderUrl);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUploaderAvatarUrl() throws Exception {
|
||||
assertIsSecureUrl(extractor().getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSubChannelName() throws Exception {
|
||||
assertEquals(expectedSubChannelName(), extractor().getSubChannelName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSubChannelUrl() throws Exception {
|
||||
final String subChannelUrl = extractor().getSubChannelUrl();
|
||||
assertEquals(expectedSubChannelUrl(), subChannelUrl);
|
||||
|
||||
if (!expectedSubChannelUrl().isEmpty()) {
|
||||
// this stream has a subchannel
|
||||
assertIsSecureUrl(subChannelUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSubChannelAvatarUrl() throws Exception {
|
||||
if (expectedSubChannelName().isEmpty() && expectedSubChannelUrl().isEmpty()) {
|
||||
// this stream has no subchannel
|
||||
assertEquals("", extractor().getSubChannelAvatarUrl());
|
||||
} else {
|
||||
// this stream has a subchannel
|
||||
assertIsSecureUrl(extractor().getSubChannelAvatarUrl());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testThumbnailUrl() throws Exception {
|
||||
assertIsSecureUrl(extractor().getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testDescription() throws Exception {
|
||||
final Description description = extractor().getDescription();
|
||||
assertNotNull(description);
|
||||
assertFalse("description is empty", description.getContent().isEmpty());
|
||||
|
||||
for (final String s : expectedDescriptionContains()) {
|
||||
assertThat(description.getContent(), containsString(s));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testLength() throws Exception {
|
||||
assertEquals(expectedLength(), extractor().getLength());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testTimestamp() throws Exception {
|
||||
assertEquals(expectedTimestamp(), extractor().getTimeStamp());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testViewCount() throws Exception {
|
||||
assertAtLeast(expectedViewCountAtLeast(), extractor().getViewCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testUploadDate() throws Exception {
|
||||
final DateWrapper dateWrapper = extractor().getUploadDate();
|
||||
|
||||
if (expectedUploadDate() == null) {
|
||||
assertNull(dateWrapper);
|
||||
} else {
|
||||
assertNotNull(dateWrapper);
|
||||
|
||||
final LocalDateTime expectedDateTime = LocalDateTime.parse(expectedUploadDate(),
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
||||
final LocalDateTime actualDateTime = dateWrapper.offsetDateTime().toLocalDateTime();
|
||||
|
||||
assertEquals(expectedDateTime, actualDateTime);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testTextualUploadDate() throws Exception {
|
||||
assertEquals(expectedTextualUploadDate(), extractor().getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testLikeCount() throws Exception {
|
||||
if (expectedLikeCountAtLeast() == -1) {
|
||||
assertEquals(-1, extractor().getLikeCount());
|
||||
} else {
|
||||
assertAtLeast(expectedLikeCountAtLeast(), extractor().getLikeCount());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testDislikeCount() throws Exception {
|
||||
if (expectedDislikeCountAtLeast() == -1) {
|
||||
assertEquals(-1, extractor().getDislikeCount());
|
||||
} else {
|
||||
assertAtLeast(expectedDislikeCountAtLeast(), extractor().getDislikeCount());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testRelatedStreams() throws Exception {
|
||||
final StreamInfoItemsCollector relatedStreams = extractor().getRelatedStreams();
|
||||
|
||||
if (expectedHasRelatedStreams()) {
|
||||
assertNotNull(relatedStreams);
|
||||
defaultTestListOfItems(extractor().getService(), relatedStreams.getItems(),
|
||||
relatedStreams.getErrors());
|
||||
} else {
|
||||
assertNull(relatedStreams);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testAgeLimit() throws Exception {
|
||||
assertEquals(expectedAgeLimit(), extractor().getAgeLimit());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testErrorMessage() throws Exception {
|
||||
assertEquals(expectedErrorMessage(), extractor().getErrorMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testVideoStreams() throws Exception {
|
||||
final List<VideoStream> videoStreams = extractor().getVideoStreams();
|
||||
final List<VideoStream> videoOnlyStreams = extractor().getVideoOnlyStreams();
|
||||
assertNotNull(videoStreams);
|
||||
assertNotNull(videoOnlyStreams);
|
||||
videoStreams.addAll(videoOnlyStreams);
|
||||
|
||||
if (expectedHasVideoStreams()) {
|
||||
assertFalse(videoStreams.isEmpty());
|
||||
|
||||
for (final VideoStream stream : videoStreams) {
|
||||
assertIsSecureUrl(stream.getUrl());
|
||||
assertFalse(stream.getResolution().isEmpty());
|
||||
|
||||
final int formatId = stream.getFormatId();
|
||||
// see MediaFormat: video stream formats range from 0 to 0x100
|
||||
assertTrue("format id does not fit a video stream: " + formatId,
|
||||
0 <= formatId && formatId < 0x100);
|
||||
}
|
||||
} else {
|
||||
assertTrue(videoStreams.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testAudioStreams() throws Exception {
|
||||
final List<AudioStream> audioStreams = extractor().getAudioStreams();
|
||||
assertNotNull(audioStreams);
|
||||
|
||||
if (expectedHasAudioStreams()) {
|
||||
assertFalse(audioStreams.isEmpty());
|
||||
|
||||
for (final AudioStream stream : audioStreams) {
|
||||
assertIsSecureUrl(stream.getUrl());
|
||||
|
||||
final int formatId = stream.getFormatId();
|
||||
// see MediaFormat: video stream formats range from 0x100 to 0x1000
|
||||
assertTrue("format id does not fit an audio stream: " + formatId,
|
||||
0x100 <= formatId && formatId < 0x1000);
|
||||
}
|
||||
} else {
|
||||
assertTrue(audioStreams.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSubtitles() throws Exception {
|
||||
final List<SubtitlesStream> subtitles = extractor().getSubtitlesDefault();
|
||||
assertNotNull(subtitles);
|
||||
|
||||
if (expectedHasSubtitles()) {
|
||||
assertFalse(subtitles.isEmpty());
|
||||
|
||||
for (final SubtitlesStream stream : subtitles) {
|
||||
assertIsSecureUrl(stream.getUrl());
|
||||
|
||||
final int formatId = stream.getFormatId();
|
||||
// see MediaFormat: video stream formats range from 0x1000 to 0x10000
|
||||
assertTrue("format id does not fit a subtitles stream: " + formatId,
|
||||
0x1000 <= formatId && formatId < 0x10000);
|
||||
}
|
||||
} else {
|
||||
assertTrue(subtitles.isEmpty());
|
||||
|
||||
final MediaFormat[] formats = {MediaFormat.VTT, MediaFormat.TTML, MediaFormat.SRT,
|
||||
MediaFormat.TRANSCRIPT1, MediaFormat.TRANSCRIPT2, MediaFormat.TRANSCRIPT3};
|
||||
for (final MediaFormat format : formats) {
|
||||
final List<SubtitlesStream> formatSubtitles = extractor().getSubtitles(format);
|
||||
assertNotNull(formatSubtitles);
|
||||
assertTrue(formatSubtitles.isEmpty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testGetDashMpdUrl() throws Exception {
|
||||
final String dashMpdUrl = extractor().getDashMpdUrl();
|
||||
if (expectedDashMpdUrlContains() == null) {
|
||||
assertNotNull(dashMpdUrl);
|
||||
assertTrue(dashMpdUrl.isEmpty());
|
||||
} else {
|
||||
assertIsSecureUrl(dashMpdUrl);
|
||||
assertThat(extractor().getDashMpdUrl(), containsString(expectedDashMpdUrlContains()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testFrames() throws Exception {
|
||||
final List<Frameset> frames = extractor().getFrames();
|
||||
assertNotNull(frames);
|
||||
|
||||
if (expectedHasFrames()) {
|
||||
assertFalse(frames.isEmpty());
|
||||
for (final Frameset f : frames) {
|
||||
for (final String url : f.getUrls()) {
|
||||
assertIsValidUrl(url);
|
||||
assertIsSecureUrl(url);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assertTrue(frames.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testHost() throws Exception {
|
||||
assertEquals(expectedHost(), extractor().getHost());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testPrivacy() throws Exception {
|
||||
assertEquals(expectedPrivacy(), extractor().getPrivacy());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testCategory() throws Exception {
|
||||
assertEquals(expectedCategory(), extractor().getCategory());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testLicence() throws Exception {
|
||||
assertEquals(expectedLicence(), extractor().getLicence());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testLanguageInfo() throws Exception {
|
||||
assertEquals(expectedLanguageInfo(), extractor().getLanguageInfo());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testTags() throws Exception {
|
||||
assertEqualsOrderIndependent(expectedTags(), extractor().getTags());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testSupportInfo() throws Exception {
|
||||
assertEquals(expectedSupportInfo(), extractor().getSupportInfo());
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -42,7 +41,7 @@ public final class DefaultTests {
|
||||
StreamInfoItem streamInfoItem = (StreamInfoItem) item;
|
||||
assertNotEmpty("Uploader name not set: " + item, streamInfoItem.getUploaderName());
|
||||
|
||||
// assertNotEmpty("Uploader url not set: " + item, streamInfoItem.getUploaderUrl());
|
||||
// assertNotEmpty("Uploader url not set: " + item, streamInfoItem.getUploaderUrl());
|
||||
final String uploaderUrl = streamInfoItem.getUploaderUrl();
|
||||
if (!isNullOrEmpty(uploaderUrl)) {
|
||||
assertIsSecureUrl(uploaderUrl);
|
||||
@@ -54,7 +53,6 @@ public final class DefaultTests {
|
||||
if (!isNullOrEmpty(streamInfoItem.getTextualUploadDate())) {
|
||||
final DateWrapper uploadDate = streamInfoItem.getUploadDate();
|
||||
assertNotNull("No parsed upload date", uploadDate);
|
||||
assertTrue("Upload date not in the past", uploadDate.date().before(Calendar.getInstance()));
|
||||
}
|
||||
|
||||
} else if (item instanceof ChannelInfoItem) {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class MediaCCCConferenceExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testGetUrl() throws Exception {
|
||||
assertEquals("https://media.ccc.de/public/conferences/froscon2017", extractor.getUrl());
|
||||
assertEquals("https://media.ccc.de/c/froscon2017", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,7 +67,7 @@ public class MediaCCCConferenceExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testGetUrl() throws Exception {
|
||||
assertEquals("https://media.ccc.de/public/conferences/oscal19", extractor.getUrl());
|
||||
assertEquals("https://media.ccc.de/c/oscal19", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
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.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferenceLinkHandlerFactory;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MediaCCCConferenceLinkHandlerFactoryTest {
|
||||
private static MediaCCCConferenceLinkHandlerFactory linkHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
linkHandler = new MediaCCCConferenceLinkHandlerFactory();
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getId() throws ParsingException {
|
||||
assertEquals("jh20",
|
||||
linkHandler.fromUrl("https://media.ccc.de/c/jh20#278").getId());
|
||||
assertEquals("jh20",
|
||||
linkHandler.fromUrl("https://media.ccc.de/b/jh20?a=b").getId());
|
||||
assertEquals("jh20",
|
||||
linkHandler.fromUrl("https://api.media.ccc.de/public/conferences/jh20&a=b&b=c").getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUrl() throws ParsingException {
|
||||
assertEquals("https://media.ccc.de/c/jh20",
|
||||
linkHandler.fromUrl("https://media.ccc.de/c/jh20#278").getUrl());
|
||||
assertEquals("https://media.ccc.de/c/jh20",
|
||||
linkHandler.fromUrl("https://media.ccc.de/b/jh20?a=b").getUrl());
|
||||
assertEquals("https://media.ccc.de/c/jh20",
|
||||
linkHandler.fromUrl("https://api.media.ccc.de/public/conferences/jh20&a=b&b=c").getUrl());
|
||||
assertEquals("https://media.ccc.de/c/jh20",
|
||||
linkHandler.fromId("jh20").getUrl());
|
||||
}
|
||||
}
|
||||
@@ -1,204 +1,152 @@
|
||||
package org.schabi.newpipe.extractor.services.media_ccc;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
|
||||
|
||||
/**
|
||||
* Test {@link MediaCCCStreamExtractor}
|
||||
*/
|
||||
public class MediaCCCStreamExtractorTest {
|
||||
public static class Gpn18Tmux {
|
||||
private static MediaCCCStreamExtractor extractor;
|
||||
private static final String BASE_URL = "https://media.ccc.de/v/";
|
||||
|
||||
public static class Gpn18Tmux extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "gpn18-105-tmux-warum-ein-schwarzes-fenster-am-bildschirm-reicht";
|
||||
private static final String URL = BASE_URL + ID;
|
||||
private static StreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
|
||||
extractor = (MediaCCCStreamExtractor) MediaCCC.getStreamExtractor("https://media.ccc.de/v/gpn18-105-tmux-warum-ein-schwarzes-fenster-am-bildschirm-reicht");
|
||||
extractor = MediaCCC.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServiceId() throws Exception {
|
||||
assertEquals(2, extractor.getServiceId());
|
||||
}
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return MediaCCC; }
|
||||
@Override public String expectedName() { return "tmux - Warum ein schwarzes Fenster am Bildschirm reicht"; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return URL; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Test
|
||||
public void testName() throws Exception {
|
||||
assertEquals("tmux - Warum ein schwarzes Fenster am Bildschirm reicht", extractor.getName());
|
||||
}
|
||||
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "gpn18"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://media.ccc.de/c/gpn18"; }
|
||||
@Override public List<String> expectedDescriptionContains() { return Arrays.asList("SSH-Sessions", "\"Terminal Multiplexer\""); }
|
||||
@Override public long expectedLength() { return 3097; }
|
||||
@Override public long expectedViewCountAtLeast() { return 2380; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2018-05-11 00:00:00.000"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2018-05-11T02:00:00.000+02:00"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return -1; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return -1; }
|
||||
@Override public boolean expectedHasRelatedStreams() { return false; }
|
||||
@Override public boolean expectedHasSubtitles() { return false; }
|
||||
@Override public boolean expectedHasFrames() { return false; }
|
||||
@Override public List<String> expectedTags() { return Arrays.asList("gpn18", "105"); }
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testId() throws Exception {
|
||||
assertEquals("gpn18-105-tmux-warum-ein-schwarzes-fenster-am-bildschirm-reicht", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrl() throws Exception {
|
||||
assertIsSecureUrl(extractor.getUrl());
|
||||
assertEquals("https://media.ccc.de/public/events/gpn18-105-tmux-warum-ein-schwarzes-fenster-am-bildschirm-reicht", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertIsSecureUrl(extractor.getOriginalUrl());
|
||||
assertEquals("https://media.ccc.de/v/gpn18-105-tmux-warum-ein-schwarzes-fenster-am-bildschirm-reicht", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThumbnail() throws Exception {
|
||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||
public void testThumbnailUrl() throws Exception {
|
||||
super.testThumbnailUrl();
|
||||
assertEquals("https://static.media.ccc.de/media/events/gpn/gpn18/105-hd.jpg", extractor.getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderName() throws Exception {
|
||||
assertEquals("gpn18", extractor.getUploaderName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderUrl() throws Exception {
|
||||
assertIsSecureUrl(extractor.getUploaderUrl());
|
||||
assertEquals("https://media.ccc.de/public/conferences/gpn18", extractor.getUploaderUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testUploaderAvatarUrl() throws Exception {
|
||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||
super.testUploaderAvatarUrl();
|
||||
assertEquals("https://static.media.ccc.de/media/events/gpn/gpn18/logo.png", extractor.getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testVideoStreams() throws Exception {
|
||||
List<VideoStream> videoStreamList = extractor.getVideoStreams();
|
||||
assertEquals(4, videoStreamList.size());
|
||||
for (VideoStream stream : videoStreamList) {
|
||||
assertIsSecureUrl(stream.getUrl());
|
||||
}
|
||||
super.testVideoStreams();
|
||||
assertEquals(4, extractor.getVideoStreams().size());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAudioStreams() throws Exception {
|
||||
List<AudioStream> audioStreamList = extractor.getAudioStreams();
|
||||
assertEquals(2, audioStreamList.size());
|
||||
for (AudioStream stream : audioStreamList) {
|
||||
assertIsSecureUrl(stream.getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTextualUploadDate() throws ParsingException {
|
||||
Assert.assertEquals("2018-05-11T02:00:00.000+02:00", extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(new SimpleDateFormat("yyyy-MM-dd").parse("2018-05-11"));
|
||||
assertEquals(instance, requireNonNull(extractor.getUploadDate()).date());
|
||||
super.testAudioStreams();
|
||||
assertEquals(2, extractor.getAudioStreams().size());
|
||||
}
|
||||
}
|
||||
|
||||
public static class _36c3PrivacyMessaging {
|
||||
private static MediaCCCStreamExtractor extractor;
|
||||
public static class _36c3PrivacyMessaging extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "36c3-10565-what_s_left_for_private_messaging";
|
||||
private static final String URL = BASE_URL + ID;
|
||||
private static StreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (MediaCCCStreamExtractor) MediaCCC.getStreamExtractor("https://media.ccc.de/v/36c3-10565-what_s_left_for_private_messaging");
|
||||
extractor = MediaCCC.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testName() throws Exception {
|
||||
assertEquals("What's left for private messaging?", extractor.getName());
|
||||
}
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return MediaCCC; }
|
||||
@Override public String expectedName() { return "What's left for private messaging?"; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return URL; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Test
|
||||
public void testId() throws Exception {
|
||||
assertEquals("36c3-10565-what_s_left_for_private_messaging", extractor.getId());
|
||||
}
|
||||
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "36c3"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://media.ccc.de/c/36c3"; }
|
||||
@Override public List<String> expectedDescriptionContains() { return Arrays.asList("WhatsApp", "Signal"); }
|
||||
@Override public long expectedLength() { return 3603; }
|
||||
@Override public long expectedViewCountAtLeast() { return 2380; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2020-01-11 00:00:00.000"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2020-01-11T01:00:00.000+01:00"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return -1; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return -1; }
|
||||
@Override public boolean expectedHasRelatedStreams() { return false; }
|
||||
@Override public boolean expectedHasSubtitles() { return false; }
|
||||
@Override public boolean expectedHasFrames() { return false; }
|
||||
@Override public List<String> expectedTags() { return Arrays.asList("36c3", "10565", "2019", "Security", "Main"); }
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testUrl() throws Exception {
|
||||
assertIsSecureUrl(extractor.getUrl());
|
||||
assertEquals("https://media.ccc.de/public/events/36c3-10565-what_s_left_for_private_messaging", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws Exception {
|
||||
assertIsSecureUrl(extractor.getOriginalUrl());
|
||||
assertEquals("https://media.ccc.de/v/36c3-10565-what_s_left_for_private_messaging", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThumbnail() throws Exception {
|
||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||
public void testThumbnailUrl() throws Exception {
|
||||
super.testThumbnailUrl();
|
||||
assertEquals("https://static.media.ccc.de/media/congress/2019/10565-hd.jpg", extractor.getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderName() throws Exception {
|
||||
assertEquals("36c3", extractor.getUploaderName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploaderUrl() throws Exception {
|
||||
assertIsSecureUrl(extractor.getUploaderUrl());
|
||||
assertEquals("https://media.ccc.de/public/conferences/36c3", extractor.getUploaderUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testUploaderAvatarUrl() throws Exception {
|
||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||
super.testUploaderAvatarUrl();
|
||||
assertEquals("https://static.media.ccc.de/media/congress/2019/logo.png", extractor.getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testVideoStreams() throws Exception {
|
||||
List<VideoStream> videoStreamList = extractor.getVideoStreams();
|
||||
assertEquals(8, videoStreamList.size());
|
||||
for (VideoStream stream : videoStreamList) {
|
||||
assertIsSecureUrl(stream.getUrl());
|
||||
}
|
||||
super.testVideoStreams();
|
||||
assertEquals(8, extractor.getVideoStreams().size());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testAudioStreams() throws Exception {
|
||||
List<AudioStream> audioStreamList = extractor.getAudioStreams();
|
||||
assertEquals(2, audioStreamList.size());
|
||||
for (AudioStream stream : audioStreamList) {
|
||||
assertIsSecureUrl(stream.getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTextualUploadDate() throws ParsingException {
|
||||
Assert.assertEquals("2020-01-11T01:00:00.000+01:00", extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(new SimpleDateFormat("yyyy-MM-dd").parse("2020-01-11"));
|
||||
assertEquals(instance, requireNonNull(extractor.getUploadDate()).date());
|
||||
super.testAudioStreams();
|
||||
assertEquals(2, extractor.getAudioStreams().size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
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.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCStreamLinkHandlerFactory;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MediaCCCStreamLinkHandlerFactoryTest {
|
||||
private static MediaCCCStreamLinkHandlerFactory linkHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
linkHandler = new MediaCCCStreamLinkHandlerFactory();
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getId() throws ParsingException {
|
||||
assertEquals("jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
|
||||
linkHandler.fromUrl("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020").getId());
|
||||
assertEquals("jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
|
||||
linkHandler.fromUrl("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020?a=b").getId());
|
||||
assertEquals("jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
|
||||
linkHandler.fromUrl("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020#3").getId());
|
||||
assertEquals("jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
|
||||
linkHandler.fromUrl("https://api.media.ccc.de/public/events/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020&a=b").getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUrl() throws ParsingException {
|
||||
assertEquals("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
|
||||
linkHandler.fromUrl("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020").getUrl());
|
||||
assertEquals("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
|
||||
linkHandler.fromUrl("https://api.media.ccc.de/public/events/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020?b=a&a=b").getUrl());
|
||||
assertEquals("https://media.ccc.de/v/jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020",
|
||||
linkHandler.fromId("jhremote20-3001-abschlusspraesentation_jugend_hackt_remote_2020").getUrl());
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class PeertubeAccountExtractorTest {
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));
|
||||
extractor = (PeertubeAccountExtractor) PeerTube
|
||||
.getChannelExtractor("https://peertube.mastodon.host/api/v1/accounts/kde");
|
||||
.getChannelExtractor("https://peertube.mastodon.host/accounts/kde");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class PeertubeAccountExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/accounts/kde", extractor.getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/accounts/kde", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,10 +89,9 @@ public class PeertubeAccountExtractorTest {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testBannerUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getBannerUrl());
|
||||
public void testBannerUrl() {
|
||||
assertNull(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -115,7 +114,7 @@ public class PeertubeAccountExtractorTest {
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));
|
||||
extractor = (PeertubeAccountExtractor) PeerTube
|
||||
.getChannelExtractor("https://peertube.mastodon.host/accounts/booteille");
|
||||
.getChannelExtractor("https://peertube.mastodon.host/api/v1/accounts/booteille");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@@ -150,12 +149,12 @@ public class PeertubeAccountExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/accounts/booteille", extractor.getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/accounts/booteille", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/accounts/booteille", extractor.getOriginalUrl());
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/accounts/booteille", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PeertubeChannelExtractorTest {
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));
|
||||
extractor = (PeertubeChannelExtractor) PeerTube
|
||||
.getChannelExtractor("https://peertube.mastodon.host/api/v1/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa");
|
||||
.getChannelExtractor("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class PeertubeChannelExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa", extractor.getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,10 +104,9 @@ public class PeertubeChannelExtractorTest {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testBannerUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getBannerUrl());
|
||||
assertNull(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -130,7 +129,7 @@ public class PeertubeChannelExtractorTest {
|
||||
// setting instance might break test when running in parallel
|
||||
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));
|
||||
extractor = (PeertubeChannelExtractor) PeerTube
|
||||
.getChannelExtractor("https://peertube.mastodon.host/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457");
|
||||
.getChannelExtractor("https://peertube.mastodon.host/api/v1/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@@ -165,12 +164,12 @@ public class PeertubeChannelExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457", extractor.getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457", extractor.getOriginalUrl());
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/video-channels/35080089-79b6-45fc-96ac-37e4d46a4457", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -28,20 +28,36 @@ public class PeertubeChannelLinkHandlerFactoryTest {
|
||||
@Test
|
||||
public void acceptUrlTest() throws ParsingException {
|
||||
assertTrue(linkHandler.acceptUrl("https://peertube.mastodon.host/accounts/kranti@videos.squat.net"));
|
||||
assertTrue(linkHandler.acceptUrl("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa"));
|
||||
assertTrue(linkHandler.acceptUrl("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa/videos"));
|
||||
assertTrue(linkHandler.acceptUrl("https://peertube.mastodon.host/api/v1/accounts/kranti@videos.squat.net/videos"));
|
||||
assertTrue(linkHandler.acceptUrl("https://peertube.mastodon.host/api/v1/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIdFromUrl() throws ParsingException {
|
||||
assertEquals("accounts/kranti@videos.squat.net", linkHandler.fromUrl("https://peertube.mastodon.host/accounts/kranti@videos.squat.net").getId());
|
||||
assertEquals("accounts/kranti@videos.squat.net", linkHandler.fromUrl("https://peertube.mastodon.host/accounts/kranti@videos.squat.net/videos").getId());
|
||||
assertEquals("video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa", linkHandler.fromUrl("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa/videos").getId());
|
||||
public void getId() throws ParsingException {
|
||||
assertEquals("accounts/kranti@videos.squat.net",
|
||||
linkHandler.fromUrl("https://peertube.mastodon.host/accounts/kranti@videos.squat.net").getId());
|
||||
assertEquals("accounts/kranti@videos.squat.net",
|
||||
linkHandler.fromUrl("https://peertube.mastodon.host/accounts/kranti@videos.squat.net/videos").getId());
|
||||
assertEquals("video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa",
|
||||
linkHandler.fromUrl("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa/videos").getId());
|
||||
assertEquals("accounts/kranti@videos.squat.net",
|
||||
linkHandler.fromUrl("https://peertube.mastodon.host/api/v1/accounts/kranti@videos.squat.net").getId());
|
||||
assertEquals("accounts/kranti@videos.squat.net",
|
||||
linkHandler.fromUrl("https://peertube.mastodon.host/api/v1/accounts/kranti@videos.squat.net/videos").getId());
|
||||
assertEquals("video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa",
|
||||
linkHandler.fromUrl("https://peertube.mastodon.host/api/v1/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa").getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUrlFromId() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa", linkHandler.fromId("video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa").getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/accounts/kranti@videos.squat.net", linkHandler.fromId("accounts/kranti@videos.squat.net").getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/api/v1/accounts/kranti@videos.squat.net", linkHandler.fromId("kranti@videos.squat.net").getUrl());
|
||||
public void getUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa",
|
||||
linkHandler.fromId("video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa").getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/accounts/kranti@videos.squat.net",
|
||||
linkHandler.fromId("accounts/kranti@videos.squat.net").getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/accounts/kranti@videos.squat.net",
|
||||
linkHandler.fromId("kranti@videos.squat.net").getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa",
|
||||
linkHandler.fromUrl("https://peertube.mastodon.host/api/v1/video-channels/7682d9f2-07be-4622-862e-93ec812e2ffa").getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
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.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
|
||||
/**
|
||||
* Test for {@link StreamExtractor}
|
||||
*/
|
||||
public class PeertubeStreamExtractorDefaultTest {
|
||||
private static PeertubeStreamExtractor extractor;
|
||||
private static final String expectedLargeDescription = "**[Want to help to translate this video?](https://weblate.framasoft.org/projects/what-is-peertube-video/)**\r\n\r\n**Take back the control of your videos! [#JoinPeertube](https://joinpeertube.org)**\r\n*A decentralized video hosting network, based on free/libre software!*\r\n\r\n**Animation Produced by:** [LILA](https://libreart.info) - [ZeMarmot Team](https://film.zemarmot.net)\r\n*Directed by* Aryeom\r\n*Assistant* Jehan\r\n**Licence**: [CC-By-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)\r\n\r\n**Sponsored by** [Framasoft](https://framasoft.org)\r\n\r\n**Music**: [Red Step Forward](http://play.dogmazic.net/song.php?song_id=52491) - CC-By Ken Bushima\r\n\r\n**Movie Clip**: [Caminades 3: Llamigos](http://www.caminandes.com/) CC-By Blender Institute\r\n\r\n**Video sources**: https://gitlab.gnome.org/Jehan/what-is-peertube/";
|
||||
private static final String expectedSmallDescription = "https://www.kickstarter.com/projects/1587081065/nothing-to-hide-the-documentary";
|
||||
|
||||
@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 = (PeertubeStreamExtractor) PeerTube.getStreamExtractor("https://framatube.org/videos/watch/9c9de5e8-0a1e-484a-b099-e80766180a6d");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
instance.setTime(sdf.parse("2018-10-01T10:52:46.396Z"));
|
||||
assertEquals(instance, requireNonNull(extractor.getUploadDate()).date());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInvalidTimeStamp() throws ParsingException {
|
||||
assertTrue(extractor.getTimeStamp() + "",
|
||||
extractor.getTimeStamp() <= 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTitle() throws ParsingException {
|
||||
assertEquals("What is PeerTube?", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLargeDescription() throws ParsingException {
|
||||
assertEquals(expectedLargeDescription, extractor.getDescription().getContent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEmptyDescription() throws Exception {
|
||||
PeertubeStreamExtractor extractorEmpty = (PeertubeStreamExtractor) PeerTube.getStreamExtractor("https://framatube.org/api/v1/videos/d5907aad-2252-4207-89ec-a4b687b9337d");
|
||||
extractorEmpty.fetchPage();
|
||||
assertEquals("", extractorEmpty.getDescription().getContent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSmallDescription() throws Exception {
|
||||
PeerTube.setInstance(new PeertubeInstance("https://peertube.cpy.re", "PeerTube test server"));
|
||||
PeertubeStreamExtractor extractorSmall = (PeertubeStreamExtractor) PeerTube.getStreamExtractor("https://peertube.cpy.re/videos/watch/d2a5ec78-5f85-4090-8ec5-dc1102e022ea");
|
||||
extractorSmall.fetchPage();
|
||||
assertEquals(expectedSmallDescription, extractorSmall.getDescription().getContent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderName() throws ParsingException {
|
||||
assertEquals("Framasoft", extractor.getUploaderName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getUploaderUrl());
|
||||
assertEquals("https://framatube.org/api/v1/accounts/framasoft@framatube.org", extractor.getUploaderUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubChannelName() throws ParsingException {
|
||||
assertEquals("Les vidéos de Framasoft", extractor.getSubChannelName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubChannelUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getSubChannelUrl());
|
||||
assertEquals("https://framatube.org/video-channels/bf54d359-cfad-4935-9d45-9d6be93f63e8", extractor.getSubChannelUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubChannelAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getSubChannelAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLength() throws ParsingException {
|
||||
assertEquals(113, extractor.getLength());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetViewCount() throws ParsingException {
|
||||
assertTrue(Long.toString(extractor.getViewCount()),
|
||||
extractor.getViewCount() > 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetThumbnailUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVideoStreams() throws IOException, ExtractionException {
|
||||
assertFalse(extractor.getVideoStreams().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamType() throws ParsingException {
|
||||
assertTrue(extractor.getStreamType() == StreamType.VIDEO_STREAM);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testGetRelatedVideos() throws ExtractionException, IOException {
|
||||
StreamInfoItemsCollector relatedVideos = extractor.getRelatedStreams();
|
||||
assertFalse(relatedVideos.getItems().isEmpty());
|
||||
assertTrue(relatedVideos.getErrors().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesListDefault() throws IOException, ExtractionException {
|
||||
assertFalse(extractor.getSubtitlesDefault().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesList() throws IOException, ExtractionException {
|
||||
assertFalse(extractor.getSubtitlesDefault().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAgeLimit() throws ExtractionException, IOException {
|
||||
assertEquals(0, extractor.getAgeLimit());
|
||||
PeertubeStreamExtractor ageLimit = (PeertubeStreamExtractor) PeerTube.getStreamExtractor("https://nocensoring.net/videos/embed/dbd8e5e1-c527-49b6-b70c-89101dbb9c08");
|
||||
ageLimit.fetchPage();
|
||||
assertEquals(18, ageLimit.getAgeLimit());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSupportInformation() throws ExtractionException, IOException {
|
||||
PeertubeStreamExtractor supportInfoExtractor = (PeertubeStreamExtractor) PeerTube.getStreamExtractor("https://framatube.org/videos/watch/ee408ec8-07cd-4e35-b884-fb681a4b9d37");
|
||||
supportInfoExtractor.fetchPage();
|
||||
assertEquals("https://utip.io/chatsceptique", supportInfoExtractor.getSupportInfo());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLanguageInformation() throws ParsingException {
|
||||
assertEquals(new Locale("en"), extractor.getLanguageInfo());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package org.schabi.newpipe.extractor.services.peertube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
|
||||
public class PeertubeStreamExtractorTest {
|
||||
private static final String BASE_URL = "/videos/watch/";
|
||||
|
||||
public static class WhatIsPeertube extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "9c9de5e8-0a1e-484a-b099-e80766180a6d";
|
||||
private static final String INSTANCE = "https://framatube.org";
|
||||
private static final int TIMESTAMP_MINUTE = 1;
|
||||
private static final int TIMESTAMP_SECOND = 21;
|
||||
private static final String URL = INSTANCE + BASE_URL + ID + "?start=" + TIMESTAMP_MINUTE + "m" + TIMESTAMP_SECOND + "s";
|
||||
private static StreamExtractor 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(INSTANCE, "FramaTube"));
|
||||
extractor = PeerTube.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLanguageInformation() throws ParsingException {
|
||||
assertEquals(new Locale("en"), extractor.getLanguageInfo());
|
||||
}
|
||||
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return PeerTube; }
|
||||
@Override public String expectedName() { return "What is PeerTube?"; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return INSTANCE + BASE_URL + ID; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "Framasoft"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://framatube.org/accounts/framasoft@framatube.org"; }
|
||||
@Override public String expectedSubChannelName() { return "Les vidéos de Framasoft"; }
|
||||
@Override public String expectedSubChannelUrl() { return "https://framatube.org/video-channels/bf54d359-cfad-4935-9d45-9d6be93f63e8"; }
|
||||
@Override public List<String> expectedDescriptionContains() { // CRLF line ending
|
||||
return Arrays.asList("**[Want to help to translate this video?](https://weblate.framasoft.org/projects/what-is-peertube-video/)**\r\n"
|
||||
+ "\r\n"
|
||||
+ "**Take back the control of your videos! [#JoinPeertube](https://joinpeertube.org)**\r\n"
|
||||
+ "*A decentralized video hosting network, based on free/libre software!*\r\n"
|
||||
+ "\r\n"
|
||||
+ "**Animation Produced by:** [LILA](https://libreart.info) - [ZeMarmot Team](https://film.zemarmot.net)\r\n"
|
||||
+ "*Directed by* Aryeom\r\n"
|
||||
+ "*Assistant* Jehan\r\n"
|
||||
+ "**Licence**: [CC-By-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)\r\n"
|
||||
+ "\r\n"
|
||||
+ "**Sponsored by** [Framasoft](https://framasoft.org)\r\n"
|
||||
+ "\r\n"
|
||||
+ "**Music**: [Red Step Forward](http://play.dogmazic.net/song.php?song_id=52491) - CC-By Ken Bushima\r\n"
|
||||
+ "\r\n"
|
||||
+ "**Movie Clip**: [Caminades 3: Llamigos](http://www.caminandes.com/) CC-By Blender Institute\r\n"
|
||||
+ "\r\n"
|
||||
+ "**Video sources**: https://gitlab.gnome.org/Jehan/what-is-peertube/");
|
||||
}
|
||||
@Override public long expectedLength() { return 113; }
|
||||
@Override public long expectedTimestamp() { return TIMESTAMP_MINUTE*60 + TIMESTAMP_SECOND; }
|
||||
@Override public long expectedViewCountAtLeast() { return 38600; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2018-10-01 10:52:46.396"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2018-10-01T10:52:46.396Z"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return 120; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return 0; }
|
||||
@Override public boolean expectedHasAudioStreams() { return false; }
|
||||
@Override public boolean expectedHasFrames() { return false; }
|
||||
@Override public String expectedHost() { return "framatube.org"; }
|
||||
@Override public String expectedPrivacy() { return "Public"; }
|
||||
@Override public String expectedCategory() { return "Science & Technology"; }
|
||||
@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"); }
|
||||
}
|
||||
|
||||
public static class AgeRestricted extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "dbd8e5e1-c527-49b6-b70c-89101dbb9c08";
|
||||
private static final String INSTANCE = "https://nocensoring.net";
|
||||
private static final String URL = INSTANCE + "/videos/embed/" + ID;
|
||||
private static StreamExtractor 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(INSTANCE));
|
||||
extractor = PeerTube.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return PeerTube; }
|
||||
@Override public String expectedName() { return "Covid-19 ? [Court-métrage]"; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return INSTANCE + BASE_URL + ID; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "Résilience humaine"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://nocensoring.net/accounts/gmt@nocensoring.net"; }
|
||||
@Override public String expectedSubChannelName() { return "SYSTEM FAILURE Quel à-venir ?"; }
|
||||
@Override public String expectedSubChannelUrl() { return "https://nocensoring.net/video-channels/systemfailure_quel"; }
|
||||
@Override public List<String> expectedDescriptionContains() { // LF line ending
|
||||
return Arrays.asList("2020, le monde est frappé par une pandémie, beaucoup d'humains sont confinés.",
|
||||
"System Failure Quel à-venir ? - Covid-19 / 2020");
|
||||
}
|
||||
@Override public long expectedLength() { return 667; }
|
||||
@Override public long expectedViewCountAtLeast() { return 138; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2020-05-14 17:24:35.580"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2020-05-14T17:24:35.580Z"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return 1; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return 0; }
|
||||
@Override public int expectedAgeLimit() { return 18; }
|
||||
@Override public boolean expectedHasAudioStreams() { return false; }
|
||||
@Override public boolean expectedHasSubtitles() { return false; }
|
||||
@Override public boolean expectedHasFrames() { return false; }
|
||||
@Override public String expectedHost() { return "nocensoring.net"; }
|
||||
@Override public String expectedPrivacy() { return "Public"; }
|
||||
@Override public String expectedCategory() { return "Art"; }
|
||||
@Override public String expectedLicence() { return "Attribution"; }
|
||||
@Override public List<String> expectedTags() { return Arrays.asList("Covid-19", "Gérôme-Mary trebor", "Horreur et beauté", "court-métrage", "nue artistique"); }
|
||||
}
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
PeerTube.setInstance(new PeertubeInstance("https://peertube.cpy.re", "PeerTube test server"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEmptyDescription() throws Exception {
|
||||
StreamExtractor extractorEmpty = PeerTube.getStreamExtractor("https://framatube.org/api/v1/videos/d5907aad-2252-4207-89ec-a4b687b9337d");
|
||||
extractorEmpty.fetchPage();
|
||||
assertEquals("", extractorEmpty.getDescription().getContent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSmallDescription() throws Exception {
|
||||
StreamExtractor extractorSmall = PeerTube.getStreamExtractor("https://peertube.cpy.re/videos/watch/d2a5ec78-5f85-4090-8ec5-dc1102e022ea");
|
||||
extractorSmall.fetchPage();
|
||||
assertEquals("https://www.kickstarter.com/projects/1587081065/nothing-to-hide-the-documentary", extractorSmall.getDescription().getContent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSupportInformation() throws ExtractionException, IOException {
|
||||
StreamExtractor supportInfoExtractor = PeerTube.getStreamExtractor("https://framatube.org/videos/watch/ee408ec8-07cd-4e35-b884-fb681a4b9d37");
|
||||
supportInfoExtractor.fetchPage();
|
||||
assertEquals("https://utip.io/chatsceptique", supportInfoExtractor.getSupportInfo());
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeStream
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
|
||||
/**
|
||||
* Test for {@link PeertubeStreamLinkHandlerFactory}
|
||||
@@ -17,16 +18,34 @@ public class PeertubeStreamLinkHandlerFactoryTest {
|
||||
private static PeertubeStreamLinkHandlerFactory linkHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
public static void setUp() {
|
||||
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));
|
||||
linkHandler = PeertubeStreamLinkHandlerFactory.getInstance();
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getId() throws Exception {
|
||||
assertEquals("986aac60-1263-4f73-9ce5-36b18225cb60", linkHandler.fromUrl("https://peertube.mastodon.host/videos/watch/986aac60-1263-4f73-9ce5-36b18225cb60").getId());
|
||||
assertEquals("986aac60-1263-4f73-9ce5-36b18225cb60", linkHandler.fromUrl("https://peertube.mastodon.host/videos/watch/986aac60-1263-4f73-9ce5-36b18225cb60?fsdafs=fsafa").getId());
|
||||
assertEquals("9c9de5e8-0a1e-484a-b099-e80766180a6d", linkHandler.fromUrl("https://framatube.org/videos/embed/9c9de5e8-0a1e-484a-b099-e80766180a6d").getId());
|
||||
assertEquals("986aac60-1263-4f73-9ce5-36b18225cb60",
|
||||
linkHandler.fromUrl("https://peertube.mastodon.host/videos/watch/986aac60-1263-4f73-9ce5-36b18225cb60").getId());
|
||||
assertEquals("986aac60-1263-4f73-9ce5-36b18225cb60",
|
||||
linkHandler.fromUrl("https://peertube.mastodon.host/videos/watch/986aac60-1263-4f73-9ce5-36b18225cb60?fsdafs=fsafa").getId());
|
||||
assertEquals("9c9de5e8-0a1e-484a-b099-e80766180a6d",
|
||||
linkHandler.fromUrl("https://framatube.org/videos/embed/9c9de5e8-0a1e-484a-b099-e80766180a6d").getId());
|
||||
assertEquals("986aac60-1263-4f73-9ce5-36b18225cb60",
|
||||
linkHandler.fromUrl("https://peertube.mastodon.host/api/v1/videos/watch/986aac60-1263-4f73-9ce5-36b18225cb60").getId());
|
||||
assertEquals("986aac60-1263-4f73-9ce5-36b18225cb60",
|
||||
linkHandler.fromUrl("https://peertube.mastodon.host/api/v1/videos/watch/986aac60-1263-4f73-9ce5-36b18225cb60?fsdafs=fsafa").getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUrl() throws Exception {
|
||||
assertEquals("https://peertube.mastodon.host/videos/watch/986aac60-1263-4f73-9ce5-36b18225cb60",
|
||||
linkHandler.fromId("986aac60-1263-4f73-9ce5-36b18225cb60").getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/videos/watch/986aac60-1263-4f73-9ce5-36b18225cb60",
|
||||
linkHandler.fromUrl("https://peertube.mastodon.host/api/v1/videos/watch/986aac60-1263-4f73-9ce5-36b18225cb60").getUrl());
|
||||
assertEquals("https://peertube.mastodon.host/videos/watch/986aac60-1263-4f73-9ce5-36b18225cb60",
|
||||
linkHandler.fromUrl("https://peertube.mastodon.host/videos/embed/986aac60-1263-4f73-9ce5-36b18225cb60").getUrl());
|
||||
}
|
||||
|
||||
|
||||
@@ -35,5 +54,6 @@ public class PeertubeStreamLinkHandlerFactoryTest {
|
||||
assertTrue(linkHandler.acceptUrl("https://peertube.mastodon.host/videos/watch/986aac60-1263-4f73-9ce5-36b18225cb60"));
|
||||
assertTrue(linkHandler.acceptUrl("https://peertube.mastodon.host/videos/watch/986aac60-1263-4f73-9ce5-36b18225cb60?fsdafs=fsafa"));
|
||||
assertTrue(linkHandler.acceptUrl("https://framatube.org/videos/embed/9c9de5e8-0a1e-484a-b099-e80766180a6d"));
|
||||
assertTrue(linkHandler.acceptUrl("https://peertube.mastodon.host/api/v1/videos/watch/986aac60-1263-4f73-9ce5-36b18225cb60?fsdafs=fsafa"));
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeTrendingExtractor;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
||||
|
||||
public class PeertubeTrendingExtractorTest {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SoundcloudChannelExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testName() {
|
||||
assertEquals("LIL UZI VERT", extractor.getName());
|
||||
assertEquals("Lil Uzi Vert", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChartsExtractor;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ public class SoundcloudPlaylistExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testUploaderName() {
|
||||
assertTrue(extractor.getUploaderName().contains("LIL UZI VERT"));
|
||||
assertTrue(extractor.getUploaderName().contains("Lil Uzi Vert"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,163 +0,0 @@
|
||||
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.extractor.NewPipe;
|
||||
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.soundcloud.extractors.SoundcloudStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
|
||||
/**
|
||||
* Test for {@link StreamExtractor}
|
||||
*/
|
||||
public class SoundcloudStreamExtractorDefaultTest {
|
||||
|
||||
public static class LilUziVertDoWhatIWant {
|
||||
private static SoundcloudStreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (SoundcloudStreamExtractor) SoundCloud.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInvalidTimeStamp() throws ParsingException {
|
||||
assertTrue(extractor.getTimeStamp() + "",
|
||||
extractor.getTimeStamp() <= 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
||||
StreamExtractor extractor = SoundCloud.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon#t=69");
|
||||
assertEquals("69", extractor.getTimeStamp() + "");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTitle() throws ParsingException {
|
||||
assertEquals("Do What I Want [Produced By Maaly Raw + Don Cannon]", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDescription() throws ParsingException {
|
||||
assertEquals("The Perfect LUV Tape®️", extractor.getDescription().getContent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderName() throws ParsingException {
|
||||
assertEquals("LIL UZI VERT", extractor.getUploaderName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLength() throws ParsingException {
|
||||
assertEquals(175, extractor.getLength());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetViewCount() throws ParsingException {
|
||||
assertTrue(Long.toString(extractor.getViewCount()),
|
||||
extractor.getViewCount() > 44227978);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTextualUploadDate() throws ParsingException {
|
||||
Assert.assertEquals("2016-07-31 18:18:07", extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss +0000");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
instance.setTime(sdf.parse("2016/07/31 18:18:07 +0000"));
|
||||
assertEquals(instance, requireNonNull(extractor.getUploadDate()).date());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getUploaderUrl());
|
||||
assertEquals("https://soundcloud.com/liluzivert", extractor.getUploaderUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetThumbnailUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAudioStreams() throws IOException, ExtractionException {
|
||||
assertFalse(extractor.getAudioStreams().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamType() throws ParsingException {
|
||||
assertTrue(extractor.getStreamType() == StreamType.AUDIO_STREAM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRelatedVideos() throws ExtractionException, IOException {
|
||||
StreamInfoItemsCollector relatedVideos = extractor.getRelatedStreams();
|
||||
assertFalse(relatedVideos.getItems().isEmpty());
|
||||
assertTrue(relatedVideos.getErrors().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesListDefault() throws IOException, ExtractionException {
|
||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||
assertTrue(extractor.getSubtitlesDefault().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesList() throws IOException, ExtractionException {
|
||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||
assertTrue(extractor.getSubtitlesDefault().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
public static class ContentNotSupported {
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test(expected = ContentNotSupportedException.class)
|
||||
public void hlsAudioStream() throws Exception {
|
||||
final StreamExtractor extractor =
|
||||
SoundCloud.getStreamExtractor("https://soundcloud.com/dualipa/cool");
|
||||
extractor.fetchPage();
|
||||
extractor.getAudioStreams();
|
||||
}
|
||||
|
||||
@Test(expected = ContentNotSupportedException.class)
|
||||
public void bothHlsAndOpusAudioStreams() throws Exception {
|
||||
final StreamExtractor extractor =
|
||||
SoundCloud.getStreamExtractor("https://soundcloud.com/lil-baby-4pf/no-sucker");
|
||||
extractor.fetchPage();
|
||||
extractor.getAudioStreams();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.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;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||
|
||||
public class SoundcloudStreamExtractorTest {
|
||||
|
||||
public static class CreativeCommonsPlaysWellWithOthers extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "plays-well-with-others-ep-2-what-do-an-army-of-ants-and-an-online-encyclopedia-have-in-common";
|
||||
private static final String UPLOADER = "https://soundcloud.com/wearecc";
|
||||
private static final int TIMESTAMP = 69;
|
||||
private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP;
|
||||
private static StreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = SoundCloud.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return SoundCloud; }
|
||||
@Override public String expectedName() { return "Plays Well with Others, Ep 2: What Do an Army of Ants and an Online Encyclopedia Have in Common?"; }
|
||||
@Override public String expectedId() { return "597253485"; }
|
||||
@Override public String expectedUrlContains() { return UPLOADER + "/" + ID; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Override public StreamType expectedStreamType() { return StreamType.AUDIO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "Creative Commons"; }
|
||||
@Override public String expectedUploaderUrl() { return UPLOADER; }
|
||||
@Override public List<String> expectedDescriptionContains() { return Arrays.asList("Stigmergy is a mechanism of indirect coordination",
|
||||
"All original content in Plays Well with Others is available under a Creative Commons BY license."); }
|
||||
@Override public long expectedLength() { return 1400; }
|
||||
@Override public long expectedTimestamp() { return TIMESTAMP; }
|
||||
@Override public long expectedViewCountAtLeast() { return 27000; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2019-03-28 13:36:18.000"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2019-03-28 13:36:18"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return -1; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return -1; }
|
||||
@Override public boolean expectedHasVideoStreams() { return false; }
|
||||
@Override public boolean expectedHasSubtitles() { return false; }
|
||||
@Override public boolean expectedHasFrames() { return false; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,6 +53,7 @@ public class SoundcloudStreamLinkHandlerFactoryTest {
|
||||
assertEquals("309689103", linkHandler.fromUrl("https://soundcloud.com/liluzivert/15-ysl").getId());
|
||||
assertEquals("309689082", linkHandler.fromUrl("https://www.soundcloud.com/liluzivert/15-luv-scars-ko").getId());
|
||||
assertEquals("309689035", linkHandler.fromUrl("http://soundcloud.com/liluzivert/15-boring-shit").getId());
|
||||
assertEquals("259273264", linkHandler.fromUrl("https://soundcloud.com/liluzivert/ps-qs-produced-by-don-cannon/").getId());
|
||||
assertEquals("294488599", linkHandler.fromUrl("http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats").getId());
|
||||
assertEquals("294488438", linkHandler.fromUrl("HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz").getId());
|
||||
assertEquals("294488147", linkHandler.fromUrl("https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69").getId());
|
||||
@@ -60,6 +61,7 @@ public class SoundcloudStreamLinkHandlerFactoryTest {
|
||||
assertEquals("294487684", linkHandler.fromUrl("https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9").getId());
|
||||
assertEquals("294487428", linkHandler.fromUrl("https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s").getId());
|
||||
assertEquals("294487157", linkHandler.fromUrl("https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s").getId());
|
||||
assertEquals("44556776", linkHandler.fromUrl("https://soundcloud.com/kechuspider-sets-1/last-days").getId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeCommentsLinkHandlerFactory;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class YouTubeCommentsLinkHandlerFactoryTest {
|
||||
|
||||
private static YoutubeCommentsLinkHandlerFactory linkHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
linkHandler = YoutubeCommentsLinkHandlerFactory.getInstance();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void getIdWithNullAsUrl() throws ParsingException {
|
||||
linkHandler.fromId(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIdFromYt() throws ParsingException {
|
||||
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://www.youtube.com/watch?v=VM_6n762j6M").getId());
|
||||
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://m.youtube.com/watch?v=VM_6n762j6M").getId());
|
||||
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://youtube.com/watch?v=VM_6n762j6M").getId());
|
||||
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://WWW.youtube.com/watch?v=VM_6n762j6M").getId());
|
||||
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://youtu.be/VM_6n762j6M").getId());
|
||||
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://youtu.be/VM_6n762j6M&t=20").getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptUrl() throws ParsingException {
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/watch?v=VM_6n762j6M&t=20"));
|
||||
assertTrue(linkHandler.acceptUrl("https://WWW.youtube.com/watch?v=VM_6n762j6M&t=20"));
|
||||
assertTrue(linkHandler.acceptUrl("https://youtube.com/watch?v=VM_6n762j6M&t=20"));
|
||||
assertTrue(linkHandler.acceptUrl("https://youtu.be/VM_6n762j6M&t=20"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeniesUrl() throws ParsingException {
|
||||
assertFalse(linkHandler.acceptUrl("https://www.you com/watch?v=VM_6n762j6M"));
|
||||
assertFalse(linkHandler.acceptUrl("https://com/watch?v=VM_6n762j6M"));
|
||||
assertFalse(linkHandler.acceptUrl("htt ://com/watch?v=VM_6n762j6M"));
|
||||
assertFalse(linkHandler.acceptUrl("ftp://www.youtube.com/watch?v=VM_6n762j6M"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIdFromInvidious() throws ParsingException {
|
||||
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://www.invidio.us/watch?v=VM_6n762j6M").getId());
|
||||
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://invidio.us/watch?v=VM_6n762j6M").getId());
|
||||
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://INVIDIO.US/watch?v=VM_6n762j6M").getId());
|
||||
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://invidio.us/VM_6n762j6M").getId());
|
||||
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://invidio.us/VM_6n762j6M&t=20").getId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -432,190 +432,6 @@ public class YoutubeChannelExtractorTest {
|
||||
}
|
||||
}
|
||||
|
||||
// this channel has no "Subscribe" button
|
||||
public static class EminemVEVO implements BaseChannelExtractorTest {
|
||||
private static YoutubeChannelExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeChannelExtractor) YouTube
|
||||
.getChannelExtractor("https://www.youtube.com/user/EminemVEVO/");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Extractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testServiceId() {
|
||||
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testName() throws Exception {
|
||||
assertEquals("EminemVEVO", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId() throws Exception {
|
||||
assertEquals("UC20vb-R_px4CguHzzBPhoyQ", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://www.youtube.com/channel/UC20vb-R_px4CguHzzBPhoyQ", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://www.youtube.com/user/EminemVEVO/", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
defaultTestMoreItems(extractor);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ChannelExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testDescription() throws Exception {
|
||||
final String description = extractor.getDescription();
|
||||
assertTrue(description, description.contains("Eminem on Vevo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAvatarUrl() throws Exception {
|
||||
String avatarUrl = extractor.getAvatarUrl();
|
||||
assertIsSecureUrl(avatarUrl);
|
||||
assertTrue(avatarUrl, avatarUrl.contains("yt3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBannerUrl() throws Exception {
|
||||
String bannerUrl = extractor.getBannerUrl();
|
||||
assertIsSecureUrl(bannerUrl);
|
||||
assertTrue(bannerUrl, bannerUrl.contains("yt3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFeedUrl() throws Exception {
|
||||
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UC20vb-R_px4CguHzzBPhoyQ", extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriberCount() throws Exception {
|
||||
// there is no "Subscribe" button
|
||||
long subscribers = extractor.getSubscriberCount();
|
||||
assertEquals("Wrong subscriber count", -1, subscribers);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Some VEVO channels will redirect to a new page with a new channel id.
|
||||
* <p>
|
||||
* Though, it isn't a simple redirect, but a redirect instruction embed in the response itself, this
|
||||
* test assure that we account for that.
|
||||
*/
|
||||
public static class RedirectedChannel implements BaseChannelExtractorTest {
|
||||
private static YoutubeChannelExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeChannelExtractor) YouTube
|
||||
.getChannelExtractor("https://www.youtube.com/channel/UCITk7Ky4iE5_xISw9IaHqpQ");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Extractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testServiceId() {
|
||||
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testName() throws Exception {
|
||||
assertEquals("LordiVEVO", extractor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId() throws Exception {
|
||||
assertEquals("UCrxkwepj7-4Wz1wHyfzw-sQ", extractor.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrl() throws ParsingException {
|
||||
assertEquals("https://www.youtube.com/channel/UCrxkwepj7-4Wz1wHyfzw-sQ", extractor.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginalUrl() throws ParsingException {
|
||||
assertEquals("https://www.youtube.com/channel/UCITk7Ky4iE5_xISw9IaHqpQ", extractor.getOriginalUrl());
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ListExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testRelatedItems() throws Exception {
|
||||
defaultTestRelatedItems(extractor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoreRelatedItems() throws Exception {
|
||||
assertNoMoreItems(extractor);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// ChannelExtractor
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Test
|
||||
public void testDescription() throws Exception {
|
||||
assertEmpty(extractor.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAvatarUrl() throws Exception {
|
||||
String avatarUrl = extractor.getAvatarUrl();
|
||||
assertIsSecureUrl(avatarUrl);
|
||||
assertTrue(avatarUrl, avatarUrl.contains("yt3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBannerUrl() throws Exception {
|
||||
assertEmpty(extractor.getBannerUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFeedUrl() throws Exception {
|
||||
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCrxkwepj7-4Wz1wHyfzw-sQ", extractor.getFeedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriberCount() throws Exception {
|
||||
assertEquals(-1, extractor.getSubscriberCount());
|
||||
}
|
||||
}
|
||||
|
||||
public static class RandomChannel implements BaseChannelExtractorTest {
|
||||
private static YoutubeChannelExtractor extractor;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
@@ -30,6 +31,8 @@ public class YoutubeChannelLinkHandlerFactoryTest {
|
||||
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/c/creatoracademy"));
|
||||
|
||||
assertTrue(linkHandler.acceptUrl("https://youtube.com/DIMENSI0N"));
|
||||
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA"));
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1"));
|
||||
|
||||
@@ -44,6 +47,18 @@ public class YoutubeChannelLinkHandlerFactoryTest {
|
||||
|
||||
assertTrue(linkHandler.acceptUrl("https://invidio.us/channel/UClq42foiSgl7sSpLupnugGA"));
|
||||
assertTrue(linkHandler.acceptUrl("https://invidio.us/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1"));
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/watchismo"));
|
||||
|
||||
|
||||
// do not accept URLs which are not channels
|
||||
assertFalse(linkHandler.acceptUrl("https://www.youtube.com/watch?v=jZViOEv90dI&t=100"));
|
||||
assertFalse(linkHandler.acceptUrl("http://www.youtube.com/watch_popup?v=uEJuoEs1UxY"));
|
||||
assertFalse(linkHandler.acceptUrl("http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare"));
|
||||
assertFalse(linkHandler.acceptUrl("https://www.youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1d"));
|
||||
assertFalse(linkHandler.acceptUrl("https://www.youtube.com/embed/jZViOEv90dI"));
|
||||
assertFalse(linkHandler.acceptUrl("https://www.youtube.com/feed/subscriptions?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||
assertFalse(linkHandler.acceptUrl("https://www.youtube.com/?app=desktop&persist_app=1"));
|
||||
assertFalse(linkHandler.acceptUrl("https://m.youtube.com/select_site"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -6,12 +6,15 @@ import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.localization.Localization;
|
||||
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||
import org.schabi.newpipe.extractor.localization.Localization;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
@@ -23,7 +26,7 @@ import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRela
|
||||
@Ignore("Should be ran manually from time to time, as it's too time consuming.")
|
||||
public class YoutubeChannelLocalizationTest {
|
||||
private static final boolean DEBUG = true;
|
||||
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
private final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||
|
||||
@Test
|
||||
public void testAllSupportedLocalizations() throws Exception {
|
||||
@@ -64,7 +67,7 @@ public class YoutubeChannelLocalizationTest {
|
||||
+ "\n:::: " + item.getStreamType() + ", views = " + item.getViewCount();
|
||||
final DateWrapper uploadDate = item.getUploadDate();
|
||||
if (uploadDate != null) {
|
||||
String dateAsText = dateFormat.format(uploadDate.date().getTime());
|
||||
String dateAsText = dateTimeFormatter.format(uploadDate.offsetDateTime());
|
||||
debugMessage += "\n:::: " + item.getTextualUploadDate() +
|
||||
"\n:::: " + dateAsText;
|
||||
}
|
||||
@@ -107,13 +110,13 @@ public class YoutubeChannelLocalizationTest {
|
||||
final DateWrapper currentUploadDate = currentItem.getUploadDate();
|
||||
|
||||
final String referenceDateString = referenceUploadDate == null ? "null" :
|
||||
dateFormat.format(referenceUploadDate.date().getTime());
|
||||
dateTimeFormatter.format(referenceUploadDate.offsetDateTime());
|
||||
final String currentDateString = currentUploadDate == null ? "null" :
|
||||
dateFormat.format(currentUploadDate.date().getTime());
|
||||
dateTimeFormatter.format(currentUploadDate.offsetDateTime());
|
||||
|
||||
long difference = -1;
|
||||
if (referenceUploadDate != null && currentUploadDate != null) {
|
||||
difference = Math.abs(referenceUploadDate.date().getTimeInMillis() - currentUploadDate.date().getTimeInMillis());
|
||||
difference = ChronoUnit.MILLIS.between(referenceUploadDate.offsetDateTime(), currentUploadDate.offsetDateTime());
|
||||
}
|
||||
|
||||
final boolean areTimeEquals = difference < 5 * 60 * 1000L;
|
||||
|
||||
@@ -23,91 +23,133 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
public class YoutubeCommentsExtractorTest {
|
||||
private static final String urlYT = "https://www.youtube.com/watch?v=D00Au7k3i6o";
|
||||
private static final String urlInvidious = "https://invidio.us/watch?v=D00Au7k3i6o";
|
||||
private static YoutubeCommentsExtractor extractorYT;
|
||||
private static YoutubeCommentsExtractor extractorInvidious;
|
||||
/**
|
||||
* Test a "normal" YouTube
|
||||
*/
|
||||
public static class Thomas {
|
||||
private static final String url = "https://www.youtube.com/watch?v=D00Au7k3i6o";
|
||||
private static YoutubeCommentsExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractorYT = (YoutubeCommentsExtractor) YouTube
|
||||
.getCommentsExtractor(urlYT);
|
||||
extractorYT.fetchPage();
|
||||
extractorInvidious = (YoutubeCommentsExtractor) YouTube
|
||||
.getCommentsExtractor(urlInvidious);
|
||||
}
|
||||
private static final String commentContent = "sub 4 sub";
|
||||
|
||||
@Test
|
||||
public void testGetComments() throws IOException, ExtractionException {
|
||||
assertTrue(getCommentsHelper(extractorYT));
|
||||
assertTrue(getCommentsHelper(extractorInvidious));
|
||||
}
|
||||
|
||||
private boolean getCommentsHelper(YoutubeCommentsExtractor extractor) throws IOException, ExtractionException {
|
||||
InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage();
|
||||
boolean result = findInComments(comments, "s1ck m3m3");
|
||||
|
||||
while (comments.hasNextPage() && !result) {
|
||||
comments = extractor.getPage(comments.getNextPage());
|
||||
result = findInComments(comments, "s1ck m3m3");
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeCommentsExtractor) YouTube
|
||||
.getCommentsExtractor(url);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCommentsFromCommentsInfo() throws IOException, ExtractionException {
|
||||
assertTrue(getCommentsFromCommentsInfoHelper(urlYT));
|
||||
assertTrue(getCommentsFromCommentsInfoHelper(urlInvidious));
|
||||
}
|
||||
|
||||
private boolean getCommentsFromCommentsInfoHelper(String url) throws IOException, ExtractionException {
|
||||
CommentsInfo commentsInfo = CommentsInfo.getInfo(url);
|
||||
|
||||
assertEquals("Comments", commentsInfo.getName());
|
||||
boolean result = findInComments(commentsInfo.getRelatedItems(), "s1ck m3m3");
|
||||
|
||||
Page nextPage = commentsInfo.getNextPage();
|
||||
InfoItemsPage<CommentsInfoItem> moreItems = new InfoItemsPage<>(null, nextPage, null);
|
||||
while (moreItems.hasNextPage() && !result) {
|
||||
moreItems = CommentsInfo.getMoreItems(YouTube, commentsInfo, nextPage);
|
||||
result = findInComments(moreItems.getItems(), "s1ck m3m3");
|
||||
nextPage = moreItems.getNextPage();
|
||||
@Test
|
||||
public void testGetComments() throws IOException, ExtractionException {
|
||||
assertTrue(getCommentsHelper(extractor));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCommentsAllData() throws IOException, ExtractionException {
|
||||
InfoItemsPage<CommentsInfoItem> comments = extractorYT.getInitialPage();
|
||||
private boolean getCommentsHelper(YoutubeCommentsExtractor extractor) throws IOException, ExtractionException {
|
||||
InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage();
|
||||
boolean result = findInComments(comments, commentContent);
|
||||
|
||||
DefaultTests.defaultTestListOfItems(YouTube, comments.getItems(), comments.getErrors());
|
||||
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.getCommentText()));
|
||||
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);
|
||||
while (comments.hasNextPage() && !result) {
|
||||
comments = extractor.getPage(comments.getNextPage());
|
||||
result = findInComments(comments, commentContent);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean findInComments(InfoItemsPage<CommentsInfoItem> comments, String comment) {
|
||||
return findInComments(comments.getItems(), comment);
|
||||
}
|
||||
@Test
|
||||
public void testGetCommentsFromCommentsInfo() throws IOException, ExtractionException {
|
||||
assertTrue(getCommentsFromCommentsInfoHelper(url));
|
||||
}
|
||||
|
||||
private boolean findInComments(List<CommentsInfoItem> comments, String comment) {
|
||||
for (CommentsInfoItem c : comments) {
|
||||
if (c.getCommentText().contains(comment)) {
|
||||
return true;
|
||||
private boolean getCommentsFromCommentsInfoHelper(String url) throws IOException, ExtractionException {
|
||||
final CommentsInfo commentsInfo = CommentsInfo.getInfo(url);
|
||||
|
||||
assertEquals("Comments", commentsInfo.getName());
|
||||
boolean result = findInComments(commentsInfo.getRelatedItems(), commentContent);
|
||||
|
||||
Page nextPage = commentsInfo.getNextPage();
|
||||
InfoItemsPage<CommentsInfoItem> moreItems = new InfoItemsPage<>(null, nextPage, null);
|
||||
while (moreItems.hasNextPage() && !result) {
|
||||
moreItems = CommentsInfo.getMoreItems(YouTube, commentsInfo, nextPage);
|
||||
result = findInComments(moreItems.getItems(), commentContent);
|
||||
nextPage = moreItems.getNextPage();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCommentsAllData() throws IOException, ExtractionException {
|
||||
InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage();
|
||||
|
||||
DefaultTests.defaultTestListOfItems(YouTube, comments.getItems(), comments.getErrors());
|
||||
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.getCommentText()));
|
||||
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);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
private boolean findInComments(InfoItemsPage<CommentsInfoItem> comments, String comment) {
|
||||
return findInComments(comments.getItems(), comment);
|
||||
}
|
||||
|
||||
private boolean findInComments(List<CommentsInfoItem> comments, String comment) {
|
||||
for (CommentsInfoItem c : comments) {
|
||||
if (c.getCommentText().contains(comment)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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";
|
||||
|
||||
@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());
|
||||
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);
|
||||
if (c.getCommentId().equals("Ugga_h1-EXdHB3gCoAEC")) { // comment without text
|
||||
assertTrue(Utils.isBlank(c.getCommentText()));
|
||||
} else {
|
||||
assertFalse(Utils.isBlank(c.getCommentText()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,15 @@ public class YoutubeStreamLinkHandlerFactoryTest {
|
||||
assertEquals("jZViOEv90dI", linkHandler.fromUrl("vnd.youtube:jZViOEv90dI").getId());
|
||||
assertEquals("n8X9_MgEdCg", linkHandler.fromUrl("vnd.youtube://n8X9_MgEdCg").getId());
|
||||
assertEquals("O0EDx9WAelc", linkHandler.fromUrl("https://music.youtube.com/watch?v=O0EDx9WAelc").getId());
|
||||
assertEquals("-cdveCh1kQk", linkHandler.fromUrl("https://m.youtube.com/watch?v=-cdveCh1kQk)").getId());
|
||||
assertEquals("-cdveCh1kQk", linkHandler.fromUrl("https://www.youtube.com/watch?v=-cdveCh1kQk-").getId());
|
||||
assertEquals("-cdveCh1kQk", linkHandler.fromUrl("https://WWW.YouTube.com/watch?v=-cdveCh1kQkwhatever").getId());
|
||||
assertEquals("O0EDx9WAelc", linkHandler.fromUrl("HTTPS://www.youtube.com/watch?v=O0EDx9WAelc]").getId());
|
||||
assertEquals("-cdveCh1kQk", linkHandler.fromUrl("https://youtu.be/-cdveCh1kQk)hello").getId());
|
||||
assertEquals("OGS7c0-CmRs", linkHandler.fromUrl("https://YouTu.be/OGS7c0-CmRswhatever)").getId());
|
||||
assertEquals("-cdveCh1kQk", linkHandler.fromUrl("HTTPS://youtu.be/-cdveCh1kQk)").getId());
|
||||
assertEquals("IOS2fqxwYbA", linkHandler.fromUrl("https://www.youtube.com/shorts/IOS2fqxwYbAhi").getId());
|
||||
assertEquals("IOS2fqxwYbA", linkHandler.fromUrl("http://www.youtube.com/shorts/IOS2fqxwYbA").getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,6 +110,7 @@ public class YoutubeStreamLinkHandlerFactoryTest {
|
||||
assertTrue(linkHandler.acceptUrl("vnd.youtube:jZViOEv90dI"));
|
||||
assertTrue(linkHandler.acceptUrl("vnd.youtube.launch:jZViOEv90dI"));
|
||||
assertTrue(linkHandler.acceptUrl("https://music.youtube.com/watch?v=O0EDx9WAelc"));
|
||||
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/shorts/IOS2fqxwYbA"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -11,12 +11,16 @@ import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||
import org.schabi.newpipe.extractor.subscription.SubscriptionItem;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.schabi.newpipe.FileUtils.resolveTestResource;
|
||||
|
||||
/**
|
||||
* Test for {@link YoutubeSubscriptionExtractor}
|
||||
@@ -34,54 +38,48 @@ public class YoutubeSubscriptionExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testFromInputStream() throws Exception {
|
||||
File testFile = new File("extractor/src/test/resources/youtube_export_test.xml");
|
||||
if (!testFile.exists()) testFile = new File("src/test/resources/youtube_export_test.xml");
|
||||
final List<SubscriptionItem> subscriptionItems = subscriptionExtractor.fromInputStream(
|
||||
new FileInputStream(resolveTestResource("youtube_takeout_import_test.json")));
|
||||
assertEquals(7, subscriptionItems.size());
|
||||
|
||||
List<SubscriptionItem> subscriptionItems = subscriptionExtractor.fromInputStream(new FileInputStream(testFile));
|
||||
assertTrue("List doesn't have exactly 8 items (had " + subscriptionItems.size() + ")", subscriptionItems.size() == 8);
|
||||
|
||||
for (SubscriptionItem item : subscriptionItems) {
|
||||
for (final SubscriptionItem item : subscriptionItems) {
|
||||
assertNotNull(item.getName());
|
||||
assertNotNull(item.getUrl());
|
||||
assertTrue(urlHandler.acceptUrl(item.getUrl()));
|
||||
assertFalse(item.getServiceId() == -1);
|
||||
assertEquals(ServiceList.YouTube.getServiceId(), item.getServiceId());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptySourceException() throws Exception {
|
||||
String emptySource = "<opml version=\"1.1\"><body>" +
|
||||
"<outline text=\"Testing\" title=\"123\" />" +
|
||||
"</body></opml>";
|
||||
|
||||
List<SubscriptionItem> items = subscriptionExtractor.fromInputStream(new ByteArrayInputStream(emptySource.getBytes("UTF-8")));
|
||||
final List<SubscriptionItem> items = subscriptionExtractor.fromInputStream(
|
||||
new ByteArrayInputStream("[]".getBytes(StandardCharsets.UTF_8)));
|
||||
assertTrue(items.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriptionWithEmptyTitleInSource() throws Exception {
|
||||
String channelId = "AA0AaAa0AaaaAAAAAA0aa0AA";
|
||||
String source = "<opml version=\"1.1\"><body><outline text=\"YouTube Subscriptions\" title=\"YouTube Subscriptions\">" +
|
||||
"<outline text=\"\" title=\"\" type=\"rss\" xmlUrl=\"https://www.youtube.com/feeds/videos.xml?channel_id=" + channelId + "\" />" +
|
||||
"</outline></body></opml>";
|
||||
final String source = "[{\"snippet\":{\"resourceId\":{\"channelId\":\"UCEOXxzW2vU0P-0THehuIIeg\"}}}]";
|
||||
final List<SubscriptionItem> items = subscriptionExtractor.fromInputStream(
|
||||
new ByteArrayInputStream(source.getBytes(StandardCharsets.UTF_8)));
|
||||
|
||||
List<SubscriptionItem> items = subscriptionExtractor.fromInputStream(new ByteArrayInputStream(source.getBytes("UTF-8")));
|
||||
assertTrue("List doesn't have exactly 1 item (had " + items.size() + ")", items.size() == 1);
|
||||
assertTrue("Item does not have an empty title (had \"" + items.get(0).getName() + "\")", items.get(0).getName().isEmpty());
|
||||
assertTrue("Item does not have the right channel id \"" + channelId + "\" (the whole url is \"" + items.get(0).getUrl() + "\")", items.get(0).getUrl().endsWith(channelId));
|
||||
assertEquals(1, items.size());
|
||||
assertEquals(ServiceList.YouTube.getServiceId(), items.get(0).getServiceId());
|
||||
assertEquals("https://www.youtube.com/channel/UCEOXxzW2vU0P-0THehuIIeg", items.get(0).getUrl());
|
||||
assertEquals("", items.get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriptionWithInvalidUrlInSource() throws Exception {
|
||||
String source = "<opml version=\"1.1\"><body><outline text=\"YouTube Subscriptions\" title=\"YouTube Subscriptions\">" +
|
||||
"<outline text=\"invalid\" title=\"url\" type=\"rss\" xmlUrl=\"https://www.youtube.com/feeds/videos.xml?channel_not_id=|||||||\"/>" +
|
||||
"<outline text=\"fail\" title=\"fail\" type=\"rss\" xmlUgrl=\"invalidTag\"/>" +
|
||||
"<outline text=\"invalid\" title=\"url\" type=\"rss\" xmlUrl=\"\"/>" +
|
||||
"<outline text=\"\" title=\"\" type=\"rss\" xmlUrl=\"\"/>" +
|
||||
"</outline></body></opml>";
|
||||
final String source = "[{\"snippet\":{\"resourceId\":{\"channelId\":\"gibberish\"},\"title\":\"name1\"}}," +
|
||||
"{\"snippet\":{\"resourceId\":{\"channelId\":\"UCEOXxzW2vU0P-0THehuIIeg\"},\"title\":\"name2\"}}]";
|
||||
final List<SubscriptionItem> items = subscriptionExtractor.fromInputStream(
|
||||
new ByteArrayInputStream(source.getBytes(StandardCharsets.UTF_8)));
|
||||
|
||||
List<SubscriptionItem> items = subscriptionExtractor.fromInputStream(new ByteArrayInputStream(source.getBytes("UTF-8")));
|
||||
assertTrue(items.isEmpty());
|
||||
assertEquals(1, items.size());
|
||||
assertEquals(ServiceList.YouTube.getServiceId(), items.get(0).getServiceId());
|
||||
assertEquals("https://www.youtube.com/channel/UCEOXxzW2vU0P-0THehuIIeg", items.get(0).getUrl());
|
||||
assertEquals("name2", items.get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,26 +87,26 @@ public class YoutubeSubscriptionExtractorTest {
|
||||
List<String> invalidList = Arrays.asList(
|
||||
"<xml><notvalid></notvalid></xml>",
|
||||
"<opml><notvalid></notvalid></opml>",
|
||||
"<opml><body></body></opml>",
|
||||
"{\"a\":\"b\"}",
|
||||
"[{}]",
|
||||
"[\"\", 5]",
|
||||
"[{\"snippet\":{\"title\":\"name\"}}]",
|
||||
"[{\"snippet\":{\"resourceId\":{\"channelId\":\"gibberish\"}}}]",
|
||||
"",
|
||||
null,
|
||||
"\uD83D\uDC28\uD83D\uDC28\uD83D\uDC28",
|
||||
"gibberish");
|
||||
|
||||
for (String invalidContent : invalidList) {
|
||||
try {
|
||||
if (invalidContent != null) {
|
||||
byte[] bytes = invalidContent.getBytes("UTF-8");
|
||||
subscriptionExtractor.fromInputStream(new ByteArrayInputStream(bytes));
|
||||
fail("Extracting from \"" + invalidContent + "\" didn't throw an exception");
|
||||
} else {
|
||||
subscriptionExtractor.fromInputStream(null);
|
||||
fail("Extracting from null String didn't throw an exception");
|
||||
byte[] bytes = invalidContent.getBytes(StandardCharsets.UTF_8);
|
||||
subscriptionExtractor.fromInputStream(new ByteArrayInputStream(bytes));
|
||||
fail("Extracting from \"" + invalidContent + "\" didn't throw an exception");
|
||||
} catch (final Exception e) {
|
||||
boolean correctType = e instanceof SubscriptionExtractor.InvalidSourceException;
|
||||
if (!correctType) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// System.out.println(" -> " + e);
|
||||
boolean isExpectedException = e instanceof SubscriptionExtractor.InvalidSourceException;
|
||||
assertTrue("\"" + e.getClass().getSimpleName() + "\" is not the expected exception", isExpectedException);
|
||||
assertTrue(e.getClass().getSimpleName() + " is not InvalidSourceException", correctType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,8 +153,8 @@ public class YoutubeMusicSearchExtractorTest {
|
||||
|
||||
public static class CorrectedSearch extends DefaultSearchExtractorTest {
|
||||
private static SearchExtractor extractor;
|
||||
private static final String QUERY = "duo lipa";
|
||||
private static final String EXPECTED_SUGGESTION = "dua lipa";
|
||||
private static final String QUERY = "nocopyrigh sounds";
|
||||
private static final String EXPECTED_SUGGESTION = "nocopyrightsounds";
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
|
||||
@@ -1,144 +1,53 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube.stream;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.MediaFormat;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
/**
|
||||
* Test for {@link YoutubeStreamLinkHandlerFactory}
|
||||
*/
|
||||
public class YoutubeStreamExtractorAgeRestrictedTest {
|
||||
public static final String HTTPS = "https://";
|
||||
private static YoutubeStreamExtractor extractor;
|
||||
public class YoutubeStreamExtractorAgeRestrictedTest extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "MmBeUZqv1QA";
|
||||
private static final int TIMESTAMP = 196;
|
||||
private static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID + "&t=" + TIMESTAMP;
|
||||
private static StreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=MmBeUZqv1QA");
|
||||
extractor = YouTube.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInvalidTimeStamp() throws ParsingException {
|
||||
assertTrue(extractor.getTimeStamp() + "", extractor.getTimeStamp() <= 0);
|
||||
}
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return YouTube; }
|
||||
@Override public String expectedName() { return "FINGERING PORNSTARS @ AVN Expo 2017 In Las Vegas!"; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return YoutubeStreamExtractorDefaultTest.BASE_URL + ID; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Test
|
||||
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
||||
StreamExtractor extractor = YouTube.getStreamExtractor("https://youtu.be/FmG385_uUys?t=174");
|
||||
assertEquals(extractor.getTimeStamp() + "", "174");
|
||||
extractor = YouTube.getStreamExtractor("https://youtube.com/embed/FmG385_uUys?start=174");
|
||||
assertEquals(extractor.getTimeStamp() + "", "174");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAgeLimit() throws ParsingException {
|
||||
assertEquals(18, extractor.getAgeLimit());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetName() throws ParsingException {
|
||||
assertNotNull("name is null", extractor.getName());
|
||||
assertFalse("name is empty", extractor.getName().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDescription() throws ParsingException {
|
||||
assertNotNull(extractor.getDescription());
|
||||
assertFalse(extractor.getDescription().getContent().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderName() throws ParsingException {
|
||||
assertNotNull(extractor.getUploaderName());
|
||||
assertFalse(extractor.getUploaderName().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLength() throws ParsingException {
|
||||
assertEquals(1790, extractor.getLength());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetViews() throws ParsingException {
|
||||
assertTrue(extractor.getViewCount() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTextualUploadDate() throws ParsingException {
|
||||
assertEquals("2017-01-25", extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(new SimpleDateFormat("yyyy-MM-dd").parse("2017-01-25"));
|
||||
assertEquals(instance, requireNonNull(extractor.getUploadDate()).date());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetThumbnailUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAudioStreams() throws IOException, ExtractionException {
|
||||
// audio streams are not always necessary
|
||||
assertFalse(extractor.getAudioStreams().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVideoStreams() throws IOException, ExtractionException {
|
||||
List<VideoStream> streams = new ArrayList<>();
|
||||
streams.addAll(extractor.getVideoStreams());
|
||||
streams.addAll(extractor.getVideoOnlyStreams());
|
||||
|
||||
assertTrue(Integer.toString(streams.size()), streams.size() > 0);
|
||||
for (VideoStream s : streams) {
|
||||
assertTrue(s.getUrl(),
|
||||
s.getUrl().contains(HTTPS));
|
||||
assertTrue(s.resolution.length() > 0);
|
||||
assertTrue(Integer.toString(s.getFormatId()),
|
||||
0 <= s.getFormatId() && s.getFormatId() <= 0x100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesListDefault() throws IOException, ExtractionException {
|
||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||
assertTrue(extractor.getSubtitlesDefault().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesList() throws IOException, ExtractionException {
|
||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||
assertTrue(extractor.getSubtitles(MediaFormat.TTML).isEmpty());
|
||||
}
|
||||
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "EpicFiveTV"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCuPUHlLP5POZphOIrjrNxiw"; }
|
||||
@Override public List<String> expectedDescriptionContains() { return Arrays.asList("http://instagram.com/Ruben_Sole", "AVN"); }
|
||||
@Override public long expectedLength() { return 1790; }
|
||||
@Override public long expectedTimestamp() { return TIMESTAMP; }
|
||||
@Override public long expectedViewCountAtLeast() { return 28500000; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2017-01-25 00:00:00.000"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2017-01-25"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return 149000; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return 38000; }
|
||||
@Override public boolean expectedHasRelatedStreams() { return false; } // no related videos (!)
|
||||
@Override public int expectedAgeLimit() { return 18; }
|
||||
@Nullable @Override public String expectedErrorMessage() { return "Sign in to confirm your age"; }
|
||||
@Override public boolean expectedHasSubtitles() { return false; }
|
||||
}
|
||||
|
||||
@@ -1,134 +1,54 @@
|
||||
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.extractor.MediaFormat;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
/**
|
||||
* Test for {@link YoutubeStreamLinkHandlerFactory}
|
||||
*/
|
||||
public class YoutubeStreamExtractorControversialTest {
|
||||
private static YoutubeStreamExtractor extractor;
|
||||
public class YoutubeStreamExtractorControversialTest extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "T4XJQO3qol8";
|
||||
private static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID;
|
||||
private static StreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=T4XJQO3qol8");
|
||||
extractor = YouTube.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInvalidTimeStamp() throws ParsingException {
|
||||
assertTrue(extractor.getTimeStamp() + "", extractor.getTimeStamp() <= 0);
|
||||
}
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return YouTube; }
|
||||
@Override public String expectedName() { return "Burning Everyone's Koran"; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return URL; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Test
|
||||
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
||||
StreamExtractor extractor = YouTube.getStreamExtractor("https://youtu.be/FmG385_uUys?t=174");
|
||||
assertEquals(extractor.getTimeStamp() + "", "174");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testGetAgeLimit() throws ParsingException {
|
||||
assertEquals(18, extractor.getAgeLimit());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetName() throws ParsingException {
|
||||
assertNotNull("name is null", extractor.getName());
|
||||
assertFalse("name is empty", extractor.getName().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDescription() throws ParsingException {
|
||||
assertNotNull(extractor.getDescription());
|
||||
assertFalse(extractor.getDescription().getContent().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderName() throws ParsingException {
|
||||
assertNotNull(extractor.getUploaderName());
|
||||
assertFalse(extractor.getUploaderName().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLength() throws ParsingException {
|
||||
assertEquals(219, extractor.getLength());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetViews() throws ParsingException {
|
||||
assertTrue(extractor.getViewCount() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTextualUploadDate() throws ParsingException {
|
||||
assertEquals("2010-09-09", extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(new SimpleDateFormat("yyyy-MM-dd").parse("2010-09-09"));
|
||||
assertEquals(instance, requireNonNull(extractor.getUploadDate()).date());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetThumbnailUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAudioStreams() throws IOException, ExtractionException {
|
||||
// audio streams are not always necessary
|
||||
assertFalse(extractor.getAudioStreams().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVideoStreams() throws IOException, ExtractionException {
|
||||
List<VideoStream> streams = new ArrayList<>();
|
||||
streams.addAll(extractor.getVideoStreams());
|
||||
streams.addAll(extractor.getVideoOnlyStreams());
|
||||
assertTrue(streams.size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesListDefault() throws IOException, ExtractionException {
|
||||
// Video (/view?v=T4XJQO3qol8) set in the setUp() method has at least auto-generated (English) captions
|
||||
assertFalse(extractor.getSubtitlesDefault().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesList() throws IOException, ExtractionException {
|
||||
// Video (/view?v=T4XJQO3qol8) set in the setUp() method has at least auto-generated (English) captions
|
||||
assertFalse(extractor.getSubtitles(MediaFormat.TTML).isEmpty());
|
||||
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "Amazing Atheist"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCjNxszyFPasDdRoD9J6X-sw"; }
|
||||
@Override public List<String> expectedDescriptionContains() {
|
||||
return Arrays.asList("http://www.huffingtonpost.com/2010/09/09/obama-gma-interview-quran_n_710282.html",
|
||||
"freedom");
|
||||
}
|
||||
@Override public long expectedLength() { return 219; }
|
||||
@Override public long expectedViewCountAtLeast() { return 285000; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2010-09-09 00:00:00.000"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2010-09-09"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return 13300; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return 2600; }
|
||||
}
|
||||
|
||||
@@ -1,35 +1,22 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube.stream;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ExtractorAsserts;
|
||||
import org.schabi.newpipe.extractor.MediaFormat;
|
||||
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.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.Frameset;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
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 javax.annotation.Nullable;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
/*
|
||||
@@ -51,11 +38,8 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test for {@link StreamExtractor}
|
||||
*/
|
||||
public class YoutubeStreamExtractorDefaultTest {
|
||||
static final String BASE_URL = "https://www.youtube.com/watch?v=";
|
||||
|
||||
public static class NotAvailable {
|
||||
@BeforeClass
|
||||
@@ -66,266 +50,120 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||
@Test(expected = ContentNotAvailableException.class)
|
||||
public void nonExistentFetch() throws Exception {
|
||||
final StreamExtractor extractor =
|
||||
YouTube.getStreamExtractor("https://www.youtube.com/watch?v=don-t-exist");
|
||||
YouTube.getStreamExtractor(BASE_URL + "don-t-exist");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test(expected = ParsingException.class)
|
||||
public void invalidId() throws Exception {
|
||||
final StreamExtractor extractor =
|
||||
YouTube.getStreamExtractor("https://www.youtube.com/watch?v=INVALID_ID_INVALID_ID");
|
||||
YouTube.getStreamExtractor(BASE_URL + "INVALID_ID_INVALID_ID");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for {@link StreamExtractor}
|
||||
*/
|
||||
public static class AdeleHello {
|
||||
private static YoutubeStreamExtractor extractor;
|
||||
public static class DescriptionTestPewdiepie extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "7PIMiDcwNvc";
|
||||
private static final int TIMESTAMP = 17;
|
||||
private static final String URL = BASE_URL + ID + "&t=" + TIMESTAMP;
|
||||
private static StreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=YQHsXMglC9A");
|
||||
extractor = YouTube.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInvalidTimeStamp() throws ParsingException {
|
||||
assertTrue(extractor.getTimeStamp() + "",
|
||||
extractor.getTimeStamp() <= 0);
|
||||
}
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return YouTube; }
|
||||
@Override public String expectedName() { return "Marzia & Felix - Wedding 19.08.2019"; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return BASE_URL + ID; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Test
|
||||
public void testGetValidTimeStamp() throws ExtractionException {
|
||||
StreamExtractor extractor = YouTube.getStreamExtractor("https://youtu.be/FmG385_uUys?t=174");
|
||||
assertEquals(extractor.getTimeStamp() + "", "174");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTitle() throws ParsingException {
|
||||
assertFalse(extractor.getName().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDescription() throws ParsingException {
|
||||
assertNotNull(extractor.getDescription());
|
||||
assertFalse(extractor.getDescription().getContent().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFullLinksInDescription() throws ParsingException {
|
||||
assertTrue(extractor.getDescription().getContent().contains("http://adele.com"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderName() throws ParsingException {
|
||||
assertNotNull(extractor.getUploaderName());
|
||||
assertFalse(extractor.getUploaderName().isEmpty());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetLength() throws ParsingException {
|
||||
assertEquals(367, extractor.getLength());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetViewCount() throws ParsingException {
|
||||
Long count = extractor.getViewCount();
|
||||
assertTrue(Long.toString(count), count >= /* specific to that video */ 1220025784);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTextualUploadDate() throws ParsingException {
|
||||
Assert.assertEquals("2015-10-22", extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(new SimpleDateFormat("yyyy-MM-dd").parse("2015-10-22"));
|
||||
assertEquals(instance, requireNonNull(extractor.getUploadDate()).date());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderUrl() throws ParsingException {
|
||||
String url = extractor.getUploaderUrl();
|
||||
if (!url.equals("https://www.youtube.com/channel/UCsRM0YB_dabtEPGPTKo-gcw") &&
|
||||
!url.equals("https://www.youtube.com/channel/UComP_epzeKzvBX156r6pm1Q")) {
|
||||
fail("Uploader url is neither the music channel one nor the Vevo one");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetThumbnailUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAudioStreams() throws ExtractionException {
|
||||
assertFalse(extractor.getAudioStreams().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVideoStreams() throws ExtractionException {
|
||||
for (VideoStream s : extractor.getVideoStreams()) {
|
||||
assertIsSecureUrl(s.url);
|
||||
assertTrue(s.resolution.length() > 0);
|
||||
assertTrue(Integer.toString(s.getFormatId()),
|
||||
0 <= s.getFormatId() && s.getFormatId() <= 0x100);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamType() throws ParsingException {
|
||||
assertTrue(extractor.getStreamType() == StreamType.VIDEO_STREAM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDashMpd() throws ParsingException {
|
||||
// we dont expect this particular video to have a DASH file. For this purpouse we use a different test class.
|
||||
assertTrue(extractor.getDashMpdUrl(),
|
||||
extractor.getDashMpdUrl() != null && extractor.getDashMpdUrl().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRelatedVideos() throws ExtractionException {
|
||||
StreamInfoItemsCollector relatedVideos = extractor.getRelatedStreams();
|
||||
Utils.printErrors(relatedVideos.getErrors());
|
||||
assertFalse(relatedVideos.getItems().isEmpty());
|
||||
assertTrue(relatedVideos.getErrors().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesListDefault() {
|
||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||
assertTrue(extractor.getSubtitlesDefault().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesList() {
|
||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||
assertTrue(extractor.getSubtitles(MediaFormat.TTML).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLikeCount() throws ParsingException {
|
||||
long likeCount = extractor.getLikeCount();
|
||||
assertTrue("" + likeCount, likeCount >= 15000000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDislikeCount() throws ParsingException {
|
||||
long dislikeCount = extractor.getDislikeCount();
|
||||
assertTrue("" + dislikeCount, dislikeCount >= 818000);
|
||||
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "PewDiePie"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UC-lHJZR3Gqxm24_Vd_AJ5Yw"; }
|
||||
@Override public List<String> expectedDescriptionContains() {
|
||||
return Arrays.asList("https://www.youtube.com/channel/UC7l23W7gFi4Uho6WSzckZRA",
|
||||
"https://www.handcraftpictures.com/");
|
||||
}
|
||||
@Override public long expectedLength() { return 381; }
|
||||
@Override public long expectedTimestamp() { return TIMESTAMP; }
|
||||
@Override public long expectedViewCountAtLeast() { return 26682500; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2019-08-24 00:00:00.000"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2019-08-24"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return 5212900; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return 30600; }
|
||||
}
|
||||
|
||||
public static class DescriptionTestPewdiepie {
|
||||
private static YoutubeStreamExtractor extractor;
|
||||
public static class DescriptionTestUnboxing extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "cV5TjZCJkuA";
|
||||
private static final String URL = BASE_URL + ID;
|
||||
private static StreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=fBc4Q_htqPg");
|
||||
extractor = YouTube.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDescription() throws ParsingException {
|
||||
assertNotNull(extractor.getDescription());
|
||||
assertFalse(extractor.getDescription().getContent().isEmpty());
|
||||
}
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return YouTube; }
|
||||
@Override public String expectedName() { return "This Smartphone Changes Everything..."; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return URL; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Test
|
||||
public void testGetFullLinksInDescription() throws ParsingException {
|
||||
assertTrue(extractor.getDescription().getContent().contains("https://www.reddit.com/r/PewdiepieSubmissions/"));
|
||||
assertTrue(extractor.getDescription().getContent().contains("https://www.youtube.com/channel/UC3e8EMTOn4g6ZSKggHTnNng"));
|
||||
assertTrue(extractor.getDescription().getContent().contains("https://usa.clutchchairz.com/product/pewdiepie-edition-throttle-series/"));
|
||||
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "Unbox Therapy"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCsTcErHg8oDvUnTzoqsYeNw"; }
|
||||
@Override public List<String> expectedDescriptionContains() {
|
||||
return Arrays.asList("https://www.youtube.com/watch?v=X7FLCHVXpsA&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34",
|
||||
"https://www.youtube.com/watch?v=Lqv6G0pDNnw&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34",
|
||||
"https://www.youtube.com/watch?v=XxaRBPyrnBU&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34",
|
||||
"https://www.youtube.com/watch?v=U-9tUEOFKNU&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34");
|
||||
}
|
||||
@Override public long expectedLength() { return 434; }
|
||||
@Override public long expectedViewCountAtLeast() { return 21229200; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2018-06-19 00:00:00.000"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2018-06-19"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return 340100; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return 18700; }
|
||||
}
|
||||
|
||||
public static class DescriptionTestUnboxing {
|
||||
private static YoutubeStreamExtractor extractor;
|
||||
public static class RatingsDisabledTest extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "HRKu0cvrr_o";
|
||||
private static final int TIMESTAMP = 17;
|
||||
private static final String URL = BASE_URL + ID + "&t=" + TIMESTAMP;
|
||||
private static StreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=cV5TjZCJkuA");
|
||||
extractor = YouTube.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDescription() throws ParsingException {
|
||||
assertNotNull(extractor.getDescription());
|
||||
assertFalse(extractor.getDescription().getContent().isEmpty());
|
||||
}
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return YouTube; }
|
||||
@Override public String expectedName() { return "AlphaOmegaSin Fanboy Logic: Likes/Dislikes Disabled = Point Invalid Lol wtf?"; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return BASE_URL + ID; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Test
|
||||
public void testGetFullLinksInDescription() throws ParsingException {
|
||||
final String description = extractor.getDescription().getContent();
|
||||
assertTrue(description.contains("https://www.youtube.com/watch?v=X7FLCHVXpsA&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34"));
|
||||
assertTrue(description.contains("https://www.youtube.com/watch?v=Lqv6G0pDNnw&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34"));
|
||||
assertTrue(description.contains("https://www.youtube.com/watch?v=XxaRBPyrnBU&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34"));
|
||||
assertTrue(description.contains("https://www.youtube.com/watch?v=U-9tUEOFKNU&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34"));
|
||||
}
|
||||
}
|
||||
|
||||
public static class RatingsDisabledTest {
|
||||
private static YoutubeStreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=HRKu0cvrr_o");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLikeCount() throws ParsingException {
|
||||
assertEquals(-1, extractor.getLikeCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDislikeCount() throws ParsingException {
|
||||
assertEquals(-1, extractor.getDislikeCount());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class FramesTest {
|
||||
private static YoutubeStreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=HoK9shIJ2xQ");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFrames() throws ExtractionException {
|
||||
final List<Frameset> frames = extractor.getFrames();
|
||||
assertNotNull(frames);
|
||||
assertFalse(frames.isEmpty());
|
||||
for (final Frameset f : frames) {
|
||||
for (final String url : f.getUrls()) {
|
||||
ExtractorAsserts.assertIsValidUrl(url);
|
||||
ExtractorAsserts.assertIsSecureUrl(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "YouTuber PrinceOfFALLEN"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCQT2yul0lr6Ie9qNQNmw-sg"; }
|
||||
@Override public List<String> expectedDescriptionContains() { return Arrays.asList("dislikes", "Alpha", "wrong"); }
|
||||
@Override public long expectedLength() { return 84; }
|
||||
@Override public long expectedTimestamp() { return TIMESTAMP; }
|
||||
@Override public long expectedViewCountAtLeast() { return 190; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2019-01-02 00:00:00.000"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2019-01-02"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return -1; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return -1; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,139 +1,55 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube.stream;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.MediaFormat;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
public class YoutubeStreamExtractorLivestreamTest {
|
||||
private static YoutubeStreamExtractor extractor;
|
||||
public class YoutubeStreamExtractorLivestreamTest extends DefaultStreamExtractorTest {
|
||||
private static final String ID = "5qap5aO4i9A";
|
||||
private static final int TIMESTAMP = 1737;
|
||||
private static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID + "&t=" + TIMESTAMP;
|
||||
private static StreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=5qap5aO4i9A");
|
||||
extractor = YouTube.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInvalidTimeStamp() throws ParsingException {
|
||||
assertTrue(extractor.getTimeStamp() + "",
|
||||
extractor.getTimeStamp() <= 0);
|
||||
}
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return YouTube; }
|
||||
@Override public String expectedName() { return "lofi hip hop radio - beats to relax/study to"; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return YoutubeStreamExtractorDefaultTest.BASE_URL + ID; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Test
|
||||
public void testGetTitle() throws ParsingException {
|
||||
assertFalse(extractor.getName().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDescription() throws ParsingException {
|
||||
assertNotNull(extractor.getDescription());
|
||||
assertFalse(extractor.getDescription().getContent().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFullLinksInDescription() throws ParsingException {
|
||||
assertTrue(extractor.getDescription().getContent().contains("https://bit.ly/chilledcow-playlists"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderName() throws ParsingException {
|
||||
assertNotNull(extractor.getUploaderName());
|
||||
assertFalse(extractor.getUploaderName().isEmpty());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetLength() throws ParsingException {
|
||||
assertEquals(0, extractor.getLength());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetViewCount() throws ParsingException {
|
||||
long count = extractor.getViewCount();
|
||||
assertTrue(Long.toString(count), count > -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException {
|
||||
assertNull(extractor.getUploadDate());
|
||||
assertNull(extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderUrl() throws ParsingException {
|
||||
assertEquals("https://www.youtube.com/channel/UCSJ4gkVC6NrvII8umztf0Ow", extractor.getUploaderUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetThumbnailUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAudioStreams() throws ExtractionException {
|
||||
assertFalse(extractor.getAudioStreams().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVideoStreams() throws ExtractionException {
|
||||
for (VideoStream s : extractor.getVideoStreams()) {
|
||||
assertIsSecureUrl(s.url);
|
||||
assertTrue(s.resolution.length() > 0);
|
||||
assertTrue(Integer.toString(s.getFormatId()),
|
||||
0 <= s.getFormatId() && s.getFormatId() <= 0x100);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamType() throws ParsingException {
|
||||
assertSame(extractor.getStreamType(), StreamType.LIVE_STREAM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDashMpd() throws ParsingException {
|
||||
assertTrue(extractor.getDashMpdUrl().startsWith("https://manifest.googlevideo.com/api/manifest/dash/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRelatedVideos() throws ExtractionException {
|
||||
StreamInfoItemsCollector relatedVideos = extractor.getRelatedStreams();
|
||||
Utils.printErrors(relatedVideos.getErrors());
|
||||
assertFalse(relatedVideos.getItems().isEmpty());
|
||||
assertTrue(relatedVideos.getErrors().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesListDefault() {
|
||||
assertTrue(extractor.getSubtitlesDefault().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesList() {
|
||||
assertTrue(extractor.getSubtitles(MediaFormat.TTML).isEmpty());
|
||||
@Override public StreamType expectedStreamType() { return StreamType.LIVE_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "ChilledCow"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCSJ4gkVC6NrvII8umztf0Ow"; }
|
||||
@Override public List<String> expectedDescriptionContains() {
|
||||
return Arrays.asList("https://bit.ly/chilledcow-playlists",
|
||||
"https://bit.ly/chilledcow-submissions");
|
||||
}
|
||||
@Override public long expectedLength() { return 0; }
|
||||
@Override public long expectedTimestamp() { return TIMESTAMP; }
|
||||
@Override public long expectedViewCountAtLeast() { return 0; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2020-02-22 00:00:00.000"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2020-02-22"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return 825000; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return 15600; }
|
||||
@Override public boolean expectedHasSubtitles() { return false; }
|
||||
@Nullable @Override public String expectedDashMpdUrlContains() { return "https://manifest.googlevideo.com/api/manifest/dash/"; }
|
||||
@Override public boolean expectedHasFrames() { return false; }
|
||||
}
|
||||
|
||||
@@ -1,161 +1,50 @@
|
||||
package org.schabi.newpipe.extractor.services.youtube.stream;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.MediaFormat;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
public class YoutubeStreamExtractorUnlistedTest {
|
||||
private static YoutubeStreamExtractor extractor;
|
||||
public class YoutubeStreamExtractorUnlistedTest extends DefaultStreamExtractorTest {
|
||||
static final String ID = "udsB8KnIJTg";
|
||||
static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID;
|
||||
private static StreamExtractor extractor;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
extractor = (YoutubeStreamExtractor) YouTube
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=udsB8KnIJTg");
|
||||
extractor = YouTube.getStreamExtractor(URL);
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInvalidTimeStamp() throws ParsingException {
|
||||
assertTrue(extractor.getTimeStamp() + "",
|
||||
extractor.getTimeStamp() <= 0);
|
||||
}
|
||||
@Override public StreamExtractor extractor() { return extractor; }
|
||||
@Override public StreamingService expectedService() { return YouTube; }
|
||||
@Override public String expectedName() { return "Praise the Casual: Ein Neuling trifft Dark Souls - Folge 5"; }
|
||||
@Override public String expectedId() { return ID; }
|
||||
@Override public String expectedUrlContains() { return URL; }
|
||||
@Override public String expectedOriginalUrlContains() { return URL; }
|
||||
|
||||
@Test
|
||||
public void testGetTitle() throws ParsingException {
|
||||
assertFalse(extractor.getName().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDescription() throws ParsingException {
|
||||
assertNotNull(extractor.getDescription());
|
||||
assertFalse(extractor.getDescription().getContent().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFullLinksInDescription() throws ParsingException {
|
||||
assertTrue(extractor.getDescription().getContent().contains("https://www.youtube.com/user/Roccowschiptune"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderName() throws ParsingException {
|
||||
assertNotNull(extractor.getUploaderName());
|
||||
assertFalse(extractor.getUploaderName().isEmpty());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetLength() throws ParsingException {
|
||||
assertEquals(2488, extractor.getLength());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetViewCount() throws ParsingException {
|
||||
long count = extractor.getViewCount();
|
||||
assertTrue(Long.toString(count), count >= /* specific to that video */ 1225);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTextualUploadDate() throws ParsingException {
|
||||
Assert.assertEquals("2017-09-22", extractor.getTextualUploadDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploadDate() throws ParsingException, ParseException {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(new SimpleDateFormat("yyyy-MM-dd").parse("2017-09-22"));
|
||||
assertNotNull(extractor.getUploadDate());
|
||||
assertEquals(instance, extractor.getUploadDate().date());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderUrl() throws ParsingException {
|
||||
assertEquals("https://www.youtube.com/channel/UCPysfiuOv4VKBeXFFPhKXyw", extractor.getUploaderUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetThumbnailUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUploaderAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAudioStreams() throws ExtractionException {
|
||||
List<AudioStream> audioStreams = extractor.getAudioStreams();
|
||||
assertFalse(audioStreams.isEmpty());
|
||||
for (AudioStream s : audioStreams) {
|
||||
assertIsSecureUrl(s.url);
|
||||
assertTrue(Integer.toString(s.getFormatId()),
|
||||
0x100 <= s.getFormatId() && s.getFormatId() < 0x1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVideoStreams() throws ExtractionException {
|
||||
for (VideoStream s : extractor.getVideoStreams()) {
|
||||
assertIsSecureUrl(s.url);
|
||||
assertTrue(s.resolution.length() > 0);
|
||||
assertTrue(Integer.toString(s.getFormatId()),
|
||||
0 <= s.getFormatId() && s.getFormatId() < 0x100);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamType() throws ParsingException {
|
||||
assertSame(StreamType.VIDEO_STREAM, extractor.getStreamType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRelatedVideos() throws ExtractionException {
|
||||
StreamInfoItemsCollector relatedVideos = extractor.getRelatedStreams();
|
||||
Utils.printErrors(relatedVideos.getErrors());
|
||||
assertFalse(relatedVideos.getItems().isEmpty());
|
||||
assertTrue(relatedVideos.getErrors().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesListDefault() {
|
||||
assertFalse(extractor.getSubtitlesDefault().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubtitlesList() {
|
||||
assertFalse(extractor.getSubtitles(MediaFormat.TTML).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLikeCount() throws ParsingException {
|
||||
long likeCount = extractor.getLikeCount();
|
||||
assertTrue("" + likeCount, likeCount >= 96);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDislikeCount() throws ParsingException {
|
||||
long dislikeCount = extractor.getDislikeCount();
|
||||
assertTrue("" + dislikeCount, dislikeCount >= 0);
|
||||
@Override public StreamType expectedStreamType() { return StreamType.VIDEO_STREAM; }
|
||||
@Override public String expectedUploaderName() { return "Hooked"; }
|
||||
@Override public String expectedUploaderUrl() { return "https://www.youtube.com/channel/UCPysfiuOv4VKBeXFFPhKXyw"; }
|
||||
@Override public List<String> expectedDescriptionContains() {
|
||||
return Arrays.asList("https://www.youtube.com/user/Roccowschiptune",
|
||||
"https://www.facebook.com/HookedMagazinDE");
|
||||
}
|
||||
@Override public long expectedLength() { return 2488; }
|
||||
@Override public long expectedViewCountAtLeast() { return 1500; }
|
||||
@Nullable @Override public String expectedUploadDate() { return "2017-09-22 00:00:00.000"; }
|
||||
@Nullable @Override public String expectedTextualUploadDate() { return "2017-09-22"; }
|
||||
@Override public long expectedLikeCountAtLeast() { return 110; }
|
||||
@Override public long expectedDislikeCountAtLeast() { return 0; }
|
||||
}
|
||||
|
||||
@@ -21,4 +21,28 @@ public class UtilsTest {
|
||||
public void testJoin() {
|
||||
assertEquals("some,random,stuff", Utils.join(",", Arrays.asList("some", "random", "stuff")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBaseUrl() throws ParsingException {
|
||||
assertEquals("https://www.youtube.com", Utils.getBaseUrl("https://www.youtube.com/watch?v=Hu80uDzh8RY"));
|
||||
assertEquals("vnd.youtube", Utils.getBaseUrl("vnd.youtube://www.youtube.com/watch?v=jZViOEv90dI"));
|
||||
assertEquals("vnd.youtube", Utils.getBaseUrl("vnd.youtube:jZViOEv90dI"));
|
||||
assertEquals("vnd.youtube", Utils.getBaseUrl("vnd.youtube://n8X9_MgEdCg"));
|
||||
assertEquals("https://music.youtube.com", Utils.getBaseUrl("https://music.youtube.com/watch?v=O0EDx9WAelc"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFollowGoogleRedirect() {
|
||||
assertEquals("https://www.youtube.com/watch?v=Hu80uDzh8RY",
|
||||
Utils.followGoogleRedirectIfNeeded("https://www.google.it/url?sa=t&rct=j&q=&esrc=s&cd=&cad=rja&uact=8&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DHu80uDzh8RY&source=video"));
|
||||
assertEquals("https://www.youtube.com/watch?v=0b6cFWG45kA",
|
||||
Utils.followGoogleRedirectIfNeeded("https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=video&cd=&cad=rja&uact=8&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0b6cFWG45kA"));
|
||||
assertEquals("https://soundcloud.com/ciaoproduction",
|
||||
Utils.followGoogleRedirectIfNeeded("https://www.google.com/url?sa=t&url=https%3A%2F%2Fsoundcloud.com%2Fciaoproduction&rct=j&q=&esrc=s&source=web&cd="));
|
||||
|
||||
assertEquals("https://www.youtube.com/watch?v=Hu80uDzh8RY¶m=xyz",
|
||||
Utils.followGoogleRedirectIfNeeded("https://www.youtube.com/watch?v=Hu80uDzh8RY¶m=xyz"));
|
||||
assertEquals("https://www.youtube.com/watch?v=Hu80uDzh8RY&url=hello",
|
||||
Utils.followGoogleRedirectIfNeeded("https://www.youtube.com/watch?v=Hu80uDzh8RY&url=hello"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<opml version="1.1">
|
||||
<body>
|
||||
<outline text="YouTube Subscriptions" title="YouTube Subscriptions">
|
||||
<outline text="Kurzgesagt – In a Nutshell" title="Kurzgesagt – In a Nutshell" type="rss"
|
||||
xmlUrl="https://www.youtube.com/feeds/videos.xml?channel_id=UCsXVk37bltHxD1rDPwtNM8Q"/>
|
||||
<outline text="CaptainDisillusion" title="CaptainDisillusion" type="rss"
|
||||
xmlUrl="https://www.youtube.com/feeds/videos.xml?channel_id=UCEOXxzW2vU0P-0THehuIIeg"/>
|
||||
<outline text="TED" title="TED" type="rss"
|
||||
xmlUrl="https://www.youtube.com/feeds/videos.xml?channel_id=UCAuUUnT6oDeKwE6v1NGQxug"/>
|
||||
<outline text="Gorillaz" title="Gorillaz" type="rss"
|
||||
xmlUrl="https://www.youtube.com/feeds/videos.xml?channel_id=UCfIXdjDQH9Fau7y99_Orpjw"/>
|
||||
<outline text="ElectroBOOM" title="ElectroBOOM" type="rss"
|
||||
xmlUrl="https://www.youtube.com/feeds/videos.xml?channel_id=UCJ0-OtVpF0wOKEqT2Z1HEtA"/>
|
||||
|
||||
<outline text="ⓤⓝⓘⓒⓞⓓⓔ" title="ⓤⓝⓘⓒⓞⓓⓔ" type="rss"
|
||||
xmlUrl="https://www.youtube.com/feeds/videos.xml?channel_id=UCsXVk37bltHxD1rDPwtNM8Q"/>
|
||||
<outline text="中文" title="中文" type="rss"
|
||||
xmlUrl="https://www.youtube.com/feeds/videos.xml?channel_id=UCsXVk37bltHxD1rDPwtNM8Q"/>
|
||||
<outline text="हिंदी" title="हिंदी" type="rss"
|
||||
xmlUrl="https://www.youtube.com/feeds/videos.xml?channel_id=UCsXVk37bltHxD1rDPwtNM8Q"/>
|
||||
</outline>
|
||||
</body>
|
||||
</opml>
|
||||
211
extractor/src/test/resources/youtube_takeout_import_test.json
Normal file
211
extractor/src/test/resources/youtube_takeout_import_test.json
Normal file
@@ -0,0 +1,211 @@
|
||||
[ {
|
||||
"contentDetails" : {
|
||||
"activityType" : "all",
|
||||
"newItemCount" : 0,
|
||||
"totalItemCount" : 229
|
||||
},
|
||||
"etag" : "WRftgrOZw2rsNjNYhHG3s-VObgs",
|
||||
"id" : "qUAzBV8xkoLYOP-1gwzy6yVWWYc7mBJxLNUEVlkNk8Y",
|
||||
"kind" : "youtube#subscription",
|
||||
"snippet" : {
|
||||
"channelId" : "UC-lHJZR3Gqxm24_Vd_AJ5Yw",
|
||||
"description" : "The official YouTube home of Gorillaz.",
|
||||
"publishedAt" : "2020-11-01T17:24:34.498Z",
|
||||
"resourceId" : {
|
||||
"channelId" : "UCfIXdjDQH9Fau7y99_Orpjw",
|
||||
"kind" : "youtube#channel"
|
||||
},
|
||||
"thumbnails" : {
|
||||
"default" : {
|
||||
"url" : "https://yt3.ggpht.com/-UXcxdSDLo08/AAAAAAAAAAI/AAAAAAAAAAA/FP5NbxM7TzU/s88-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"high" : {
|
||||
"url" : "https://yt3.ggpht.com/-UXcxdSDLo08/AAAAAAAAAAI/AAAAAAAAAAA/FP5NbxM7TzU/s800-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"medium" : {
|
||||
"url" : "https://yt3.ggpht.com/-UXcxdSDLo08/AAAAAAAAAAI/AAAAAAAAAAA/FP5NbxM7TzU/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
}
|
||||
},
|
||||
"title" : "Gorillaz"
|
||||
}
|
||||
}, {
|
||||
"contentDetails" : {
|
||||
"activityType" : "all",
|
||||
"newItemCount" : 0,
|
||||
"totalItemCount" : 3502
|
||||
},
|
||||
"etag" : "wUgip-X0qBlnjj0frSTwP6B8XoY",
|
||||
"id" : "qUAzBV8xkoLYOP-1gwzy63zpjj8SMTtDReGwIa2sHp8",
|
||||
"kind" : "youtube#subscription",
|
||||
"snippet" : {
|
||||
"channelId" : "UC-lHJZR3Gqxm24_Vd_AJ5Yw",
|
||||
"description" : "The TED Talks channel features the best talks and performances from the TED Conference, where the world's leading thinkers and doers give the talk of their lives in 18 minutes (or less). Look for talks on Technology, Entertainment and Design -- plus science, business, global issues, the arts and more. You're welcome to link to or embed these videos, forward them to others and share these ideas with people you know.\n\nTED's videos may be used for non-commercial purposes under a Creative Commons License, Attribution–Non Commercial–No Derivatives (or the CC BY – NC – ND 4.0 International) and in accordance with our TED Talks Usage Policy (https://www.ted.com/about/our-organization/our-policies-terms/ted-talks-usage-policy). For more information on using TED for commercial purposes (e.g. employee learning, in a film or online course), please submit a Media Request at https://media-requests.ted.com",
|
||||
"publishedAt" : "2020-11-01T17:24:11.769Z",
|
||||
"resourceId" : {
|
||||
"channelId" : "UCAuUUnT6oDeKwE6v1NGQxug",
|
||||
"kind" : "youtube#channel"
|
||||
},
|
||||
"thumbnails" : {
|
||||
"default" : {
|
||||
"url" : "https://yt3.ggpht.com/-bonZt347bMc/AAAAAAAAAAI/AAAAAAAAAAA/lR8QEKnqqHk/s88-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"high" : {
|
||||
"url" : "https://yt3.ggpht.com/-bonZt347bMc/AAAAAAAAAAI/AAAAAAAAAAA/lR8QEKnqqHk/s800-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"medium" : {
|
||||
"url" : "https://yt3.ggpht.com/-bonZt347bMc/AAAAAAAAAAI/AAAAAAAAAAA/lR8QEKnqqHk/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
}
|
||||
},
|
||||
"title" : "TED"
|
||||
}
|
||||
}, {
|
||||
"contentDetails" : {
|
||||
"activityType" : "all",
|
||||
"newItemCount" : 0,
|
||||
"totalItemCount" : 98
|
||||
},
|
||||
"etag" : "M3Hl6FQUAD3e-fH9pcvcE9aPSWQ",
|
||||
"id" : "qUAzBV8xkoLYOP-1gwzy64Vo-PpWMPDyIYBM1JUfepk",
|
||||
"kind" : "youtube#subscription",
|
||||
"snippet" : {
|
||||
"channelId" : "UC-lHJZR3Gqxm24_Vd_AJ5Yw",
|
||||
"description" : "In a world where the content of digital images and videos can no longer be taken at face value, an unlikely hero fights for the acceptance of truth.\r\n\r\nCaptain Disillusion guides children of all ages through the maze of visual fakery to the open spaces of reality and peace of mind.\r\n\r\nSubscribe to get fun and detailed explanations of current \"unbelievable\" viral videos that fool the masses!",
|
||||
"publishedAt" : "2020-11-01T17:23:52.909Z",
|
||||
"resourceId" : {
|
||||
"channelId" : "UCEOXxzW2vU0P-0THehuIIeg",
|
||||
"kind" : "youtube#channel"
|
||||
},
|
||||
"thumbnails" : {
|
||||
"default" : {
|
||||
"url" : "https://yt3.ggpht.com/-7f3hUYZP5Sc/AAAAAAAAAAI/AAAAAAAAAAA/4cpBHKDlbYQ/s88-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"high" : {
|
||||
"url" : "https://yt3.ggpht.com/-7f3hUYZP5Sc/AAAAAAAAAAI/AAAAAAAAAAA/4cpBHKDlbYQ/s800-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"medium" : {
|
||||
"url" : "https://yt3.ggpht.com/-7f3hUYZP5Sc/AAAAAAAAAAI/AAAAAAAAAAA/4cpBHKDlbYQ/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
}
|
||||
},
|
||||
"title" : "Captain Disillusion"
|
||||
}
|
||||
}, {
|
||||
"contentDetails" : {
|
||||
"activityType" : "all",
|
||||
"newItemCount" : 0,
|
||||
"totalItemCount" : 130
|
||||
},
|
||||
"etag" : "crkTVZbDHS3arRZErMaLMnNqtac",
|
||||
"id" : "qUAzBV8xkoLYOP-1gwzy66EVopYHE34m06PVw8Pvheg",
|
||||
"kind" : "youtube#subscription",
|
||||
"snippet" : {
|
||||
"channelId" : "UC-lHJZR3Gqxm24_Vd_AJ5Yw",
|
||||
"description" : "Videos explaining things with optimistic nihilism. \n\nWe are a small team who want to make science look beautiful. Because it is beautiful. \n\nCurrently we make one animation video per month. Follow us on Twitter, Facebook to get notified when a new one comes out.\n\nFAQ:\n \n- We do the videos with After Effects and Illustrator.",
|
||||
"publishedAt" : "2020-11-01T17:23:39.659Z",
|
||||
"resourceId" : {
|
||||
"channelId" : "UCsXVk37bltHxD1rDPwtNM8Q",
|
||||
"kind" : "youtube#channel"
|
||||
},
|
||||
"thumbnails" : {
|
||||
"default" : {
|
||||
"url" : "https://yt3.ggpht.com/-UwENvFjc4vI/AAAAAAAAAAI/AAAAAAAAAAA/04dXvZ_jl0I/s88-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"high" : {
|
||||
"url" : "https://yt3.ggpht.com/-UwENvFjc4vI/AAAAAAAAAAI/AAAAAAAAAAA/04dXvZ_jl0I/s800-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"medium" : {
|
||||
"url" : "https://yt3.ggpht.com/-UwENvFjc4vI/AAAAAAAAAAI/AAAAAAAAAAA/04dXvZ_jl0I/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
}
|
||||
},
|
||||
"title" : "Kurzgesagt – In a Nutshell"
|
||||
}
|
||||
}, {
|
||||
"contentDetails" : {
|
||||
"activityType" : "all",
|
||||
"newItemCount" : 0,
|
||||
"totalItemCount" : 229
|
||||
},
|
||||
"etag" : "WRftgrOZw2rsNjNYhHG3s-VObgs",
|
||||
"id" : "qUAzBV8xkoLYOP-1gwzy6yVWWYc7mBJxLNUEVlkNk8Y",
|
||||
"kind" : "youtube#subscription",
|
||||
"snippet" : {
|
||||
"channelId" : "UC-lHJZR3Gqxm24_Vd_AJ5Yw",
|
||||
"description" : "ⓤⓝⓘⓒⓞⓓⓔ",
|
||||
"publishedAt" : "2020-11-01T17:24:34.498Z",
|
||||
"resourceId" : {
|
||||
"channelId" : "UCfIXdjDQH9Fau7y99_Orpjw",
|
||||
"kind" : "youtube#channel"
|
||||
},
|
||||
"thumbnails" : {
|
||||
"default" : {
|
||||
"url" : "https://yt3.ggpht.com/-UXcxdSDLo08/AAAAAAAAAAI/AAAAAAAAAAA/FP5NbxM7TzU/s88-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"high" : {
|
||||
"url" : "https://yt3.ggpht.com/-UXcxdSDLo08/AAAAAAAAAAI/AAAAAAAAAAA/FP5NbxM7TzU/s800-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"medium" : {
|
||||
"url" : "https://yt3.ggpht.com/-UXcxdSDLo08/AAAAAAAAAAI/AAAAAAAAAAA/FP5NbxM7TzU/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
}
|
||||
},
|
||||
"title" : "ⓤⓝⓘⓒⓞⓓⓔ"
|
||||
}
|
||||
}, {
|
||||
"contentDetails" : {
|
||||
"activityType" : "all",
|
||||
"newItemCount" : 0,
|
||||
"totalItemCount" : 229
|
||||
},
|
||||
"etag" : "WRftgrOZw2rsNjNYhHG3s-VObgs",
|
||||
"id" : "qUAzBV8xkoLYOP-1gwzy6yVWWYc7mBJxLNUEVlkNk8Y",
|
||||
"kind" : "youtube#subscription",
|
||||
"snippet" : {
|
||||
"channelId" : "UC-lHJZR3Gqxm24_Vd_AJ5Yw",
|
||||
"description" : "中文",
|
||||
"publishedAt" : "2020-11-01T17:24:34.498Z",
|
||||
"resourceId" : {
|
||||
"channelId" : "UCfIXdjDQH9Fau7y99_Orpjw",
|
||||
"kind" : "youtube#channel"
|
||||
},
|
||||
"thumbnails" : {
|
||||
"default" : {
|
||||
"url" : "https://yt3.ggpht.com/-UXcxdSDLo08/AAAAAAAAAAI/AAAAAAAAAAA/FP5NbxM7TzU/s88-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"high" : {
|
||||
"url" : "https://yt3.ggpht.com/-UXcxdSDLo08/AAAAAAAAAAI/AAAAAAAAAAA/FP5NbxM7TzU/s800-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"medium" : {
|
||||
"url" : "https://yt3.ggpht.com/-UXcxdSDLo08/AAAAAAAAAAI/AAAAAAAAAAA/FP5NbxM7TzU/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
}
|
||||
},
|
||||
"title" : "中文"
|
||||
}
|
||||
}, {
|
||||
"contentDetails" : {
|
||||
"activityType" : "all",
|
||||
"newItemCount" : 0,
|
||||
"totalItemCount" : 229
|
||||
},
|
||||
"etag" : "WRftgrOZw2rsNjNYhHG3s-VObgs",
|
||||
"id" : "qUAzBV8xkoLYOP-1gwzy6yVWWYc7mBJxLNUEVlkNk8Y",
|
||||
"kind" : "youtube#subscription",
|
||||
"snippet" : {
|
||||
"channelId" : "UC-lHJZR3Gqxm24_Vd_AJ5Yw",
|
||||
"description" : "हिंदी",
|
||||
"publishedAt" : "2020-11-01T17:24:34.498Z",
|
||||
"resourceId" : {
|
||||
"channelId" : "UCfIXdjDQH9Fau7y99_Orpjw",
|
||||
"kind" : "youtube#channel"
|
||||
},
|
||||
"thumbnails" : {
|
||||
"default" : {
|
||||
"url" : "https://yt3.ggpht.com/-UXcxdSDLo08/AAAAAAAAAAI/AAAAAAAAAAA/FP5NbxM7TzU/s88-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"high" : {
|
||||
"url" : "https://yt3.ggpht.com/-UXcxdSDLo08/AAAAAAAAAAI/AAAAAAAAAAA/FP5NbxM7TzU/s800-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
},
|
||||
"medium" : {
|
||||
"url" : "https://yt3.ggpht.com/-UXcxdSDLo08/AAAAAAAAAAI/AAAAAAAAAAA/FP5NbxM7TzU/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
|
||||
}
|
||||
},
|
||||
"title" : "हिंदी"
|
||||
}
|
||||
} ]
|
||||
Reference in New Issue
Block a user