Apply suggestions: improve switch and use EMPTY_STRING

This commit is contained in:
Stypox 2022-04-30 16:39:51 +02:00
parent 8c1041def6
commit c2b5370517
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
2 changed files with 8 additions and 8 deletions

View File

@ -18,6 +18,7 @@ import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
import org.schabi.newpipe.extractor.MultiInfoItemsCollector; import org.schabi.newpipe.extractor.MultiInfoItemsCollector;
import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.search.SearchExtractor;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.streaminfoitem.BandcampSearchStreamInfoItemExtractor; import org.schabi.newpipe.extractor.services.bandcamp.extractors.streaminfoitem.BandcampSearchStreamInfoItemExtractor;
import org.schabi.newpipe.extractor.utils.Utils;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
@ -34,7 +35,7 @@ public class BandcampSearchExtractor extends SearchExtractor {
@NonNull @NonNull
@Override @Override
public String getSearchSuggestion() { public String getSearchSuggestion() {
return ""; return Utils.EMPTY_STRING;
} }
@Override @Override
@ -58,13 +59,9 @@ public class BandcampSearchExtractor extends SearchExtractor {
.flatMap(element -> element.getElementsByClass("itemtype").stream()) .flatMap(element -> element.getElementsByClass("itemtype").stream())
.map(Element::text) .map(Element::text)
.findFirst() .findFirst()
.orElse(""); .orElse(Utils.EMPTY_STRING);
switch (type) { switch (type) {
default:
case "FAN":
// don't display fan results
break;
case "ARTIST": case "ARTIST":
collector.commit(new BandcampChannelInfoItemExtractor(searchResult)); collector.commit(new BandcampChannelInfoItemExtractor(searchResult));
break; break;
@ -74,6 +71,9 @@ public class BandcampSearchExtractor extends SearchExtractor {
case "TRACK": case "TRACK":
collector.commit(new BandcampSearchStreamInfoItemExtractor(searchResult, null)); collector.commit(new BandcampSearchStreamInfoItemExtractor(searchResult, null));
break; break;
default:
// don't display fan results ("FAN") or other things
break;
} }
} }

View File

@ -119,7 +119,7 @@ public class BandcampStreamExtractor extends StreamExtractor {
@Override @Override
public String getThumbnailUrl() throws ParsingException { public String getThumbnailUrl() throws ParsingException {
if (albumJson.isNull("art_id")) { if (albumJson.isNull("art_id")) {
return ""; return Utils.EMPTY_STRING;
} else { } else {
return getImageUrl(albumJson.getLong("art_id"), true); return getImageUrl(albumJson.getLong("art_id"), true);
} }
@ -131,7 +131,7 @@ public class BandcampStreamExtractor extends StreamExtractor {
return document.getElementsByClass("band-photo").stream() return document.getElementsByClass("band-photo").stream()
.map(element -> element.attr("src")) .map(element -> element.attr("src"))
.findFirst() .findFirst()
.orElse(""); .orElse(Utils.EMPTY_STRING);
} }
@Nonnull @Nonnull