2019-12-22 17:30:22 +01:00
|
|
|
package org.schabi.newpipe.extractor.services.bandcamp;
|
|
|
|
|
|
|
|
import org.junit.BeforeClass;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.schabi.newpipe.DownloaderTestImpl;
|
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
2020-08-09 10:07:49 +02:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
|
2019-12-22 17:30:22 +01:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
2020-06-04 12:30:53 +02:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
2019-12-22 17:30:22 +01:00
|
|
|
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampRadioStreamExtractor;
|
2020-06-04 12:30:53 +02:00
|
|
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
2019-12-22 17:30:22 +01:00
|
|
|
|
|
|
|
import java.io.IOException;
|
2020-06-04 14:09:21 +02:00
|
|
|
import java.util.Calendar;
|
2020-06-04 19:12:10 +02:00
|
|
|
import java.util.TimeZone;
|
2019-12-22 17:30:22 +01:00
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
2020-04-20 21:55:35 +02:00
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
2019-12-22 17:30:22 +01:00
|
|
|
|
|
|
|
public class BandcampRadioStreamExtractorTest {
|
|
|
|
|
2020-06-04 12:30:53 +02:00
|
|
|
private static StreamExtractor e;
|
|
|
|
|
|
|
|
private static final String SHOW_URL = "https://bandcamp.com/?show=230";
|
|
|
|
|
2019-12-22 17:30:22 +01:00
|
|
|
@BeforeClass
|
2020-06-04 12:30:53 +02:00
|
|
|
public static void setUp() throws IOException, ExtractionException {
|
2019-12-22 17:30:22 +01:00
|
|
|
NewPipe.init(DownloaderTestImpl.getInstance());
|
2020-06-04 12:30:53 +02:00
|
|
|
e = Bandcamp.getStreamExtractor(SHOW_URL);
|
|
|
|
e.fetchPage();
|
2019-12-22 17:30:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGettingCorrectStreamExtractor() throws ExtractionException {
|
2020-04-20 21:55:35 +02:00
|
|
|
assertTrue(Bandcamp.getStreamExtractor("https://bandcamp.com/?show=3") instanceof BandcampRadioStreamExtractor);
|
2020-11-24 09:55:41 +01:00
|
|
|
assertFalse(Bandcamp.getStreamExtractor("https://zachbenson.bandcamp.com/track/deflated")
|
|
|
|
instanceof BandcampRadioStreamExtractor);
|
2019-12-22 17:30:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2020-06-04 12:30:53 +02:00
|
|
|
public void testGetName() throws ParsingException {
|
2019-12-22 17:30:22 +01:00
|
|
|
assertEquals("Sound Movements", e.getName());
|
2020-06-04 12:30:53 +02:00
|
|
|
}
|
|
|
|
|
2020-08-09 10:07:49 +02:00
|
|
|
@Test(expected = ContentNotSupportedException.class)
|
2020-06-04 19:32:19 +02:00
|
|
|
public void testGetUploaderUrl() throws ParsingException {
|
2020-08-09 10:07:49 +02:00
|
|
|
e.getUploaderUrl();
|
2020-06-04 12:30:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGetUrl() throws ParsingException {
|
|
|
|
assertEquals(SHOW_URL, e.getUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGetUploaderName() throws ParsingException {
|
2019-12-22 17:30:22 +01:00
|
|
|
assertEquals("Andrew Jervis", e.getUploaderName());
|
|
|
|
}
|
2020-06-04 12:30:53 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGetTextualUploadDate() throws ParsingException {
|
2020-06-04 19:12:10 +02:00
|
|
|
assertEquals("16 May 2017 00:00:00 GMT", e.getTextualUploadDate());
|
2020-06-04 14:09:21 +02:00
|
|
|
}
|
2020-06-04 12:30:53 +02:00
|
|
|
|
2020-06-04 14:09:21 +02:00
|
|
|
@Test
|
|
|
|
public void testUploadDate() throws ParsingException {
|
2020-06-04 19:12:10 +02:00
|
|
|
final Calendar expectedCalendar = Calendar.getInstance();
|
|
|
|
|
|
|
|
// 16 May 2017 00:00:00 GMT
|
|
|
|
expectedCalendar.setTimeZone(TimeZone.getTimeZone("GMT"));
|
|
|
|
expectedCalendar.setTimeInMillis(0);
|
|
|
|
expectedCalendar.set(2017, Calendar.MAY, 16);
|
|
|
|
|
|
|
|
assertEquals(expectedCalendar.getTimeInMillis(), e.getUploadDate().date().getTimeInMillis());
|
2020-06-04 12:30:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGetThumbnailUrl() throws ParsingException {
|
|
|
|
assertTrue(e.getThumbnailUrl().contains("bcbits.com/img"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGetUploaderAvatarUrl() throws ParsingException {
|
|
|
|
assertTrue(e.getUploaderAvatarUrl().contains("bandcamp-button"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGetDescription() throws ParsingException {
|
2020-11-24 09:55:41 +01:00
|
|
|
assertEquals("Featuring special guests Nick Hakim and Elbows, plus fresh cuts from Eddie Palmieri, KRS One, Ladi6, and Moonchild.",
|
|
|
|
e.getDescription().getContent());
|
2020-06-04 12:30:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGetLength() throws ParsingException {
|
|
|
|
assertEquals(5619, e.getLength());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGetAudioStreams() throws ExtractionException, IOException {
|
|
|
|
assertEquals(2, e.getAudioStreams().size());
|
|
|
|
}
|
2019-12-22 17:30:22 +01:00
|
|
|
}
|