2017-08-08 08:42:28 +02:00
|
|
|
|
package org.schabi.newpipe.extractor.services.soundcloud;
|
|
|
|
|
|
2017-12-07 02:09:46 +01:00
|
|
|
|
import org.junit.BeforeClass;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.schabi.newpipe.Downloader;
|
|
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|
|
|
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
2018-02-24 22:20:50 +01:00
|
|
|
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
import org.schabi.newpipe.extractor.stream.StreamType;
|
2018-09-15 21:47:53 +02:00
|
|
|
|
import org.schabi.newpipe.extractor.utils.Localization;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
2017-08-08 17:01:50 +02:00
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
2018-01-04 17:21:03 +01:00
|
|
|
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
2017-08-08 17:01:50 +02:00
|
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
|
|
|
|
|
2017-08-08 08:42:28 +02:00
|
|
|
|
/**
|
|
|
|
|
* Test for {@link StreamExtractor}
|
|
|
|
|
*/
|
|
|
|
|
public class SoundcloudStreamExtractorDefaultTest {
|
2017-12-07 02:09:46 +01:00
|
|
|
|
private static SoundcloudStreamExtractor extractor;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
2017-12-07 02:09:46 +01:00
|
|
|
|
@BeforeClass
|
|
|
|
|
public static void setUp() throws Exception {
|
2018-09-15 21:47:53 +02:00
|
|
|
|
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
2018-02-10 03:46:05 +01:00
|
|
|
|
extractor = (SoundcloudStreamExtractor) SoundCloud.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon");
|
2017-11-28 13:37:01 +01:00
|
|
|
|
extractor.fetchPage();
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetInvalidTimeStamp() throws ParsingException {
|
2017-08-11 03:23:09 +02:00
|
|
|
|
assertTrue(extractor.getTimeStamp() + "",
|
2017-08-08 08:42:28 +02:00
|
|
|
|
extractor.getTimeStamp() <= 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
2018-02-10 03:46:05 +01:00
|
|
|
|
StreamExtractor extractor = SoundCloud.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon#t=69");
|
2019-07-30 20:53:23 +02:00
|
|
|
|
assertEquals("69", extractor.getTimeStamp() + "");
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetTitle() throws ParsingException {
|
2019-07-30 20:53:23 +02:00
|
|
|
|
assertEquals("Do What I Want [Produced By Maaly Raw + Don Cannon]", extractor.getName());
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetDescription() throws ParsingException {
|
2019-07-30 20:53:23 +02:00
|
|
|
|
assertEquals("The Perfect LUV Tape®️", extractor.getDescription());
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
2017-08-08 23:36:11 +02:00
|
|
|
|
public void testGetUploaderName() throws ParsingException {
|
2019-07-30 20:53:23 +02:00
|
|
|
|
assertEquals("LIL UZI VERT", extractor.getUploaderName());
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetLength() throws ParsingException {
|
2019-07-30 20:53:23 +02:00
|
|
|
|
assertEquals(175, extractor.getLength());
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetViewCount() throws ParsingException {
|
|
|
|
|
assertTrue(Long.toString(extractor.getViewCount()),
|
|
|
|
|
extractor.getViewCount() > 44227978);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetUploadDate() throws ParsingException {
|
2018-01-04 17:21:03 +01:00
|
|
|
|
assertEquals("2016-07-31", extractor.getUploadDate());
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
2017-08-08 23:36:11 +02:00
|
|
|
|
public void testGetUploaderUrl() throws ParsingException {
|
2018-01-04 17:21:03 +01:00
|
|
|
|
assertIsSecureUrl(extractor.getUploaderUrl());
|
|
|
|
|
assertEquals("https://soundcloud.com/liluzivert", extractor.getUploaderUrl());
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetThumbnailUrl() throws ParsingException {
|
2018-01-04 17:21:03 +01:00
|
|
|
|
assertIsSecureUrl(extractor.getThumbnailUrl());
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
2017-08-08 23:36:11 +02:00
|
|
|
|
public void testGetUploaderAvatarUrl() throws ParsingException {
|
2018-01-04 17:21:03 +01:00
|
|
|
|
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetAudioStreams() throws IOException, ExtractionException {
|
2017-11-25 02:07:12 +01:00
|
|
|
|
assertFalse(extractor.getAudioStreams().isEmpty());
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testStreamType() throws ParsingException {
|
|
|
|
|
assertTrue(extractor.getStreamType() == StreamType.AUDIO_STREAM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetRelatedVideos() throws ExtractionException, IOException {
|
2018-11-07 18:28:44 +01:00
|
|
|
|
StreamInfoItemsCollector relatedVideos = extractor.getRelatedStreams();
|
2018-03-11 21:50:40 +01:00
|
|
|
|
assertFalse(relatedVideos.getItems().isEmpty());
|
2017-08-08 08:42:28 +02:00
|
|
|
|
assertTrue(relatedVideos.getErrors().isEmpty());
|
|
|
|
|
}
|
2017-11-22 18:39:38 +01:00
|
|
|
|
|
|
|
|
|
@Test
|
2017-11-24 13:57:54 +01:00
|
|
|
|
public void testGetSubtitlesListDefault() throws IOException, ExtractionException {
|
2017-11-23 16:33:03 +01:00
|
|
|
|
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
2018-02-02 04:07:57 +01:00
|
|
|
|
assertTrue(extractor.getSubtitlesDefault().isEmpty());
|
2017-11-23 16:33:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
2017-11-24 13:57:54 +01:00
|
|
|
|
public void testGetSubtitlesList() throws IOException, ExtractionException {
|
2017-11-23 16:33:03 +01:00
|
|
|
|
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
2018-02-02 04:07:57 +01:00
|
|
|
|
assertTrue(extractor.getSubtitlesDefault().isEmpty());
|
2017-11-22 18:39:38 +01:00
|
|
|
|
}
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|