From de776561b0eeff079f614a97a2ecf1f46c6a1581 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Thu, 4 Jun 2020 12:02:18 +0200 Subject: [PATCH] Bandcamp: fix loading uploader from streams in search --- .../BandcampSearchStreamInfoItemExtractor.java | 8 +++++--- .../services/bandcamp/BandcampSearchExtractorTest.java | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampSearchStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampSearchStreamInfoItemExtractor.java index 51fbe019d..6d88edc1c 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampSearchStreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampSearchStreamInfoItemExtractor.java @@ -14,12 +14,14 @@ public class BandcampSearchStreamInfoItemExtractor extends BandcampStreamInfoIte } @Override - public String getUploaderName() throws ParsingException { + public String getUploaderName() { String subhead = resultInfo.getElementsByClass("subhead").text(); - String[] splitBy = subhead.split(" by"); + String[] splitBy = subhead.split("by "); if (splitBy.length > 1) { return splitBy[1]; - } else throw new ParsingException("Uploader name was not found as expected"); + } else { + return splitBy[0]; + } } @Override 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 ba8c147b5..a1b44b63b 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 @@ -15,6 +15,7 @@ import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampChannelInfoItemExtractor; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampPlaylistInfoItemExtractor; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampSearchExtractor; +import org.schabi.newpipe.extractor.stream.StreamInfoItem; import java.io.IOException; @@ -44,10 +45,11 @@ public class BandcampSearchExtractorTest { SearchExtractor extractor = Bandcamp.getSearchExtractor("best friend's basement"); ListExtractor.InfoItemsPage page = extractor.getInitialPage(); - InfoItem bestFriendsBasement = page.getItems().get(0); + StreamInfoItem bestFriendsBasement = (StreamInfoItem) page.getItems().get(0); // The track by Zach Benson should be the first result, no? assertEquals("Best Friend's Basement", bestFriendsBasement.getName()); + assertEquals("Zach Benson", bestFriendsBasement.getUploaderName()); assertTrue(bestFriendsBasement.getThumbnailUrl().endsWith(".jpg")); assertTrue(bestFriendsBasement.getThumbnailUrl().contains("f4.bcbits.com/img/")); assertEquals(InfoItem.InfoType.STREAM, bestFriendsBasement.getInfoType());