2019-12-21 19:00:07 +01:00
|
|
|
// Created by Fynn Godau 2019, licensed GNU GPL version 3 or later
|
|
|
|
|
|
|
|
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;
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
2020-05-25 20:22:23 +02:00
|
|
|
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper;
|
2019-12-21 19:00:07 +01:00
|
|
|
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamExtractor;
|
2020-03-17 20:40:25 +01:00
|
|
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
2019-12-21 19:00:07 +01:00
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
import static org.junit.Assert.assertTrue;
|
2020-04-20 21:55:35 +02:00
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
2019-12-21 19:00:07 +01:00
|
|
|
|
|
|
|
public class BandcampStreamExtractorTest {
|
|
|
|
|
|
|
|
private static BandcampStreamExtractor extractor;
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
public static void setUp() throws Exception {
|
|
|
|
NewPipe.init(DownloaderTestImpl.getInstance());
|
2020-04-20 21:55:35 +02:00
|
|
|
extractor = (BandcampStreamExtractor) Bandcamp
|
2019-12-21 19:00:07 +01:00
|
|
|
.getStreamExtractor("https://zachbenson.bandcamp.com/track/kitchen");
|
|
|
|
extractor.fetchPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testServiceId() {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testName() throws ParsingException {
|
|
|
|
assertEquals("kitchen", extractor.getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUrl() throws ParsingException {
|
|
|
|
assertEquals("https://zachbenson.bandcamp.com/track/kitchen", extractor.getUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testArtistUrl() throws ParsingException {
|
|
|
|
assertEquals("https://zachbenson.bandcamp.com/", extractor.getUploaderUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testDescription() {
|
2020-03-17 20:40:25 +01:00
|
|
|
assertEquals(831, extractor.getDescription().getContent().length());
|
2019-12-21 19:00:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testArtistProfilePicture() {
|
|
|
|
String url = extractor.getUploaderAvatarUrl();
|
|
|
|
assertTrue(url.contains("://f4.bcbits.com/img/") && url.endsWith(".jpg"));
|
|
|
|
}
|
|
|
|
|
2019-12-22 01:14:35 +01:00
|
|
|
@Test
|
|
|
|
public void testNoArtistProfilePicture() throws ExtractionException {
|
2020-04-20 21:55:35 +02:00
|
|
|
assertEquals("", Bandcamp.getStreamExtractor("https://powertothequeerkids.bandcamp.com/track/human-nature").getUploaderAvatarUrl());
|
2019-12-22 01:14:35 +01:00
|
|
|
}
|
|
|
|
|
2019-12-21 21:47:06 +01:00
|
|
|
@Test
|
|
|
|
public void testAudioStream() {
|
|
|
|
assertTrue(extractor.getAudioStreams().get(0).getUrl().contains("bcbits.com/stream"));
|
|
|
|
assertEquals(1, extractor.getAudioStreams().size());
|
|
|
|
}
|
|
|
|
|
2020-03-17 20:40:25 +01:00
|
|
|
@Test
|
|
|
|
public void testCategory() throws ExtractionException, IOException {
|
2020-04-20 21:55:35 +02:00
|
|
|
StreamExtractor se = Bandcamp.getStreamExtractor("https://npet.bandcamp.com/track/track-1");
|
2020-03-17 20:40:25 +01:00
|
|
|
se.fetchPage();
|
|
|
|
assertEquals("acoustic", se.getCategory());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testLicense() throws ExtractionException, IOException {
|
2020-04-20 21:55:35 +02:00
|
|
|
StreamExtractor se = Bandcamp.getStreamExtractor("https://npet.bandcamp.com/track/track-1");
|
2020-03-17 20:40:25 +01:00
|
|
|
se.fetchPage();
|
|
|
|
assertEquals("CC BY 3.0", se.getLicence());
|
|
|
|
}
|
|
|
|
|
2020-05-25 20:22:23 +02:00
|
|
|
@Test
|
|
|
|
public void testTranslateIdsToUrl() throws ParsingException {
|
|
|
|
assertEquals("https://zachbenson.bandcamp.com/album/covers", BandcampExtractorHelper.getStreamUrlFromIds(2862267535L, 2063639444L, "album"));
|
|
|
|
// TODO write more test cases
|
|
|
|
}
|
2020-03-17 20:40:25 +01:00
|
|
|
|
2019-12-21 19:00:07 +01:00
|
|
|
}
|