mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-14 06:10:33 +05:30
Use List.isEmpty()
This commit is contained in:
parent
af2183855a
commit
e4c40ae6d1
@ -69,10 +69,8 @@ public class Response {
|
||||
public String getHeader(String name) {
|
||||
for (Map.Entry<String, List<String>> headerEntry : responseHeaders.entrySet()) {
|
||||
final String key = headerEntry.getKey();
|
||||
if (key != null && key.equalsIgnoreCase(name)) {
|
||||
if (headerEntry.getValue().size() > 0) {
|
||||
return headerEntry.getValue().get(0);
|
||||
}
|
||||
if (key != null && key.equalsIgnoreCase(name) && !headerEntry.getValue().isEmpty()) {
|
||||
return headerEntry.getValue().get(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||
info.addError(e);
|
||||
}
|
||||
// do not fail if everything but the uploader infos could be collected
|
||||
if (uploaderParsingErrors.size() > 0 &&
|
||||
if (!uploaderParsingErrors.isEmpty() &&
|
||||
(!info.getErrors().isEmpty() || uploaderParsingErrors.size() < 3)) {
|
||||
info.addAllErrors(uploaderParsingErrors);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class BandcampSearchExtractor extends SearchExtractor {
|
||||
|
||||
// Count pages
|
||||
final Elements pageLists = d.getElementsByClass("pagelist");
|
||||
if (pageLists.size() == 0)
|
||||
if (pageLists.isEmpty())
|
||||
return new InfoItemsPage<>(collector, null);
|
||||
|
||||
final Elements pages = pageLists.first().getElementsByTag("li");
|
||||
@ -96,7 +96,7 @@ public class BandcampSearchExtractor extends SearchExtractor {
|
||||
int currentPage = -1;
|
||||
for (int i = 0; i < pages.size(); i++) {
|
||||
final Element pageElement = pages.get(i);
|
||||
if (pageElement.getElementsByTag("span").size() > 0) {
|
||||
if (!pageElement.getElementsByTag("span").isEmpty()) {
|
||||
currentPage = i + 1;
|
||||
break;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class PeertubeService extends StreamingService {
|
||||
public SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler) {
|
||||
final List<String> contentFilters = queryHandler.getContentFilters();
|
||||
boolean external = false;
|
||||
if (contentFilters.size() > 0 && contentFilters.get(0).startsWith("sepia_")) {
|
||||
if (!contentFilters.isEmpty() && contentFilters.get(0).startsWith("sepia_")) {
|
||||
external = true;
|
||||
}
|
||||
return new PeertubeSearchExtractor(this, queryHandler, external);
|
||||
|
@ -24,7 +24,7 @@ public class PeertubeSearchQueryHandlerFactory extends SearchQueryHandlerFactory
|
||||
@Override
|
||||
public String getUrl(String searchString, List<String> contentFilters, String sortFilter) throws ParsingException {
|
||||
String baseUrl;
|
||||
if (contentFilters.size() > 0 && contentFilters.get(0).startsWith("sepia_")) {
|
||||
if (!contentFilters.isEmpty() && contentFilters.get(0).startsWith("sepia_")) {
|
||||
baseUrl = SEPIA_BASE_URL;
|
||||
} else {
|
||||
baseUrl = ServiceList.PeerTube.getBaseUrl();
|
||||
|
@ -89,7 +89,7 @@ public class SoundcloudParsingHelper {
|
||||
SoundcloudStreamExtractor e = (SoundcloudStreamExtractor) SoundCloud
|
||||
.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon");
|
||||
e.fetchPage();
|
||||
return e.getAudioStreams().size() >= 1;
|
||||
return !e.getAudioStreams().isEmpty();
|
||||
} catch (Exception ignored) {
|
||||
// No need to throw an exception here. If something went wrong, the client_id is wrong
|
||||
return false;
|
||||
|
@ -83,7 +83,7 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
|
||||
throw new ParsingException("Could not parse json response", e);
|
||||
}
|
||||
|
||||
if (searchCollection.size() == 0) {
|
||||
if (searchCollection.isEmpty()) {
|
||||
throw new SearchExtractor.NothingFoundException("Nothing found");
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class YoutubeService extends StreamingService {
|
||||
public SearchExtractor getSearchExtractor(SearchQueryHandler query) {
|
||||
final List<String> contentFilters = query.getContentFilters();
|
||||
|
||||
if (contentFilters.size() > 0 && contentFilters.get(0).startsWith("music_")) {
|
||||
if (!contentFilters.isEmpty() && contentFilters.get(0).startsWith("music_")) {
|
||||
return new YoutubeMusicSearchExtractor(this, query);
|
||||
} else {
|
||||
return new YoutubeSearchExtractor(this, query);
|
||||
|
@ -32,7 +32,7 @@ public class YoutubeSearchQueryHandlerFactory extends SearchQueryHandlerFactory
|
||||
@Override
|
||||
public String getUrl(String searchString, List<String> contentFilters, String sortFilter) throws ParsingException {
|
||||
try {
|
||||
if (contentFilters.size() > 0) {
|
||||
if (!contentFilters.isEmpty()) {
|
||||
switch (contentFilters.get(0)) {
|
||||
case ALL:
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user