diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Response.java b/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Response.java index b252d4638..c986f72d5 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Response.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Response.java @@ -69,10 +69,8 @@ public class Response { public String getHeader(String name) { for (Map.Entry> 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); } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java index 873d879ec..cd6df3744 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java @@ -106,7 +106,7 @@ public class PlaylistInfo extends ListInfo { 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); } 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 6888d6932..a0648304c 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 @@ -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; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java index ea1a78442..9d86ca992 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java @@ -63,7 +63,7 @@ public class PeertubeService extends StreamingService { public SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler) { final List 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); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeSearchQueryHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeSearchQueryHandlerFactory.java index 87cf6ed8c..a660a5bcc 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeSearchQueryHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeSearchQueryHandlerFactory.java @@ -24,7 +24,7 @@ public class PeertubeSearchQueryHandlerFactory extends SearchQueryHandlerFactory @Override public String getUrl(String searchString, List 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(); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java index 52e7fdae1..2afdc09ba 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java @@ -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; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudSearchExtractor.java index d5eebe984..20d7008ad 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudSearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudSearchExtractor.java @@ -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"); } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java index 6e7ab7407..edd459534 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java @@ -123,7 +123,7 @@ public class YoutubeService extends StreamingService { public SearchExtractor getSearchExtractor(SearchQueryHandler query) { final List 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); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeSearchQueryHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeSearchQueryHandlerFactory.java index cb3933a03..17e117a4c 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeSearchQueryHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeSearchQueryHandlerFactory.java @@ -32,7 +32,7 @@ public class YoutubeSearchQueryHandlerFactory extends SearchQueryHandlerFactory @Override public String getUrl(String searchString, List contentFilters, String sortFilter) throws ParsingException { try { - if (contentFilters.size() > 0) { + if (!contentFilters.isEmpty()) { switch (contentFilters.get(0)) { case ALL: default: