diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChannelExtractor.java index 1068b36f..29582425 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChannelExtractor.java @@ -18,6 +18,7 @@ import javax.annotation.Nonnull; import java.io.IOException; import static org.schabi.newpipe.extractor.utils.JsonUtils.EMPTY_STRING; +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; @SuppressWarnings("WeakerAccess") public class SoundcloudChannelExtractor extends ChannelExtractor { @@ -132,7 +133,7 @@ public class SoundcloudChannelExtractor extends ChannelExtractor { @Override public InfoItemsPage getPage(final String pageUrl) throws IOException, ExtractionException { - if (pageUrl == null || pageUrl.isEmpty()) { + if (isNullOrEmpty(pageUrl)) { throw new ExtractionException(new IllegalArgumentException("Page url is empty or null")); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChartsExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChartsExtractor.java index 042af513..0c15d9c6 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChartsExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudChartsExtractor.java @@ -13,6 +13,7 @@ import javax.annotation.Nonnull; import java.io.IOException; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; public class SoundcloudChartsExtractor extends KioskExtractor { private StreamInfoItemsCollector collector = null; @@ -36,7 +37,7 @@ public class SoundcloudChartsExtractor extends KioskExtractor { @Override public InfoItemsPage getPage(String pageUrl) throws IOException, ExtractionException { - if (pageUrl == null || pageUrl.isEmpty()) { + if (isNullOrEmpty(pageUrl)) { throw new ExtractionException(new IllegalArgumentException("Page url is empty or null")); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudPlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudPlaylistExtractor.java index fc3910a8..4cff6bb6 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudPlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudPlaylistExtractor.java @@ -162,7 +162,7 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor { @Override public InfoItemsPage getPage(String pageUrl) throws IOException, ExtractionException { - if (pageUrl == null || pageUrl.isEmpty()) { + if (isNullOrEmpty(pageUrl)) { throw new ExtractionException(new IllegalArgumentException("Page url is empty or null")); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java index 02a528fb..e78168ab 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java @@ -391,7 +391,7 @@ public class YoutubeParsingHelper { * @return text in the JSON object or {@code null} */ public static String getTextFromObject(JsonObject textObject, boolean html) throws ParsingException { - if (textObject == null || textObject.isEmpty()) return null; + if (isNullOrEmpty(textObject)) return null; if (textObject.has("simpleText")) return textObject.getString("simpleText"); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java index d9771240..f5cfbc24 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java @@ -245,7 +245,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor { @Override public InfoItemsPage getPage(String pageUrl) throws IOException, ExtractionException { - if (pageUrl == null || pageUrl.isEmpty()) { + if (isNullOrEmpty(pageUrl)) { throw new ExtractionException(new IllegalArgumentException("Page url is empty or null")); } @@ -266,7 +266,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor { private String getNextPageUrlFrom(JsonArray continuations) { - if (continuations == null || continuations.isEmpty()) { + if (isNullOrEmpty(continuations)) { return ""; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java index 5a68501e..1dea2952 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java @@ -27,6 +27,7 @@ import java.util.Map; import java.util.regex.Pattern; import static java.util.Collections.singletonList; +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; public class YoutubeCommentsExtractor extends CommentsExtractor { @@ -91,7 +92,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor { @Override public InfoItemsPage getPage(String pageUrl) throws IOException, ExtractionException { - if (pageUrl == null || pageUrl.isEmpty()) { + if (isNullOrEmpty(pageUrl)) { throw new ExtractionException(new IllegalArgumentException("Page url is empty or null")); } String ajaxResponse = makeAjaxRequest(pageUrl); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMusicSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMusicSearchExtractor.java index 6159ab43..20fe8a08 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMusicSearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMusicSearchExtractor.java @@ -167,7 +167,7 @@ public class YoutubeMusicSearchExtractor extends SearchExtractor { @Override public InfoItemsPage getPage(final String pageUrl) throws IOException, ExtractionException { - if (pageUrl == null || pageUrl.isEmpty()) { + if (isNullOrEmpty(pageUrl)) { throw new ExtractionException(new IllegalArgumentException("Page url is empty or null")); } @@ -470,7 +470,7 @@ public class YoutubeMusicSearchExtractor extends SearchExtractor { } private String getNextPageUrlFrom(final JsonArray continuations) throws ParsingException, IOException, ReCaptchaException { - if (continuations == null || continuations.isEmpty()) { + if (isNullOrEmpty(continuations)) { return ""; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java index de2a0e71..b7c6d6c2 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java @@ -23,6 +23,7 @@ import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getJsonResponse; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getUrlFromNavigationEndpoint; +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; @SuppressWarnings("WeakerAccess") public class YoutubePlaylistExtractor extends PlaylistExtractor { @@ -93,11 +94,11 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor { String url = playlistInfo.getObject("thumbnailRenderer").getObject("playlistVideoThumbnailRenderer") .getObject("thumbnail").getArray("thumbnails").getObject(0).getString("url"); - if (url == null || url.isEmpty()) { + if (isNullOrEmpty(url)) { url = initialData.getObject("microformat").getObject("microformatDataRenderer").getObject("thumbnail") .getArray("thumbnails").getObject(0).getString("url"); - if (url == null || url.isEmpty()) throw new ParsingException("Could not get playlist thumbnail"); + if (isNullOrEmpty(url)) throw new ParsingException("Could not get playlist thumbnail"); } return fixThumbnailUrl(url); @@ -166,7 +167,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor { @Override public InfoItemsPage getPage(final String pageUrl) throws IOException, ExtractionException { - if (pageUrl == null || pageUrl.isEmpty()) { + if (isNullOrEmpty(pageUrl)) { throw new ExtractionException(new IllegalArgumentException("Page url is empty or null")); } @@ -182,7 +183,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor { } private String getNextPageUrlFrom(JsonArray continuations) { - if (continuations == null || continuations.isEmpty()) { + if (isNullOrEmpty(continuations)) { return ""; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java index 732ef09a..1ef19b82 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java @@ -19,6 +19,7 @@ import javax.annotation.Nonnull; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getJsonResponse; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject; +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; /* * Created by Christian Schabesberger on 22.07.2018 @@ -99,7 +100,7 @@ public class YoutubeSearchExtractor extends SearchExtractor { @Override public InfoItemsPage getPage(final String pageUrl) throws IOException, ExtractionException { - if (pageUrl == null || pageUrl.isEmpty()) { + if (isNullOrEmpty(pageUrl)) { throw new ExtractionException(new IllegalArgumentException("Page url is empty or null")); } @@ -133,7 +134,7 @@ public class YoutubeSearchExtractor extends SearchExtractor { } private String getNextPageUrlFrom(final JsonArray continuations) throws ParsingException { - if (continuations == null || continuations.isEmpty()) { + if (isNullOrEmpty(continuations)) { return ""; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index b5cdd21d..b543c14f 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -54,6 +54,7 @@ import javax.annotation.Nullable; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.*; import static org.schabi.newpipe.extractor.utils.JsonUtils.EMPTY_STRING; +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; /* * Created by Christian Schabesberger on 06.08.15. @@ -116,10 +117,10 @@ public class YoutubeStreamExtractor extends StreamExtractor { assertPageFetched(); String title = getTextFromObject(getVideoPrimaryInfoRenderer().getObject("title")); - if (title == null || title.isEmpty()) { + if (isNullOrEmpty(title)) { title = playerResponse.getObject("videoDetails").getString("title"); - if (title == null || title.isEmpty()) throw new ParsingException("Could not get name"); + if (isNullOrEmpty(title)) throw new ParsingException("Could not get name"); } return title; @@ -167,7 +168,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { public DateWrapper getUploadDate() throws ParsingException { final String textualUploadDate = getTextualUploadDate(); - if (textualUploadDate == null || textualUploadDate.isEmpty()) { + if (isNullOrEmpty(textualUploadDate)) { return null; } @@ -204,7 +205,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { @Override public int getAgeLimit() { - if (initialData == null || initialData.isEmpty()) throw new IllegalStateException("initialData is not parsed yet"); + if (isNullOrEmpty(initialData)) throw new IllegalStateException("initialData is not parsed yet"); return ageLimit; } @@ -248,10 +249,10 @@ public class YoutubeStreamExtractor extends StreamExtractor { String views = getTextFromObject(getVideoPrimaryInfoRenderer().getObject("viewCount") .getObject("videoViewCountRenderer").getObject("viewCount")); - if (views == null || views.isEmpty()) { + if (isNullOrEmpty(views)) { views = playerResponse.getObject("videoDetails").getString("viewCount"); - if (views == null || views.isEmpty()) throw new ParsingException("Could not get view count"); + if (isNullOrEmpty(views)) throw new ParsingException("Could not get view count"); } if (views.toLowerCase().contains("no views")) return 0; @@ -329,10 +330,10 @@ public class YoutubeStreamExtractor extends StreamExtractor { String uploaderName = getTextFromObject(getVideoSecondaryInfoRenderer().getObject("owner") .getObject("videoOwnerRenderer").getObject("title")); - if (uploaderName == null || uploaderName.isEmpty()) { + if (isNullOrEmpty(uploaderName)) { uploaderName = playerResponse.getObject("videoDetails").getString("author"); - if (uploaderName == null || uploaderName.isEmpty()) throw new ParsingException("Could not get uploader name"); + if (isNullOrEmpty(uploaderName)) throw new ParsingException("Could not get uploader name"); } return uploaderName; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java index d115fdee..0757208e 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java @@ -106,7 +106,7 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor { String duration = getTextFromObject(videoInfo.getObject("lengthText")); - if (duration == null || duration.isEmpty()) { + if (isNullOrEmpty(duration)) { for (Object thumbnailOverlay : videoInfo.getArray("thumbnailOverlays")) { if (((JsonObject) thumbnailOverlay).has("thumbnailOverlayTimeStatusRenderer")) { duration = getTextFromObject(((JsonObject) thumbnailOverlay) @@ -114,7 +114,7 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor { } } - if (duration == null || duration.isEmpty()) throw new ParsingException("Could not get duration"); + if (isNullOrEmpty(duration)) throw new ParsingException("Could not get duration"); } return YoutubeParsingHelper.parseDurationString(duration); @@ -124,13 +124,13 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor { public String getUploaderName() throws ParsingException { String name = getTextFromObject(videoInfo.getObject("longBylineText")); - if (name == null || name.isEmpty()) { + if (isNullOrEmpty(name)) { name = getTextFromObject(videoInfo.getObject("ownerText")); - if (name == null || name.isEmpty()) { + if (isNullOrEmpty(name)) { name = getTextFromObject(videoInfo.getObject("shortBylineText")); - if (name == null || name.isEmpty()) throw new ParsingException("Could not get uploader name"); + if (isNullOrEmpty(name)) throw new ParsingException("Could not get uploader name"); } } @@ -142,15 +142,15 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor { String url = getUrlFromNavigationEndpoint(videoInfo.getObject("longBylineText") .getArray("runs").getObject(0).getObject("navigationEndpoint")); - if (url == null || url.isEmpty()) { + if (isNullOrEmpty(url)) { url = getUrlFromNavigationEndpoint(videoInfo.getObject("ownerText") .getArray("runs").getObject(0).getObject("navigationEndpoint")); - if (url == null || url.isEmpty()) { + if (isNullOrEmpty(url)) { url = getUrlFromNavigationEndpoint(videoInfo.getObject("shortBylineText") .getArray("runs").getObject(0).getObject("navigationEndpoint")); - if (url == null || url.isEmpty()) throw new ParsingException("Could not get uploader url"); + if (isNullOrEmpty(url)) throw new ParsingException("Could not get uploader url"); } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Stream.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Stream.java index b48eeab2..7e990816 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Stream.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Stream.java @@ -5,6 +5,8 @@ import org.schabi.newpipe.extractor.MediaFormat; import java.io.Serializable; import java.util.List; +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; + /** * Creates a stream object from url, format and optional torrent url */ @@ -61,7 +63,7 @@ public abstract class Stream implements Serializable { * Check if the list already contains one stream with equals stats */ public static boolean containSimilarStream(Stream stream, List streamList) { - if (stream == null || streamList == null) return false; + if (isNullOrEmpty(streamList)) return false; for (Stream cmpStream : streamList) { if (stream.equalStats(cmpStream)) return true; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java index 6ee60ce8..3878e593 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java @@ -105,7 +105,7 @@ public class StreamInfo extends Info { String name = extractor.getName(); int ageLimit = extractor.getAgeLimit(); - if ((streamType == StreamType.NONE) || (url == null || url.isEmpty()) || (id == null || id.isEmpty()) + if ((streamType == StreamType.NONE) || isNullOrEmpty(url) || (isNullOrEmpty(id)) || (name == null /* streamInfo.title can be empty of course */) || (ageLimit == -1)) { throw new ExtractionException("Some important stream information was not given."); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/utils/Utils.java b/extractor/src/main/java/org/schabi/newpipe/extractor/utils/Utils.java index 3029fdd2..b1a9ab34 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/utils/Utils.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/utils/Utils.java @@ -1,5 +1,6 @@ package org.schabi.newpipe.extractor.utils; +import com.grack.nanojson.JsonObject; import org.schabi.newpipe.extractor.exceptions.ParsingException; import java.io.UnsupportedEncodingException; @@ -8,6 +9,7 @@ import java.net.URL; import java.net.URLDecoder; import java.util.Collection; import java.util.List; +import java.util.Map; public class Utils { @@ -72,7 +74,7 @@ public class Utils { * @param url the url to be tested */ public static void checkUrl(String pattern, String url) throws ParsingException { - if (url == null || url.isEmpty()) { + if (isNullOrEmpty(url)) { throw new IllegalArgumentException("Url can't be null or empty"); } @@ -193,7 +195,13 @@ public class Utils { return str == null || str.isEmpty(); } + // can be used for JsonArrays public static boolean isNullOrEmpty(final Collection collection) { return collection == null || collection.isEmpty(); } + + // can be used for JsonObjects + public static boolean isNullOrEmpty(final Map map) { + return map == null || map.isEmpty(); + } } \ No newline at end of file diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultSearchExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultSearchExtractorTest.java index 93c4eac7..250df78f 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultSearchExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultSearchExtractorTest.java @@ -8,6 +8,7 @@ import javax.annotation.Nullable; import static org.junit.Assert.assertEquals; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty; +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; public abstract class DefaultSearchExtractorTest extends DefaultListExtractorTest implements BaseSearchExtractorTest { @@ -25,7 +26,7 @@ public abstract class DefaultSearchExtractorTest extends DefaultListExtractorTes @Override public void testSearchSuggestion() throws Exception { final String expectedSearchSuggestion = expectedSearchSuggestion(); - if (expectedSearchSuggestion == null || expectedSearchSuggestion.isEmpty()) { + if (isNullOrEmpty(expectedSearchSuggestion)) { assertEmpty("Suggestion was expected to be empty", extractor().getSearchSuggestion()); } else { assertEquals(expectedSearchSuggestion, extractor().getSearchSuggestion()); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultTests.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultTests.java index eaff6acb..82f75298 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultTests.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultTests.java @@ -86,7 +86,7 @@ public final class DefaultTests { public static void assertNoMoreItems(ListExtractor extractor) throws Exception { assertFalse("More items available when it shouldn't", extractor.hasNextPage()); final String nextPageUrl = extractor.getNextPageUrl(); - assertTrue("Next page is not empty or null", nextPageUrl == null || nextPageUrl.isEmpty()); + assertTrue("Next page is not empty or null", isNullOrEmpty(nextPageUrl)); } public static void assertNoDuplicatedItems(StreamingService expectedService, diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java index d5f2f1af..29fab054 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java @@ -20,6 +20,7 @@ import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors; import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoDuplicatedItems; import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.*; +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; public class YoutubeSearchExtractorTest { public static class All extends DefaultSearchExtractorTest { @@ -170,7 +171,7 @@ public class YoutubeSearchExtractorTest { assertFalse("More items available when it shouldn't", nextEmptyPage.hasNextPage()); final String nextPageUrl = nextEmptyPage.getNextPageUrl(); - assertTrue("Next page is not empty or null", nextPageUrl == null || nextPageUrl.isEmpty()); + assertTrue("Next page is not empty or null", isNullOrEmpty(nextPageUrl)); } }