Bandcamp: fix loading uploader from streams in search

This commit is contained in:
Fynn Godau 2020-06-04 12:02:18 +02:00
parent 3940138fc5
commit de776561b0
2 changed files with 8 additions and 4 deletions

View File

@ -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

View File

@ -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<InfoItem> 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());