2018-12-23 19:41:18 +01:00
|
|
|
package org.schabi.newpipe.extractor.services.media_ccc;
|
|
|
|
|
2019-04-28 22:03:16 +02:00
|
|
|
import org.junit.Assert;
|
2018-12-23 19:41:18 +01:00
|
|
|
import org.junit.BeforeClass;
|
|
|
|
import org.junit.Test;
|
2019-04-28 22:03:16 +02:00
|
|
|
import org.schabi.newpipe.DownloaderTestImpl;
|
2018-12-23 19:41:18 +01:00
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
2019-04-28 22:03:16 +02:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
2018-12-23 19:41:18 +01:00
|
|
|
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
|
2020-03-13 20:07:36 +01:00
|
|
|
import org.schabi.newpipe.extractor.stream.AudioStream;
|
|
|
|
import org.schabi.newpipe.extractor.stream.VideoStream;
|
2019-04-28 22:03:16 +02:00
|
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Calendar;
|
2020-03-13 20:07:36 +01:00
|
|
|
import java.util.List;
|
2018-12-23 19:41:18 +01:00
|
|
|
|
2019-11-03 19:45:25 +01:00
|
|
|
import static java.util.Objects.requireNonNull;
|
2018-12-23 19:41:18 +01:00
|
|
|
import static junit.framework.TestCase.assertEquals;
|
2020-03-02 22:38:44 +01:00
|
|
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
2018-12-23 19:41:18 +01:00
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test {@link MediaCCCStreamExtractor}
|
|
|
|
*/
|
2020-02-12 00:25:34 +01:00
|
|
|
public class MediaCCCStreamExtractorTest {
|
|
|
|
public static class Gpn18Tmux {
|
|
|
|
private static MediaCCCStreamExtractor extractor;
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
public static void setUpClass() 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.fetchPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testServiceId() throws Exception {
|
|
|
|
assertEquals(2, extractor.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testName() throws Exception {
|
|
|
|
assertEquals("tmux - Warum ein schwarzes Fenster am Bildschirm reicht", extractor.getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@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 {
|
2020-03-02 22:38:44 +01:00
|
|
|
assertIsSecureUrl(extractor.getUrl());
|
2020-04-01 11:40:03 +02:00
|
|
|
assertEquals("https://media.ccc.de/public/events/gpn18-105-tmux-warum-ein-schwarzes-fenster-am-bildschirm-reicht", extractor.getUrl());
|
2020-02-12 00:25:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testOriginalUrl() throws Exception {
|
2020-03-02 22:38:44 +01:00
|
|
|
assertIsSecureUrl(extractor.getOriginalUrl());
|
2020-02-12 00:25:34 +01:00
|
|
|
assertEquals("https://media.ccc.de/v/gpn18-105-tmux-warum-ein-schwarzes-fenster-am-bildschirm-reicht", extractor.getOriginalUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testThumbnail() throws Exception {
|
2020-03-02 22:38:44 +01:00
|
|
|
assertIsSecureUrl(extractor.getThumbnailUrl());
|
2020-02-12 00:25:34 +01:00
|
|
|
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 {
|
2020-03-02 22:38:44 +01:00
|
|
|
assertIsSecureUrl(extractor.getUploaderUrl());
|
2020-02-12 00:25:34 +01:00
|
|
|
assertEquals("https://api.media.ccc.de/public/conferences/gpn18", extractor.getUploaderUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUploaderAvatarUrl() throws Exception {
|
2020-03-02 22:38:44 +01:00
|
|
|
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
2020-02-12 00:25:34 +01:00
|
|
|
assertEquals("https://static.media.ccc.de/media/events/gpn/gpn18/logo.png", extractor.getUploaderAvatarUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testVideoStreams() throws Exception {
|
2020-03-13 20:07:36 +01:00
|
|
|
List<VideoStream> videoStreamList = extractor.getVideoStreams();
|
|
|
|
assertEquals(4, videoStreamList.size());
|
|
|
|
for (VideoStream stream : videoStreamList) {
|
|
|
|
assertIsSecureUrl(stream.getUrl());
|
|
|
|
}
|
2020-02-12 00:25:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testAudioStreams() throws Exception {
|
2020-03-13 20:07:36 +01:00
|
|
|
List<AudioStream> audioStreamList = extractor.getAudioStreams();
|
|
|
|
assertEquals(2, audioStreamList.size());
|
|
|
|
for (AudioStream stream : audioStreamList) {
|
|
|
|
assertIsSecureUrl(stream.getUrl());
|
|
|
|
}
|
2020-02-12 00:25:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@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());
|
|
|
|
}
|
2019-04-28 22:03:16 +02:00
|
|
|
}
|
|
|
|
|
2020-02-12 00:25:34 +01:00
|
|
|
public static class _36c3PrivacyMessaging {
|
|
|
|
private static MediaCCCStreamExtractor extractor;
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
public static void setUpClass() throws Exception {
|
|
|
|
NewPipe.init(DownloaderTestImpl.getInstance());
|
|
|
|
extractor = (MediaCCCStreamExtractor) MediaCCC.getStreamExtractor("https://media.ccc.de/v/36c3-10565-what_s_left_for_private_messaging");
|
|
|
|
extractor.fetchPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testName() throws Exception {
|
|
|
|
assertEquals("What's left for private messaging?", extractor.getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws Exception {
|
|
|
|
assertEquals("36c3-10565-what_s_left_for_private_messaging", extractor.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUrl() throws Exception {
|
2020-03-02 22:38:44 +01:00
|
|
|
assertIsSecureUrl(extractor.getUrl());
|
2020-04-01 11:40:03 +02:00
|
|
|
assertEquals("https://media.ccc.de/public/events/36c3-10565-what_s_left_for_private_messaging", extractor.getUrl());
|
2020-02-12 00:25:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testOriginalUrl() throws Exception {
|
2020-03-02 22:38:44 +01:00
|
|
|
assertIsSecureUrl(extractor.getOriginalUrl());
|
2020-02-12 00:25:34 +01:00
|
|
|
assertEquals("https://media.ccc.de/v/36c3-10565-what_s_left_for_private_messaging", extractor.getOriginalUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testThumbnail() throws Exception {
|
2020-03-02 22:38:44 +01:00
|
|
|
assertIsSecureUrl(extractor.getThumbnailUrl());
|
2020-02-12 00:25:34 +01:00
|
|
|
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 {
|
2020-03-02 22:38:44 +01:00
|
|
|
assertIsSecureUrl(extractor.getUploaderUrl());
|
2020-04-01 11:40:03 +02:00
|
|
|
assertEquals("https://media.ccc.de/public/conferences/36c3", extractor.getUploaderUrl());
|
2020-02-12 00:25:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUploaderAvatarUrl() throws Exception {
|
2020-03-02 22:38:44 +01:00
|
|
|
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
2020-02-12 00:25:34 +01:00
|
|
|
assertEquals("https://static.media.ccc.de/media/congress/2019/logo.png", extractor.getUploaderAvatarUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testVideoStreams() throws Exception {
|
2020-03-13 20:07:36 +01:00
|
|
|
List<VideoStream> videoStreamList = extractor.getVideoStreams();
|
|
|
|
assertEquals(8, videoStreamList.size());
|
|
|
|
for (VideoStream stream : videoStreamList) {
|
|
|
|
assertIsSecureUrl(stream.getUrl());
|
|
|
|
}
|
2020-02-12 00:25:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testAudioStreams() throws Exception {
|
2020-03-13 20:07:36 +01:00
|
|
|
List<AudioStream> audioStreamList = extractor.getAudioStreams();
|
|
|
|
assertEquals(2, audioStreamList.size());
|
|
|
|
for (AudioStream stream : audioStreamList) {
|
|
|
|
assertIsSecureUrl(stream.getUrl());
|
|
|
|
}
|
2020-02-12 00:25:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@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());
|
|
|
|
}
|
2019-04-28 22:03:16 +02:00
|
|
|
}
|
2020-04-01 11:40:03 +02:00
|
|
|
}
|