Bandcamp channel extractor (ignoring everything but tracks)

This commit is contained in:
Fynn Godau
2019-12-22 00:42:26 +01:00
parent 5281456899
commit a42c77425d
11 changed files with 252 additions and 30 deletions

View File

@@ -0,0 +1,42 @@
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.ParsingException;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampChannelExtractor;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.bandcamp;
public class BandcampChannelExtractorTest {
private static BandcampChannelExtractor extractor;
@BeforeClass
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (BandcampChannelExtractor) bandcamp
.getChannelExtractor("https://zachbenson.bandcamp.com/");
}
@Test
public void testImageUrl() {
assertEquals("https://f4.bcbits.com/img/a2405652335_10.jpg", BandcampChannelExtractor.getImageUrl(2405652335L, true));
assertEquals("https://f4.bcbits.com/img/17433693_10.jpg", BandcampChannelExtractor.getImageUrl(17433693L, false));
}
@Test
public void testTranslateIdsToUrl() throws ParsingException {
assertEquals("https://zachbenson.bandcamp.com/album/covers", BandcampExtractorHelper.getStreamUrlFromIds(2862267535L, 2063639444L, "album"));
// TODO write more test cases
}
@Test
public void testLength() throws ParsingException {
assertTrue(extractor.getInitialPage().getItems().size() > 2);
}
}

View File

@@ -51,4 +51,14 @@ public class BandcampChannelLinkHandlerFactoryTest {
assertEquals("https://infiniteammo.bandcamp.com", linkHandler.getUrl("3321800855"));
}
@Test(expected = ParsingException.class)
public void testGetUrlWithInvalidId() throws ParsingException {
linkHandler.getUrl("0");
}
@Test(expected = ParsingException.class)
public void testGetIdWithInvalidUrl() throws ParsingException {
linkHandler.getId("https://bandcamp.com");
}
}

View File

@@ -67,4 +67,9 @@ public class BandcampStreamExtractorTest {
assertEquals(1, extractor.getAudioStreams().size());
}
@Test(expected = ParsingException.class)
public void testInvalidUrl() throws ExtractionException {
bandcamp.getStreamExtractor("https://bandcamp.com");
}
}