diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistInfoItemExtractor.java index 5257691e6..61551bac5 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistInfoItemExtractor.java @@ -11,14 +11,14 @@ import java.io.IOException; public class BandcampPlaylistInfoItemExtractor implements PlaylistInfoItemExtractor { private String title, artist, url, cover; - private StreamingService service; + private int trackCount; - public BandcampPlaylistInfoItemExtractor(String title, String artist, String url, String cover, StreamingService service) { + public BandcampPlaylistInfoItemExtractor(String title, String artist, String url, String cover, int trackCount) { this.title = title; this.artist = artist; this.url = url; this.cover = cover; - this.service = service; + this.trackCount = trackCount; } @Override @@ -27,14 +27,8 @@ public class BandcampPlaylistInfoItemExtractor implements PlaylistInfoItemExtrac } @Override - public long getStreamCount() throws ParsingException { - try { - PlaylistExtractor extractor = service.getPlaylistExtractor(url); - extractor.fetchPage(); - return extractor.getStreamCount(); - } catch (ExtractionException | IOException e) { - throw new ParsingException("Could not find out how many tracks there are", e); - } + public long getStreamCount() { + return trackCount; } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampSearchExtractor.java index 31b1b4b84..6831cdf62 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampSearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampSearchExtractor.java @@ -74,7 +74,9 @@ public class BandcampSearchExtractor extends SearchExtractor { case "ALBUM": String artist = subhead.split(" by")[0]; - collector.commit(new BandcampPlaylistInfoItemExtractor(heading, artist, url, image, getService())); + String length = resultInfo.getElementsByClass("length").text(); + int tracks = Integer.parseInt(length.split(" track")[0]); + collector.commit(new BandcampPlaylistInfoItemExtractor(heading, artist, url, image, tracks)); break; case "TRACK": diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchExtractorTest.java index 8cffcf73e..1e6f9b579 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchExtractorTest.java @@ -85,7 +85,7 @@ public class BandcampSearchExtractorTest { assertTrue(minecraft.getThumbnailUrl().contains("f4.bcbits.com/img/")); assertEquals("https://c418.bandcamp.com/album/minecraft-volume-alpha", minecraft.getUrl()); - // Verify that playlists get counted correctly + // Verify that playlist tracks counts get extracted correctly assertEquals(24, ((PlaylistInfoItem) minecraft).getStreamCount()); }