From db02850d4f899e2226e2fcc99dd39bbcb70b0091 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Sun, 22 Dec 2019 14:12:24 +0100 Subject: [PATCH] Bandcamp playlist extractor: support playlists with just one stream --- .../extractors/BandcampPlaylistExtractor.java | 6 +++--- .../bandcamp/BandcampPlaylistExtractorTest.java | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistExtractor.java index 4544644ea..e24e603de 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistExtractor.java @@ -49,9 +49,9 @@ public class BandcampPlaylistExtractor extends PlaylistExtractor { - if (trackInfo.length() <= 1) { - // In this case, we are actually viewing a track page! - throw new ContentNotAvailableException("Album needs to be purchased or is actually a track"); + if (trackInfo.length() < 0) { + // Albums without trackInfo need to be purchased before they can be played + throw new ContentNotAvailableException("Album needs to be purchased"); } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java index c6572974a..7400b1821 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java @@ -60,4 +60,16 @@ public class BandcampPlaylistExtractorTest { PlaylistExtractor extractor = bandcamp.getPlaylistExtractor("https://billwurtz.bandcamp.com/album/high-enough"); extractor.fetchPage(); } + + /** + * Test playlist with just one track + */ + @Test + public void testSingleStreamPlaylist() throws ExtractionException, IOException { + PlaylistExtractor extractor = bandcamp.getPlaylistExtractor("https://zachjohnson1.bandcamp.com/album/endless"); + extractor.fetchPage(); + + assertEquals(1, extractor.getStreamCount()); + + } }