2017-08-08 08:42:28 +02:00
|
|
|
|
package org.schabi.newpipe.extractor.services.soundcloud;
|
|
|
|
|
|
2017-11-22 18:39:38 +01:00
|
|
|
|
import com.grack.nanojson.JsonParserException;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
import org.junit.Before;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.schabi.newpipe.Downloader;
|
|
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
2017-11-23 16:33:03 +01:00
|
|
|
|
import org.schabi.newpipe.extractor.Subtitles;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|
|
|
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
|
|
|
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
|
|
|
|
import org.schabi.newpipe.extractor.stream.StreamType;
|
2017-11-23 16:33:03 +01:00
|
|
|
|
import org.schabi.newpipe.extractor.stream.SubtitlesFormat;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
2017-08-08 17:01:50 +02:00
|
|
|
|
import java.io.IOException;
|
2017-11-23 16:33:03 +01:00
|
|
|
|
import java.util.List;
|
2017-08-08 17:01:50 +02:00
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
|
|
|
|
|
2017-08-08 08:42:28 +02:00
|
|
|
|
/**
|
|
|
|
|
* Test for {@link StreamExtractor}
|
|
|
|
|
*/
|
|
|
|
|
public class SoundcloudStreamExtractorDefaultTest {
|
2017-11-25 02:07:12 +01:00
|
|
|
|
private SoundcloudStreamExtractor extractor;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
|
|
|
|
@Before
|
|
|
|
|
public void setUp() throws Exception {
|
|
|
|
|
NewPipe.init(Downloader.getInstance());
|
2017-11-25 02:07:12 +01:00
|
|
|
|
extractor = (SoundcloudStreamExtractor) SoundCloud.getService().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 {
|
|
|
|
|
StreamExtractor extractor = SoundCloud.getService().getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon#t=69");
|
2017-08-11 03:23:09 +02:00
|
|
|
|
assertEquals(extractor.getTimeStamp() + "", "69");
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetTitle() throws ParsingException {
|
2017-08-11 03:23:09 +02:00
|
|
|
|
assertEquals(extractor.getName(), "Do What I Want [Produced By Maaly Raw + Don Cannon]");
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetDescription() throws ParsingException {
|
|
|
|
|
assertEquals(extractor.getDescription(), "The Perfect LUV Tape®️");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
2017-08-08 23:36:11 +02:00
|
|
|
|
public void testGetUploaderName() throws ParsingException {
|
|
|
|
|
assertEquals(extractor.getUploaderName(), "LIL UZI VERT");
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetLength() throws ParsingException {
|
|
|
|
|
assertEquals(extractor.getLength(), 175);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetViewCount() throws ParsingException {
|
|
|
|
|
assertTrue(Long.toString(extractor.getViewCount()),
|
|
|
|
|
extractor.getViewCount() > 44227978);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetUploadDate() throws ParsingException {
|
|
|
|
|
assertEquals(extractor.getUploadDate(), "2016-07-31");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
2017-08-08 23:36:11 +02:00
|
|
|
|
public void testGetUploaderUrl() throws ParsingException {
|
|
|
|
|
assertEquals(extractor.getUploaderUrl(), "http://soundcloud.com/liluzivert");
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetThumbnailUrl() throws ParsingException {
|
2017-09-08 15:43:40 +02:00
|
|
|
|
assertTrue(extractor.getThumbnailUrl(), extractor.getThumbnailUrl().contains("https://"));
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
2017-08-08 23:36:11 +02:00
|
|
|
|
public void testGetUploaderAvatarUrl() throws ParsingException {
|
2017-09-08 15:43:40 +02:00
|
|
|
|
assertTrue(extractor.getUploaderAvatarUrl(), extractor.getUploaderAvatarUrl().contains("https://"));
|
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 {
|
|
|
|
|
StreamInfoItemCollector relatedVideos = extractor.getRelatedVideos();
|
|
|
|
|
assertFalse(relatedVideos.getItemList().isEmpty());
|
|
|
|
|
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
|
|
|
|
|
assertTrue(extractor.getSubtitlesDefault() == null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
|
|
assertTrue(extractor.getSubtitles(SubtitlesFormat.VTT) == null);
|
2017-11-22 18:39:38 +01:00
|
|
|
|
}
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|