diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampChannelExtractor.java index 21289801d..3f39603e6 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampChannelExtractor.java @@ -3,6 +3,7 @@ package org.schabi.newpipe.extractor.services.bandcamp.extractors; import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import org.jsoup.Jsoup; import org.schabi.newpipe.extractor.NewPipe; @@ -61,7 +62,12 @@ public class BandcampChannelExtractor extends ChannelExtractor { @Override public String getAvatarUrl() { - return getImageUrl(channelInfo.getLong("bio_image_id"), false); + try { + return getImageUrl(channelInfo.getLong("bio_image_id"), false); + } catch (JSONException e) { + // In this case, the id is null and no image is available + return ""; + } } /** @@ -82,6 +88,9 @@ public class BandcampChannelExtractor extends ChannelExtractor { } catch (IOException | ReCaptchaException e) { throw new ParsingException("Could not download artist web site", e); + } catch (NullPointerException e) { + // No banner available + return ""; } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampExtractorHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampExtractorHelper.java index b1668641c..b86504c62 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampExtractorHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampExtractorHelper.java @@ -85,7 +85,7 @@ public class BandcampExtractorHelper { // Remove empty strings ArrayList list = new ArrayList<>(Arrays.asList(strings)); for (int i = list.size() - 1; i >= 0; i--) { - if (list.get(i) == null || list.get(i).isEmpty()) { + if (list.get(i) == null || list.get(i).isEmpty() || list.get(i).equals("null")) { list.remove(i); } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java index 99a06d209..d924b4fb2 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java @@ -4,6 +4,7 @@ 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.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampChannelExtractor; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper; @@ -45,4 +46,14 @@ public class BandcampChannelExtractorTest { // Why is this picture in png format when all other pictures are jpg? assertTrue(extractor.getBannerUrl().endsWith(".png")); } + + @Test + public void testGetNoAvatar() throws ExtractionException { + assertEquals("", bandcamp.getChannelExtractor("https://powertothequeerkids.bandcamp.com/").getAvatarUrl()); + } + + @Test + public void testGetNoBanner() throws ExtractionException { + assertEquals("", bandcamp.getChannelExtractor("https://powertothequeerkids.bandcamp.com/").getBannerUrl()); + } }