Bandcamp search: multiple pages

This commit is contained in:
Fynn Godau
2019-12-22 13:51:17 +01:00
parent ce2a88e56f
commit 9b16baffb7
4 changed files with 47 additions and 7 deletions

View File

@@ -89,4 +89,17 @@ public class BandcampSearchExtractorTest {
assertEquals(24, ((PlaylistInfoItem) minecraft).getStreamCount());
}
/**
* Tests searches with multiple pages
*/
@Test
public void testMultiplePages() throws ExtractionException, IOException {
// A query practically guaranteed to have the maximum amount of pages
SearchExtractor extractor = bandcamp.getSearchExtractor("e");
assertEquals("https://bandcamp.com/search?q=e&page=2", extractor.getInitialPage().getNextPageUrl());
assertEquals("https://bandcamp.com/search?q=e&page=3", extractor.getPage(extractor.getNextPageUrl()).getNextPageUrl());
}
}

View File

@@ -27,8 +27,8 @@ public class BandcampSearchQueryHandlerFactoryTest {
@Test
public void testEncoding() throws ParsingException {
// Note: this isn't exactly as bandcamp does it (it wouldn't encode '!'), but both works
assertEquals("https://bandcamp.com/search?q=hello%21%22%C2%A7%24%25%26%2F%28%29%3D", searchQuery.getUrl("hello!\"§$%&/()="));
assertEquals("https://bandcamp.com/search?q=hello%21%22%C2%A7%24%25%26%2F%28%29%3D&page=1", searchQuery.getUrl("hello!\"§$%&/()="));
// Note: bandcamp uses %20 instead of '+', but both works
assertEquals("https://bandcamp.com/search?q=search+query+with+spaces", searchQuery.getUrl("search query with spaces"));
assertEquals("https://bandcamp.com/search?q=search+query+with+spaces&page=1", searchQuery.getUrl("search query with spaces"));
}
}