Add bandcamp weekly kiosk

Unfortunately a little messy
This commit is contained in:
Fynn Godau
2019-12-22 17:30:22 +01:00
parent 13ef11e9c8
commit 808c8aa087
12 changed files with 477 additions and 28 deletions

View File

@@ -31,7 +31,7 @@ public class BandcampFeaturedExtractorTest {
}
@Test
public void testKioskItems() throws ExtractionException, IOException {
public void testFeaturedCount() throws ExtractionException, IOException {
List<InfoItem> list = extractor.getInitialPage().getItems();
assertTrue(list.size() > 1);
}

View File

@@ -0,0 +1,52 @@
// 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.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampFeaturedLinkHandlerFactory;
import static org.junit.Assert.*;
/**
* Tests for {@link BandcampFeaturedLinkHandlerFactory}
*/
public class BandcampFeaturedLinkHandlerFactoryTest {
private static BandcampFeaturedLinkHandlerFactory linkHandler;
@BeforeClass
public static void setUp() {
linkHandler = new BandcampFeaturedLinkHandlerFactory();
}
@Test
public void testAcceptUrl() throws ParsingException {
// Tests expecting true
assertTrue(linkHandler.acceptUrl("https://bandcamp.com/?show=1"));
assertTrue(linkHandler.acceptUrl("http://bandcamp.com/?show=2"));
assertTrue(linkHandler.acceptUrl("https://bandcamp.com/api/mobile/24/bootstrap_data"));
assertTrue(linkHandler.acceptUrl("https://bandcamp.com/api/bcweekly/1/list"));
// Tests expecting false
assertFalse(linkHandler.acceptUrl("https://bandcamp.com/?show="));
assertFalse(linkHandler.acceptUrl("https://bandcamp.com/?show=a"));
assertFalse(linkHandler.acceptUrl("https://bandcamp.com/"));
}
@Test
public void testGetUrl() throws ParsingException {
assertEquals("https://bandcamp.com/api/mobile/24/bootstrap_data", linkHandler.getUrl("Featured"));
assertEquals("https://bandcamp.com/api/bcweekly/1/list", linkHandler.getUrl("Radio"));
}
@Test
public void testGetId() {
assertEquals("Featured", linkHandler.getId("https://bandcamp.com/api/mobile/24/bootstrap_data"));
assertEquals("Radio", linkHandler.getId("http://bandcamp.com/?show=1"));
assertEquals("Radio", linkHandler.getId("https://bandcamp.com/api/bcweekly/1/list"));
}
}

View File

@@ -0,0 +1,40 @@
// 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.InfoItem;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampRadioExtractor;
import java.io.IOException;
import java.util.List;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.bandcamp;
/**
* Tests for {@link BandcampRadioExtractor}
*/
public class BandcampRadioExtractorTest {
private static BandcampRadioExtractor extractor;
@BeforeClass
public static void setUp() throws ExtractionException, IOException {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (BandcampRadioExtractor) bandcamp
.getKioskList()
.getExtractorById("Radio", null);
}
@Test
public void testRadioCount() throws ExtractionException, IOException {
List<InfoItem> list = bandcamp.getKioskList().getExtractorById("Radio", null).getInitialPage().getItems();
System.out.println(list.size());
assertTrue(list.size() > 300);
}
}

View File

@@ -0,0 +1,37 @@
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.Extractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampRadioStreamExtractor;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamExtractor;
import java.io.IOException;
import static org.junit.Assert.*;
import static org.schabi.newpipe.extractor.ServiceList.bandcamp;
public class BandcampRadioStreamExtractorTest {
@BeforeClass
public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance());
}
@Test
public void testGettingCorrectStreamExtractor() throws ExtractionException {
assertTrue(bandcamp.getStreamExtractor("https://bandcamp.com/?show=3") instanceof BandcampRadioStreamExtractor);
assertFalse(bandcamp.getStreamExtractor("https://zachbenson.bandcamp.com/track/deflated") instanceof BandcampRadioStreamExtractor);
}
@Test
public void testExtracting() throws ExtractionException, IOException {
BandcampRadioStreamExtractor e = (BandcampRadioStreamExtractor) bandcamp.getStreamExtractor("https://bandcamp.com/?show=230");
e.fetchPage();
assertEquals("Sound Movements", e.getName());
assertEquals("Andrew Jervis", e.getUploaderName());
}
}

View File

@@ -30,6 +30,16 @@ public class BandcampStreamLinkHandlerFactoryTest {
assertEquals("https://zachbenson.bandcamp.com/track/u-i-tonite", linkHandler.getUrl("http://ZachBenson.Bandcamp.COM/Track/U-I-Tonite/"));
}
@Test
public void testGetRadioUrl() {
assertEquals("https://bandcamp.com/?show=1", linkHandler.getUrl("1"));
}
@Test
public void testGetRadioId() throws ParsingException {
assertEquals("2", linkHandler.getId("https://bandcamp.com/?show=2"));
}
@Test
public void testAcceptUrl() throws ParsingException {
// Tests expecting false
@@ -44,5 +54,6 @@ public class BandcampStreamLinkHandlerFactoryTest {
assertTrue(linkHandler.acceptUrl("https://zachbenson.bandcamp.com/track/kitchen"));
assertTrue(linkHandler.acceptUrl("http://ZachBenson.Bandcamp.COM/Track/U-I-Tonite/"));
assertTrue(linkHandler.acceptUrl("https://interovgm.com/track/title"));
assertTrue(linkHandler.acceptUrl("http://bandcamP.com/?show=38"));
}
}