Bandcamp stream extractor: catch NullPointerException
This commit is contained in:
parent
d5cdc20be1
commit
91c0ec7cea
|
@ -109,7 +109,11 @@ public class BandcampStreamExtractor extends StreamExtractor {
|
|||
@Nonnull
|
||||
@Override
|
||||
public String getUploaderAvatarUrl() {
|
||||
return document.getElementsByClass("band-photo").first().attr("src");
|
||||
try {
|
||||
return document.getElementsByClass("band-photo").first().attr("src");
|
||||
} catch (NullPointerException e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -61,6 +61,11 @@ public class BandcampStreamExtractorTest {
|
|||
assertTrue(url.contains("://f4.bcbits.com/img/") && url.endsWith(".jpg"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoArtistProfilePicture() throws ExtractionException {
|
||||
assertEquals("", bandcamp.getStreamExtractor("https://powertothequeerkids.bandcamp.com/track/human-nature").getUploaderAvatarUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAudioStream() {
|
||||
assertTrue(extractor.getAudioStreams().get(0).getUrl().contains("bcbits.com/stream"));
|
||||
|
|
|
@ -38,6 +38,7 @@ public class BandcampStreamLinkHandlerFactoryTest {
|
|||
assertFalse(linkHandler.acceptUrl("http://zachbenson.bandcamp.com"));
|
||||
assertFalse(linkHandler.acceptUrl("https://bandcamp.com"));
|
||||
assertFalse(linkHandler.acceptUrl("https://zachbenson.bandcamp.com/"));
|
||||
assertFalse(linkHandler.acceptUrl("https://powertothequeerkids.bandcamp.com/album/power-to-the-queer-kids"));
|
||||
|
||||
// Tests expecting true
|
||||
assertTrue(linkHandler.acceptUrl("https://zachbenson.bandcamp.com/track/kitchen"));
|
||||
|
|
Loading…
Reference in New Issue