Add bandcamp playlists (albums)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
// Created by Fynn Godau 2019, licensed GNU GPL version 3 or later
|
||||
|
||||
package org.schabi.newpipe.extractor.services.bandcamp;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
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.playlist.PlaylistExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.bandcamp;
|
||||
|
||||
public class BandcampPlaylistExtractorTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCount() throws ExtractionException, IOException {
|
||||
PlaylistExtractor extractor = bandcamp.getPlaylistExtractor("https://macbenson.bandcamp.com/album/coming-of-age");
|
||||
extractor.fetchPage();
|
||||
|
||||
assertEquals(5, extractor.getStreamCount());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// 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.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampPlaylistLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampStreamLinkHandlerFactory;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test for {@link BandcampPlaylistLinkHandlerFactory}
|
||||
*/
|
||||
public class BandcampPlaylistLinkHandlerFactoryTest {
|
||||
|
||||
private static BandcampPlaylistLinkHandlerFactory linkHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
linkHandler = new BandcampPlaylistLinkHandlerFactory();
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptUrl() throws ParsingException {
|
||||
// Tests expecting false
|
||||
assertFalse(linkHandler.acceptUrl("http://interovgm.com/releases/"));
|
||||
assertFalse(linkHandler.acceptUrl("https://interovgm.com/releases"));
|
||||
assertFalse(linkHandler.acceptUrl("http://zachbenson.bandcamp.com"));
|
||||
assertFalse(linkHandler.acceptUrl("https://bandcamp.com"));
|
||||
assertFalse(linkHandler.acceptUrl("https://zachbenson.bandcamp.com/"));
|
||||
assertFalse(linkHandler.acceptUrl("https://zachbenson.bandcamp.com/track/kitchen"));
|
||||
assertFalse(linkHandler.acceptUrl("https://interovgm.com/track/title"));
|
||||
|
||||
// Tests expecting true
|
||||
assertTrue(linkHandler.acceptUrl("https://powertothequeerkids.bandcamp.com/album/power-to-the-queer-kids"));
|
||||
assertTrue(linkHandler.acceptUrl("https://zachbenson.bandcamp.com/album/prom"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class BandcampSearchExtractorTest {
|
||||
* the accordingly named song by Zach Benson
|
||||
*/
|
||||
@Test
|
||||
public void testBestFriendsBasement() throws ExtractionException, IOException {
|
||||
public void testStreamSearch() throws ExtractionException, IOException {
|
||||
SearchExtractor extractor = bandcamp.getSearchExtractor("best friend's basement");
|
||||
|
||||
ListExtractor.InfoItemsPage<InfoItem> page = extractor.getInitialPage();
|
||||
@@ -55,7 +55,7 @@ public class BandcampSearchExtractorTest {
|
||||
* Tests whether searching bandcamp for "C418" returns the artist's profile
|
||||
*/
|
||||
@Test
|
||||
public void testC418() throws ExtractionException, IOException {
|
||||
public void testChannelSearch() throws ExtractionException, IOException {
|
||||
SearchExtractor extractor = bandcamp.getSearchExtractor("C418");
|
||||
InfoItem c418 = extractor.getInitialPage()
|
||||
.getItems().get(0);
|
||||
@@ -67,4 +67,21 @@ public class BandcampSearchExtractorTest {
|
||||
assertEquals("https://c418.bandcamp.com", c418.getUrl());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether searching bandcamp for "minecraft volume alpha" returns the corresponding album
|
||||
*/
|
||||
@Test
|
||||
public void testAlbumSearch() throws ExtractionException, IOException {
|
||||
SearchExtractor extractor = bandcamp.getSearchExtractor("minecraft volume alpha");
|
||||
InfoItem minecraft = extractor.getInitialPage()
|
||||
.getItems().get(0);
|
||||
|
||||
// C418's artist profile should be the first result, no?
|
||||
assertEquals("Minecraft - Volume Alpha", minecraft.getName());
|
||||
assertTrue(minecraft.getThumbnailUrl().endsWith(".jpg"));
|
||||
assertTrue(minecraft.getThumbnailUrl().contains("f4.bcbits.com/img/"));
|
||||
assertEquals("https://c418.bandcamp.com/album/minecraft-volume-alpha", minecraft.getUrl());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user