Remove EMPTY_STRING.

This commit is contained in:
Isira Seneviratne 2022-08-15 09:19:40 +05:30
parent 20914a6035
commit 943b7c033b
34 changed files with 188 additions and 216 deletions

View File

@ -6,7 +6,6 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.localization.DateWrapper; import org.schabi.newpipe.extractor.localization.DateWrapper;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeCommentsInfoItemExtractor; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeCommentsInfoItemExtractor;
import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.utils.Utils;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -36,14 +35,14 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {
* It may be language dependent * It may be language dependent
*/ */
default String getTextualLikeCount() throws ParsingException { default String getTextualLikeCount() throws ParsingException {
return Utils.EMPTY_STRING; return "";
} }
/** /**
* The text of the comment * The text of the comment
*/ */
default String getCommentText() throws ParsingException { default String getCommentText() throws ParsingException {
return Utils.EMPTY_STRING; return "";
} }
/** /**
@ -52,7 +51,7 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {
* @see StreamExtractor#getTextualUploadDate() * @see StreamExtractor#getTextualUploadDate()
*/ */
default String getTextualUploadDate() throws ParsingException { default String getTextualUploadDate() throws ParsingException {
return Utils.EMPTY_STRING; return "";
} }
/** /**
@ -66,19 +65,19 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {
} }
default String getCommentId() throws ParsingException { default String getCommentId() throws ParsingException {
return Utils.EMPTY_STRING; return "";
} }
default String getUploaderUrl() throws ParsingException { default String getUploaderUrl() throws ParsingException {
return Utils.EMPTY_STRING; return "";
} }
default String getUploaderName() throws ParsingException { default String getUploaderName() throws ParsingException {
return Utils.EMPTY_STRING; return "";
} }
default String getUploaderAvatarUrl() throws ParsingException { default String getUploaderAvatarUrl() throws ParsingException {
return Utils.EMPTY_STRING; return "";
} }
/** /**

View File

@ -1,7 +1,5 @@
package org.schabi.newpipe.extractor.linkhandler; package org.schabi.newpipe.extractor.linkhandler;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -32,7 +30,7 @@ public class ListLinkHandler extends LinkHandler {
handler.url, handler.url,
handler.id, handler.id,
Collections.emptyList(), Collections.emptyList(),
EMPTY_STRING); "");
} }
public List<String> getContentFilters() { public List<String> getContentFilters() {

View File

@ -1,7 +1,5 @@
package org.schabi.newpipe.extractor.linkhandler; package org.schabi.newpipe.extractor.linkhandler;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.util.Collections; import java.util.Collections;
@ -39,7 +37,7 @@ public abstract class SearchQueryHandlerFactory extends ListLinkHandlerFactory {
} }
public SearchQueryHandler fromQuery(final String query) throws ParsingException { public SearchQueryHandler fromQuery(final String query) throws ParsingException {
return fromQuery(query, Collections.emptyList(), EMPTY_STRING); return fromQuery(query, Collections.emptyList(), "");
} }
/** /**

View File

@ -8,8 +8,6 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> { public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
public PlaylistExtractor(final StreamingService service, final ListLinkHandler linkHandler) { public PlaylistExtractor(final StreamingService service, final ListLinkHandler linkHandler) {
@ -25,29 +23,29 @@ public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
@Nonnull @Nonnull
public String getThumbnailUrl() throws ParsingException { public String getThumbnailUrl() throws ParsingException {
return EMPTY_STRING; return "";
} }
@Nonnull @Nonnull
public String getBannerUrl() throws ParsingException { public String getBannerUrl() throws ParsingException {
// Banner can't be handled by frontend right now. // Banner can't be handled by frontend right now.
// Whoever is willing to implement this should also implement it in the frontend. // Whoever is willing to implement this should also implement it in the frontend.
return EMPTY_STRING; return "";
} }
@Nonnull @Nonnull
public String getSubChannelName() throws ParsingException { public String getSubChannelName() throws ParsingException {
return EMPTY_STRING; return "";
} }
@Nonnull @Nonnull
public String getSubChannelUrl() throws ParsingException { public String getSubChannelUrl() throws ParsingException {
return EMPTY_STRING; return "";
} }
@Nonnull @Nonnull
public String getSubChannelAvatarUrl() throws ParsingException { public String getSubChannelAvatarUrl() throws ParsingException {
return EMPTY_STRING; return "";
} }
public PlaylistInfo.PlaylistType getPlaylistType() throws ParsingException { public PlaylistInfo.PlaylistType getPlaylistType() throws ParsingException {

View File

@ -3,7 +3,6 @@ package org.schabi.newpipe.extractor.services.bandcamp.extractors;
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImageUrl; import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImageUrl;
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamExtractor.getAlbumInfoJson; import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamExtractor.getAlbumInfoJson;
import static org.schabi.newpipe.extractor.utils.JsonUtils.getJsonData; import static org.schabi.newpipe.extractor.utils.JsonUtils.getJsonData;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.HTTPS; import static org.schabi.newpipe.extractor.utils.Utils.HTTPS;
import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonArray;
@ -73,7 +72,7 @@ public class BandcampPlaylistExtractor extends PlaylistExtractor {
@Override @Override
public String getThumbnailUrl() throws ParsingException { public String getThumbnailUrl() throws ParsingException {
if (albumJson.isNull("art_id")) { if (albumJson.isNull("art_id")) {
return EMPTY_STRING; return "";
} else { } else {
return getImageUrl(albumJson.getLong("art_id"), true); return getImageUrl(albumJson.getLong("art_id"), true);
} }
@ -96,7 +95,7 @@ public class BandcampPlaylistExtractor extends PlaylistExtractor {
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(EMPTY_STRING); .orElse("");
} }
@Override @Override

View File

@ -1,9 +1,14 @@
package org.schabi.newpipe.extractor.services.bandcamp.extractors; package org.schabi.newpipe.extractor.services.bandcamp.extractors;
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.BASE_API_URL;
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.BASE_URL;
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImageUrl;
import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser; import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException; import com.grack.nanojson.JsonParserException;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
import org.schabi.newpipe.extractor.MediaFormat; import org.schabi.newpipe.extractor.MediaFormat;
@ -20,17 +25,13 @@ import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.Description; import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamSegment; import org.schabi.newpipe.extractor.stream.StreamSegment;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.BASE_API_URL; import javax.annotation.Nonnull;
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.BASE_URL; import javax.annotation.Nullable;
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImageUrl;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
public class BandcampRadioStreamExtractor extends BandcampStreamExtractor { public class BandcampRadioStreamExtractor extends BandcampStreamExtractor {
@ -163,14 +164,14 @@ public class BandcampRadioStreamExtractor extends BandcampStreamExtractor {
@Override @Override
public String getLicence() { public String getLicence() {
// Contrary to other Bandcamp streams, radio streams don't have a license // Contrary to other Bandcamp streams, radio streams don't have a license
return EMPTY_STRING; return "";
} }
@Nonnull @Nonnull
@Override @Override
public String getCategory() { public String getCategory() {
// Contrary to other Bandcamp streams, radio streams don't have categories // Contrary to other Bandcamp streams, radio streams don't have categories
return EMPTY_STRING; return "";
} }
@Nonnull @Nonnull

View File

@ -2,29 +2,30 @@
package org.schabi.newpipe.extractor.services.bandcamp.extractors; package org.schabi.newpipe.extractor.services.bandcamp.extractors;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.MetaInfo; import org.schabi.newpipe.extractor.MetaInfo;
import org.schabi.newpipe.extractor.MultiInfoItemsCollector;
import org.schabi.newpipe.extractor.Page; import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.downloader.Downloader; import org.schabi.newpipe.extractor.downloader.Downloader;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler; import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
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 java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.annotations.NonNull;
public class BandcampSearchExtractor extends SearchExtractor { public class BandcampSearchExtractor extends SearchExtractor {
public BandcampSearchExtractor(final StreamingService service, public BandcampSearchExtractor(final StreamingService service,
@ -35,7 +36,7 @@ public class BandcampSearchExtractor extends SearchExtractor {
@NonNull @NonNull
@Override @Override
public String getSearchSuggestion() { public String getSearchSuggestion() {
return Utils.EMPTY_STRING; return "";
} }
@Override @Override
@ -59,7 +60,7 @@ 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(Utils.EMPTY_STRING); .orElse("");
switch (type) { switch (type) {
case "ARTIST": case "ARTIST":

View File

@ -3,7 +3,6 @@
package org.schabi.newpipe.extractor.services.bandcamp.extractors; package org.schabi.newpipe.extractor.services.bandcamp.extractors;
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImageUrl; import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImageUrl;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.HTTPS; import static org.schabi.newpipe.extractor.utils.Utils.HTTPS;
import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonObject;
@ -28,13 +27,14 @@ import org.schabi.newpipe.extractor.stream.VideoStream;
import org.schabi.newpipe.extractor.utils.JsonUtils; import org.schabi.newpipe.extractor.utils.JsonUtils;
import org.schabi.newpipe.extractor.utils.Utils; import org.schabi.newpipe.extractor.utils.Utils;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BandcampStreamExtractor extends StreamExtractor { public class BandcampStreamExtractor extends StreamExtractor {
private JsonObject albumJson; private JsonObject albumJson;
private JsonObject current; private JsonObject current;
@ -118,7 +118,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 EMPTY_STRING; return "";
} }
return getImageUrl(albumJson.getLong("art_id"), true); return getImageUrl(albumJson.getLong("art_id"), true);
@ -130,7 +130,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(Utils.EMPTY_STRING); .orElse("");
} }
@Nonnull @Nonnull
@ -194,7 +194,7 @@ public class BandcampStreamExtractor extends StreamExtractor {
.flatMap(element -> element.getElementsByClass("tag").stream()) .flatMap(element -> element.getElementsByClass("tag").stream())
.map(Element::text) .map(Element::text)
.findFirst() .findFirst()
.orElse(EMPTY_STRING); .orElse("");
} }
@Nonnull @Nonnull

View File

@ -1,5 +1,8 @@
package org.schabi.newpipe.extractor.services.media_ccc.extractors; package org.schabi.newpipe.extractor.services.media_ccc.extractors;
import static org.schabi.newpipe.extractor.stream.AudioStream.UNKNOWN_BITRATE;
import static org.schabi.newpipe.extractor.stream.Stream.ID_UNKNOWN;
import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonObject;
@ -25,10 +28,6 @@ import java.util.stream.Collectors;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import static org.schabi.newpipe.extractor.stream.AudioStream.UNKNOWN_BITRATE;
import static org.schabi.newpipe.extractor.stream.Stream.ID_UNKNOWN;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
public class MediaCCCLiveStreamExtractor extends StreamExtractor { public class MediaCCCLiveStreamExtractor extends StreamExtractor {
private static final String STREAMS = "streams"; private static final String STREAMS = "streams";
private static final String URLS = "urls"; private static final String URLS = "urls";
@ -149,9 +148,9 @@ public class MediaCCCLiveStreamExtractor extends StreamExtractor {
.map(JsonObject.class::cast) .map(JsonObject.class::cast)
.map(streamObject -> streamObject.getObject(URLS)) .map(streamObject -> streamObject.getObject(URLS))
.filter(urls -> urls.has(deliveryMethod)) .filter(urls -> urls.has(deliveryMethod))
.map(urls -> urls.getObject(deliveryMethod).getString(URL, EMPTY_STRING)) .map(urls -> urls.getObject(deliveryMethod).getString(URL, ""))
.findFirst() .findFirst()
.orElse(EMPTY_STRING); .orElse("");
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package org.schabi.newpipe.extractor.services.peertube.extractors; package org.schabi.newpipe.extractor.services.peertube.extractors;
import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonObject;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.ServiceList;
@ -12,8 +13,6 @@ import org.schabi.newpipe.extractor.utils.JsonUtils;
import java.util.Objects; import java.util.Objects;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtractor { public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtractor {
private final JsonObject item; private final JsonObject item;
private final String url; private final String url;
@ -66,7 +65,7 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
final Document doc = Jsoup.parse(htmlText); final Document doc = Jsoup.parse(htmlText);
return doc.body().text(); return doc.body().text();
} catch (final Exception e) { } catch (final Exception e) {
return htmlText.replaceAll("(?s)<[^>]*>(\\s*<[^>]*>)*", EMPTY_STRING); return htmlText.replaceAll("(?s)<[^>]*>(\\s*<[^>]*>)*", "");
} }
} }

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.services.peertube.extractors; package org.schabi.newpipe.extractor.services.peertube.extractors;
import static org.schabi.newpipe.extractor.stream.AudioStream.UNKNOWN_BITRATE;
import static org.schabi.newpipe.extractor.utils.Utils.UTF_8; import static org.schabi.newpipe.extractor.utils.Utils.UTF_8;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
@ -45,9 +46,6 @@ import java.util.stream.Collectors;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import static org.schabi.newpipe.extractor.stream.AudioStream.UNKNOWN_BITRATE;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
public class PeertubeStreamExtractor extends StreamExtractor { public class PeertubeStreamExtractor extends StreamExtractor {
private static final String ACCOUNT_HOST = "account.host"; private static final String ACCOUNT_HOST = "account.host";
private static final String ACCOUNT_NAME = "account.name"; private static final String ACCOUNT_NAME = "account.name";
@ -219,11 +217,10 @@ public class PeertubeStreamExtractor extends StreamExtractor {
if (getStreamType() == StreamType.VIDEO_STREAM if (getStreamType() == StreamType.VIDEO_STREAM
&& !isNullOrEmpty(json.getObject(FILES))) { && !isNullOrEmpty(json.getObject(FILES))) {
return json.getObject(FILES).getString(PLAYLIST_URL, EMPTY_STRING); return json.getObject(FILES).getString(PLAYLIST_URL, "");
} }
return json.getArray(STREAMING_PLAYLISTS).getObject(0).getString(PLAYLIST_URL, return json.getArray(STREAMING_PLAYLISTS).getObject(0).getString(PLAYLIST_URL, "");
EMPTY_STRING);
} }
@Override @Override
@ -319,7 +316,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
try { try {
return JsonUtils.getString(json, "support"); return JsonUtils.getString(json, "support");
} catch (final ParsingException e) { } catch (final ParsingException e) {
return EMPTY_STRING; return "";
} }
} }
@ -440,9 +437,9 @@ public class PeertubeStreamExtractor extends StreamExtractor {
.map(JsonObject.class::cast) .map(JsonObject.class::cast)
.map(stream -> new VideoStream.Builder() .map(stream -> new VideoStream.Builder()
.setId(String.valueOf(stream.getInt("id", -1))) .setId(String.valueOf(stream.getInt("id", -1)))
.setContent(stream.getString(PLAYLIST_URL, EMPTY_STRING), true) .setContent(stream.getString(PLAYLIST_URL, ""), true)
.setIsVideoOnly(false) .setIsVideoOnly(false)
.setResolution(EMPTY_STRING) .setResolution("")
.setMediaFormat(MediaFormat.MPEG_4) .setMediaFormat(MediaFormat.MPEG_4)
.setDeliveryMethod(DeliveryMethod.HLS) .setDeliveryMethod(DeliveryMethod.HLS)
.build()) .build())
@ -457,7 +454,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
private void getStreams() throws ParsingException { private void getStreams() throws ParsingException {
// Progressive streams // Progressive streams
getStreamsFromArray(json.getArray(FILES), EMPTY_STRING); getStreamsFromArray(json.getArray(FILES), "");
// HLS streams // HLS streams
try { try {

View File

@ -1,7 +1,6 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.UTF_8; import static org.schabi.newpipe.extractor.utils.Utils.UTF_8;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps; import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
@ -313,17 +312,17 @@ public final class SoundcloudParsingHelper {
@Nonnull @Nonnull
public static String getUploaderUrl(final JsonObject object) { public static String getUploaderUrl(final JsonObject object) {
final String url = object.getObject("user").getString("permalink_url", EMPTY_STRING); final String url = object.getObject("user").getString("permalink_url", "");
return replaceHttpWithHttps(url); return replaceHttpWithHttps(url);
} }
@Nonnull @Nonnull
public static String getAvatarUrl(final JsonObject object) { public static String getAvatarUrl(final JsonObject object) {
final String url = object.getObject("user").getString("avatar_url", EMPTY_STRING); final String url = object.getObject("user").getString("avatar_url", "");
return replaceHttpWithHttps(url); return replaceHttpWithHttps(url);
} }
public static String getUploaderName(final JsonObject object) { public static String getUploaderName(final JsonObject object) {
return object.getObject("user").getString("username", EMPTY_STRING); return object.getObject("user").getString("username", "");
} }
} }

View File

@ -1,8 +1,12 @@
package org.schabi.newpipe.extractor.services.soundcloud.extractors; package org.schabi.newpipe.extractor.services.soundcloud.extractors;
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.SOUNDCLOUD_API_V2_URL;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser; import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException; import com.grack.nanojson.JsonParserException;
import org.schabi.newpipe.extractor.Page; import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.channel.ChannelExtractor;
@ -14,12 +18,9 @@ import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper;
import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.SOUNDCLOUD_API_V2_URL; import javax.annotation.Nonnull;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class SoundcloudChannelExtractor extends ChannelExtractor { public class SoundcloudChannelExtractor extends ChannelExtractor {
private String userId; private String userId;
@ -82,7 +83,7 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
@Override @Override
public String getDescription() { public String getDescription() {
return user.getString("description", EMPTY_STRING); return user.getString("description", "");
} }
@Override @Override

View File

@ -1,11 +1,11 @@
package org.schabi.newpipe.extractor.services.soundcloud.extractors; package org.schabi.newpipe.extractor.services.soundcloud.extractors;
import com.grack.nanojson.JsonObject;
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps; import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
import com.grack.nanojson.JsonObject;
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
public class SoundcloudChannelInfoItemExtractor implements ChannelInfoItemExtractor { public class SoundcloudChannelInfoItemExtractor implements ChannelInfoItemExtractor {
private final JsonObject itemObject; private final JsonObject itemObject;
@ -26,7 +26,7 @@ public class SoundcloudChannelInfoItemExtractor implements ChannelInfoItemExtrac
@Override @Override
public String getThumbnailUrl() { public String getThumbnailUrl() {
// An avatar URL with a better resolution // An avatar URL with a better resolution
return itemObject.getString("avatar_url", EMPTY_STRING).replace("large.jpg", "crop.jpg"); return itemObject.getString("avatar_url", "").replace("large.jpg", "crop.jpg");
} }
@Override @Override
@ -46,6 +46,6 @@ public class SoundcloudChannelInfoItemExtractor implements ChannelInfoItemExtrac
@Override @Override
public String getDescription() { public String getDescription() {
return itemObject.getString("description", EMPTY_STRING); return itemObject.getString("description", "");
} }
} }

View File

@ -1,5 +1,8 @@
package org.schabi.newpipe.extractor.services.soundcloud.extractors; package org.schabi.newpipe.extractor.services.soundcloud.extractors;
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.SOUNDCLOUD_API_V2_URL;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser; import com.grack.nanojson.JsonParser;
@ -23,10 +26,6 @@ import java.util.List;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.SOUNDCLOUD_API_V2_URL;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class SoundcloudPlaylistExtractor extends PlaylistExtractor { public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
private static final int STREAMS_PER_REQUESTED_PAGE = 15; private static final int STREAMS_PER_REQUESTED_PAGE = 15;
@ -87,7 +86,7 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
} }
if (artworkUrl == null) { if (artworkUrl == null) {
return EMPTY_STRING; return "";
} }
} }

View File

@ -1,12 +1,12 @@
package org.schabi.newpipe.extractor.services.soundcloud.extractors; package org.schabi.newpipe.extractor.services.soundcloud.extractors;
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonObject;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemExtractor; import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemExtractor;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
public class SoundcloudPlaylistInfoItemExtractor implements PlaylistInfoItemExtractor { public class SoundcloudPlaylistInfoItemExtractor implements PlaylistInfoItemExtractor {
private static final String USER_KEY = "user"; private static final String USER_KEY = "user";
private static final String AVATAR_URL_KEY = "avatar_url"; private static final String AVATAR_URL_KEY = "avatar_url";
@ -32,7 +32,7 @@ public class SoundcloudPlaylistInfoItemExtractor implements PlaylistInfoItemExtr
public String getThumbnailUrl() throws ParsingException { public String getThumbnailUrl() throws ParsingException {
// Over-engineering at its finest // Over-engineering at its finest
if (itemObject.isString(ARTWORK_URL_KEY)) { if (itemObject.isString(ARTWORK_URL_KEY)) {
final String artworkUrl = itemObject.getString(ARTWORK_URL_KEY, EMPTY_STRING); final String artworkUrl = itemObject.getString(ARTWORK_URL_KEY, "");
if (!artworkUrl.isEmpty()) { if (!artworkUrl.isEmpty()) {
// An artwork URL with a better resolution // An artwork URL with a better resolution
return artworkUrl.replace("large.jpg", "crop.jpg"); return artworkUrl.replace("large.jpg", "crop.jpg");
@ -46,7 +46,7 @@ public class SoundcloudPlaylistInfoItemExtractor implements PlaylistInfoItemExtr
// First look for track artwork url // First look for track artwork url
if (trackObject.isString(ARTWORK_URL_KEY)) { if (trackObject.isString(ARTWORK_URL_KEY)) {
final String artworkUrl = trackObject.getString(ARTWORK_URL_KEY, EMPTY_STRING); final String artworkUrl = trackObject.getString(ARTWORK_URL_KEY, "");
if (!artworkUrl.isEmpty()) { if (!artworkUrl.isEmpty()) {
// An artwork URL with a better resolution // An artwork URL with a better resolution
return artworkUrl.replace("large.jpg", "crop.jpg"); return artworkUrl.replace("large.jpg", "crop.jpg");
@ -55,7 +55,7 @@ public class SoundcloudPlaylistInfoItemExtractor implements PlaylistInfoItemExtr
// Then look for track creator avatar url // Then look for track creator avatar url
final JsonObject creator = trackObject.getObject(USER_KEY); final JsonObject creator = trackObject.getObject(USER_KEY);
final String creatorAvatar = creator.getString(AVATAR_URL_KEY, EMPTY_STRING); final String creatorAvatar = creator.getString(AVATAR_URL_KEY, "");
if (!creatorAvatar.isEmpty()) { if (!creatorAvatar.isEmpty()) {
return creatorAvatar; return creatorAvatar;
} }
@ -66,7 +66,7 @@ public class SoundcloudPlaylistInfoItemExtractor implements PlaylistInfoItemExtr
try { try {
// Last resort, use user avatar url. If still not found, then throw exception. // Last resort, use user avatar url. If still not found, then throw exception.
return itemObject.getObject(USER_KEY).getString(AVATAR_URL_KEY, EMPTY_STRING); return itemObject.getObject(USER_KEY).getString(AVATAR_URL_KEY, "");
} catch (final Exception e) { } catch (final Exception e) {
throw new ParsingException("Failed to extract playlist thumbnail url", e); throw new ParsingException("Failed to extract playlist thumbnail url", e);
} }

View File

@ -1,5 +1,8 @@
package org.schabi.newpipe.extractor.services.soundcloud.extractors; package org.schabi.newpipe.extractor.services.soundcloud.extractors;
import static org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudSearchQueryHandlerFactory.ITEMS_PER_PAGE;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser; import com.grack.nanojson.JsonParser;
@ -9,17 +12,16 @@ import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.InfoItemExtractor; import org.schabi.newpipe.extractor.InfoItemExtractor;
import org.schabi.newpipe.extractor.InfoItemsCollector; import org.schabi.newpipe.extractor.InfoItemsCollector;
import org.schabi.newpipe.extractor.MetaInfo; import org.schabi.newpipe.extractor.MetaInfo;
import org.schabi.newpipe.extractor.MultiInfoItemsCollector;
import org.schabi.newpipe.extractor.Page; import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.downloader.Downloader; import org.schabi.newpipe.extractor.downloader.Downloader;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler; import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
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.utils.Parser; import org.schabi.newpipe.extractor.utils.Parser;
import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
@ -28,9 +30,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.IntUnaryOperator; import java.util.function.IntUnaryOperator;
import static org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudSearchQueryHandlerFactory.ITEMS_PER_PAGE; import javax.annotation.Nonnull;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class SoundcloudSearchExtractor extends SearchExtractor { public class SoundcloudSearchExtractor extends SearchExtractor {
private JsonArray initialSearchCollection; private JsonArray initialSearchCollection;
@ -114,7 +114,7 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
} }
final JsonObject searchResult = (JsonObject) result; final JsonObject searchResult = (JsonObject) result;
final String kind = searchResult.getString("kind", EMPTY_STRING); final String kind = searchResult.getString("kind", "");
switch (kind) { switch (kind) {
case "user": case "user":
collector.commit(new SoundcloudChannelInfoItemExtractor(searchResult)); collector.commit(new SoundcloudChannelInfoItemExtractor(searchResult));

View File

@ -4,7 +4,6 @@ import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsing
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.clientId; import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.clientId;
import static org.schabi.newpipe.extractor.stream.AudioStream.UNKNOWN_BITRATE; import static org.schabi.newpipe.extractor.stream.AudioStream.UNKNOWN_BITRATE;
import static org.schabi.newpipe.extractor.stream.Stream.ID_UNKNOWN; import static org.schabi.newpipe.extractor.stream.Stream.ID_UNKNOWN;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.UTF_8; import static org.schabi.newpipe.extractor.utils.Utils.UTF_8;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
@ -58,7 +57,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
ExtractionException { ExtractionException {
track = SoundcloudParsingHelper.resolveFor(downloader, getUrl()); track = SoundcloudParsingHelper.resolveFor(downloader, getUrl());
final String policy = track.getString("policy", EMPTY_STRING); final String policy = track.getString("policy", "");
if (!policy.equals("ALLOW") && !policy.equals("MONETIZE")) { if (!policy.equals("ALLOW") && !policy.equals("MONETIZE")) {
isAvailable = false; isAvailable = false;
@ -92,7 +91,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
public String getTextualUploadDate() { public String getTextualUploadDate() {
return track.getString("created_at") return track.getString("created_at")
.replace("T", " ") .replace("T", " ")
.replace("Z", EMPTY_STRING); .replace("Z", "");
} }
@Nonnull @Nonnull
@ -105,9 +104,9 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
@Nonnull @Nonnull
@Override @Override
public String getThumbnailUrl() { public String getThumbnailUrl() {
String artworkUrl = track.getString("artwork_url", EMPTY_STRING); String artworkUrl = track.getString("artwork_url", "");
if (artworkUrl.isEmpty()) { if (artworkUrl.isEmpty()) {
artworkUrl = track.getObject("user").getString("avatar_url", EMPTY_STRING); artworkUrl = track.getObject("user").getString("avatar_url", "");
} }
return artworkUrl.replace("large.jpg", "crop.jpg"); return artworkUrl.replace("large.jpg", "crop.jpg");
} }

View File

@ -1,6 +1,9 @@
package org.schabi.newpipe.extractor.services.soundcloud.extractors; package org.schabi.newpipe.extractor.services.soundcloud.extractors;
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonObject;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.localization.DateWrapper; import org.schabi.newpipe.extractor.localization.DateWrapper;
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper; import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper;
@ -9,9 +12,6 @@ import org.schabi.newpipe.extractor.stream.StreamType;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
public class SoundcloudStreamInfoItemExtractor implements StreamInfoItemExtractor { public class SoundcloudStreamInfoItemExtractor implements StreamInfoItemExtractor {
protected final JsonObject itemObject; protected final JsonObject itemObject;
@ -73,7 +73,7 @@ public class SoundcloudStreamInfoItemExtractor implements StreamInfoItemExtracto
@Override @Override
public String getThumbnailUrl() { public String getThumbnailUrl() {
String artworkUrl = itemObject.getString("artwork_url", EMPTY_STRING); String artworkUrl = itemObject.getString("artwork_url", "");
if (artworkUrl.isEmpty()) { if (artworkUrl.isEmpty()) {
artworkUrl = itemObject.getObject("user").getString("avatar_url"); artworkUrl = itemObject.getObject("user").getString("avatar_url");
} }

View File

@ -21,7 +21,6 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import static org.schabi.newpipe.extractor.NewPipe.getDownloader; import static org.schabi.newpipe.extractor.NewPipe.getDownloader;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.HTTP; import static org.schabi.newpipe.extractor.utils.Utils.HTTP;
import static org.schabi.newpipe.extractor.utils.Utils.HTTPS; import static org.schabi.newpipe.extractor.utils.Utils.HTTPS;
import static org.schabi.newpipe.extractor.utils.Utils.UTF_8; import static org.schabi.newpipe.extractor.utils.Utils.UTF_8;
@ -827,7 +826,7 @@ public final class YoutubeParsingHelper {
.value("hl", "en-GB") .value("hl", "en-GB")
.value("gl", "GB") .value("gl", "GB")
.array("experimentIds").end() .array("experimentIds").end()
.value("experimentsToken", EMPTY_STRING) .value("experimentsToken", "")
.object("locationInfo").end() .object("locationInfo").end()
.object("musicAppInfo").end() .object("musicAppInfo").end()
.end() .end()
@ -1397,10 +1396,10 @@ public final class YoutubeParsingHelper {
@Nonnull final Response response) { @Nonnull final Response response) {
final List<String> cookies = response.responseHeaders().get("set-cookie"); final List<String> cookies = response.responseHeaders().get("set-cookie");
if (cookies == null) { if (cookies == null) {
return EMPTY_STRING; return "";
} }
String result = EMPTY_STRING; String result = "";
for (final String cookie : cookies) { for (final String cookie : cookies) {
final int startIndex = cookie.indexOf(cookieName); final int startIndex = cookie.indexOf(cookieName);
if (startIndex != -1) { if (startIndex != -1) {
@ -1426,7 +1425,7 @@ public final class YoutubeParsingHelper {
if (!isNullOrEmpty(alerts)) { if (!isNullOrEmpty(alerts)) {
final JsonObject alertRenderer = alerts.getObject(0).getObject("alertRenderer"); final JsonObject alertRenderer = alerts.getObject(0).getObject("alertRenderer");
final String alertText = getTextFromObject(alertRenderer.getObject("text")); final String alertText = getTextFromObject(alertRenderer.getObject("text"));
final String alertType = alertRenderer.getString("type", EMPTY_STRING); final String alertType = alertRenderer.getString("type", "");
if (alertType.equalsIgnoreCase("ERROR")) { if (alertType.equalsIgnoreCase("ERROR")) {
if (alertText != null && alertText.contains("This account has been terminated")) { if (alertText != null && alertText.contains("This account has been terminated")) {
if (alertText.contains("violation") || alertText.contains("violating") if (alertText.contains("violation") || alertText.contains("violating")

View File

@ -1,18 +1,5 @@
package org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators; package org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators;
import org.schabi.newpipe.extractor.downloader.Response;
import org.schabi.newpipe.extractor.services.youtube.DeliveryType;
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
import org.schabi.newpipe.extractor.utils.ManifestCreatorCache;
import org.schabi.newpipe.extractor.utils.Utils;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Objects;
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.ALR_YES; import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.ALR_YES;
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.RN_0; import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.RN_0;
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.SEGMENT_TIMELINE; import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.SEGMENT_TIMELINE;
@ -23,9 +10,22 @@ import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.generateSegmentTimelineElement; import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.generateSegmentTimelineElement;
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.getInitializationResponse; import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.getInitializationResponse;
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.setAttribute; import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.setAttribute;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.isBlank; import static org.schabi.newpipe.extractor.utils.Utils.isBlank;
import org.schabi.newpipe.extractor.downloader.Response;
import org.schabi.newpipe.extractor.services.youtube.DeliveryType;
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
import org.schabi.newpipe.extractor.utils.ManifestCreatorCache;
import org.schabi.newpipe.extractor.utils.Utils;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.Arrays;
import java.util.Objects;
import javax.annotation.Nonnull;
/** /**
* Class which generates DASH manifests of YouTube {@link DeliveryType#OTF OTF streams}. * Class which generates DASH manifests of YouTube {@link DeliveryType#OTF OTF streams}.
*/ */
@ -112,8 +112,8 @@ public final class YoutubeOtfDashManifestCreator {
// from video servers. // from video servers.
final Response response = getInitializationResponse(realOtfBaseStreamingUrl, final Response response = getInitializationResponse(realOtfBaseStreamingUrl,
itagItem, DeliveryType.OTF); itagItem, DeliveryType.OTF);
realOtfBaseStreamingUrl = response.latestUrl().replace(SQ_0, EMPTY_STRING) realOtfBaseStreamingUrl = response.latestUrl().replace(SQ_0, "")
.replace(RN_0, EMPTY_STRING).replace(ALR_YES, EMPTY_STRING); .replace(RN_0, "").replace(ALR_YES, "");
final int responseCode = response.responseCode(); final int responseCode = response.responseCode();
if (responseCode != 200) { if (responseCode != 200) {

View File

@ -1,18 +1,5 @@
package org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators; package org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators;
import org.schabi.newpipe.extractor.downloader.Response;
import org.schabi.newpipe.extractor.services.youtube.DeliveryType;
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
import org.schabi.newpipe.extractor.utils.ManifestCreatorCache;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.ALR_YES; import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.ALR_YES;
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.RN_0; import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.RN_0;
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.SEGMENT_TIMELINE; import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.SEGMENT_TIMELINE;
@ -23,9 +10,22 @@ import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.generateSegmentTimelineElement; import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.generateSegmentTimelineElement;
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.getInitializationResponse; import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.getInitializationResponse;
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.setAttribute; import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.setAttribute;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import org.schabi.newpipe.extractor.downloader.Response;
import org.schabi.newpipe.extractor.services.youtube.DeliveryType;
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
import org.schabi.newpipe.extractor.utils.ManifestCreatorCache;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.annotation.Nonnull;
/** /**
* Class which generates DASH manifests of YouTube post-live DVR streams (which use the * Class which generates DASH manifests of YouTube post-live DVR streams (which use the
* {@link DeliveryType#LIVE LIVE delivery type}). * {@link DeliveryType#LIVE LIVE delivery type}).
@ -130,8 +130,8 @@ public final class YoutubePostLiveStreamDvrDashManifestCreator {
// from video servers. // from video servers.
final Response response = getInitializationResponse(realPostLiveStreamDvrStreamingUrl, final Response response = getInitializationResponse(realPostLiveStreamDvrStreamingUrl,
itagItem, DeliveryType.LIVE); itagItem, DeliveryType.LIVE);
realPostLiveStreamDvrStreamingUrl = response.latestUrl().replace(SQ_0, EMPTY_STRING) realPostLiveStreamDvrStreamingUrl = response.latestUrl().replace(SQ_0, "")
.replace(RN_0, EMPTY_STRING).replace(ALR_YES, EMPTY_STRING); .replace(RN_0, "").replace(ALR_YES, "");
final int responseCode = response.responseCode(); final int responseCode = response.responseCode();
if (responseCode != 200) { if (responseCode != 200) {

View File

@ -9,7 +9,6 @@ import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getValidJsonResponseBody; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getValidJsonResponseBody;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareDesktopJsonBuilder; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareDesktopJsonBuilder;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.UTF_8; import static org.schabi.newpipe.extractor.utils.Utils.UTF_8;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
@ -120,10 +119,10 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
final String webPageType = endpoint.getObject("commandMetadata") final String webPageType = endpoint.getObject("commandMetadata")
.getObject("webCommandMetadata") .getObject("webCommandMetadata")
.getString("webPageType", EMPTY_STRING); .getString("webPageType", "");
final JsonObject browseEndpoint = endpoint.getObject("browseEndpoint"); final JsonObject browseEndpoint = endpoint.getObject("browseEndpoint");
final String browseId = browseEndpoint.getString("browseId", EMPTY_STRING); final String browseId = browseEndpoint.getString("browseId", "");
if (webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_BROWSE") if (webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_BROWSE")
|| webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_CHANNEL") || webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_CHANNEL")
@ -171,10 +170,10 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
final String webPageType = endpoint.getObject("commandMetadata") final String webPageType = endpoint.getObject("commandMetadata")
.getObject("webCommandMetadata") .getObject("webCommandMetadata")
.getString("webPageType", EMPTY_STRING); .getString("webPageType", "");
final String browseId = endpoint.getObject("browseEndpoint").getString("browseId", final String browseId = endpoint.getObject("browseEndpoint").getString("browseId",
EMPTY_STRING); "");
if (webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_BROWSE") if (webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_BROWSE")
|| webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_CHANNEL") || webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_CHANNEL")
@ -215,7 +214,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
public String getId() throws ParsingException { public String getId() throws ParsingException {
final String channelId = initialData.getObject("header") final String channelId = initialData.getObject("header")
.getObject("c4TabbedHeaderRenderer") .getObject("c4TabbedHeaderRenderer")
.getString("channelId", EMPTY_STRING); .getString("channelId", "");
if (!channelId.isEmpty()) { if (!channelId.isEmpty()) {
return channelId; return channelId;
@ -456,7 +455,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
for (final Object tab : tabs) { for (final Object tab : tabs) {
if (((JsonObject) tab).has("tabRenderer")) { if (((JsonObject) tab).has("tabRenderer")) {
if (((JsonObject) tab).getObject("tabRenderer").getString("title", if (((JsonObject) tab).getObject("tabRenderer").getString("title",
EMPTY_STRING).equals("Videos")) { "").equals("Videos")) {
foundVideoTab = ((JsonObject) tab).getObject("tabRenderer"); foundVideoTab = ((JsonObject) tab).getObject("tabRenderer");
break; break;
} }

View File

@ -1,7 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.extractors; package org.schabi.newpipe.extractor.services.youtube.extractors;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonObject;
@ -63,7 +62,7 @@ public class YoutubeCommentsInfoItemExtractor implements CommentsInfoItemExtract
try { try {
return getTextFromObject(JsonUtils.getObject(getCommentRenderer(), "authorText")); return getTextFromObject(JsonUtils.getObject(getCommentRenderer(), "authorText"));
} catch (final Exception e) { } catch (final Exception e) {
return EMPTY_STRING; return "";
} }
} }
@ -162,12 +161,12 @@ public class YoutubeCommentsInfoItemExtractor implements CommentsInfoItemExtract
try { try {
// If a comment has no likes voteCount is not set // If a comment has no likes voteCount is not set
if (!getCommentRenderer().has("voteCount")) { if (!getCommentRenderer().has("voteCount")) {
return EMPTY_STRING; return "";
} }
final JsonObject voteCountObj = JsonUtils.getObject(getCommentRenderer(), "voteCount"); final JsonObject voteCountObj = JsonUtils.getObject(getCommentRenderer(), "voteCount");
if (voteCountObj.isEmpty()) { if (voteCountObj.isEmpty()) {
return EMPTY_STRING; return "";
} }
return getTextFromObject(voteCountObj); return getTextFromObject(voteCountObj);
} catch (final Exception e) { } catch (final Exception e) {
@ -182,7 +181,7 @@ public class YoutubeCommentsInfoItemExtractor implements CommentsInfoItemExtract
if (contentText.isEmpty()) { if (contentText.isEmpty()) {
// completely empty comments as described in // completely empty comments as described in
// https://github.com/TeamNewPipe/NewPipeExtractor/issues/380#issuecomment-668808584 // https://github.com/TeamNewPipe/NewPipeExtractor/issues/380#issuecomment-668808584
return EMPTY_STRING; return "";
} }
final String commentText = getTextFromObject(contentText); final String commentText = getTextFromObject(contentText);
// YouTube adds U+FEFF in some comments. // YouTube adds U+FEFF in some comments.
@ -235,7 +234,7 @@ public class YoutubeCommentsInfoItemExtractor implements CommentsInfoItemExtract
try { try {
return getTextFromObject(JsonUtils.getObject(getCommentRenderer(), "authorText")); return getTextFromObject(JsonUtils.getObject(getCommentRenderer(), "authorText"));
} catch (final Exception e) { } catch (final Exception e) {
return EMPTY_STRING; return "";
} }
} }
@ -245,7 +244,7 @@ public class YoutubeCommentsInfoItemExtractor implements CommentsInfoItemExtract
return "https://www.youtube.com/channel/" + JsonUtils.getString(getCommentRenderer(), return "https://www.youtube.com/channel/" + JsonUtils.getString(getCommentRenderer(),
"authorEndpoint.browseEndpoint.browseId"); "authorEndpoint.browseEndpoint.browseId");
} catch (final Exception e) { } catch (final Exception e) {
return EMPTY_STRING; return "";
} }
} }

View File

@ -8,7 +8,6 @@ import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getKey; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getKey;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getValidJsonResponseBody; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getValidJsonResponseBody;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareDesktopJsonBuilder; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareDesktopJsonBuilder;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.getQueryValue; import static org.schabi.newpipe.extractor.utils.Utils.getQueryValue;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import static org.schabi.newpipe.extractor.utils.Utils.stringToURL; import static org.schabi.newpipe.extractor.utils.Utils.stringToURL;
@ -144,7 +143,7 @@ public class YoutubeMixPlaylistExtractor extends PlaylistExtractor {
@Override @Override
public String getUploaderUrl() { public String getUploaderUrl() {
// YouTube mixes are auto-generated by YouTube // YouTube mixes are auto-generated by YouTube
return EMPTY_STRING; return "";
} }
@Override @Override
@ -156,7 +155,7 @@ public class YoutubeMixPlaylistExtractor extends PlaylistExtractor {
@Override @Override
public String getUploaderAvatarUrl() { public String getUploaderAvatarUrl() {
// YouTube mixes are auto-generated by YouTube // YouTube mixes are auto-generated by YouTube
return EMPTY_STRING; return "";
} }
@Override @Override

View File

@ -10,7 +10,6 @@ import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeS
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.MUSIC_PLAYLISTS; import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.MUSIC_PLAYLISTS;
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.MUSIC_SONGS; import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.MUSIC_SONGS;
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.MUSIC_VIDEOS; import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.MUSIC_VIDEOS;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.UTF_8; import static org.schabi.newpipe.extractor.utils.Utils.UTF_8;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
@ -97,7 +96,7 @@ public class YoutubeMusicSearchExtractor extends SearchExtractor {
.value("hl", "en-GB") .value("hl", "en-GB")
.value("gl", getExtractorContentCountry().getCountryCode()) .value("gl", getExtractorContentCountry().getCountryCode())
.array("experimentIds").end() .array("experimentIds").end()
.value("experimentsToken", EMPTY_STRING) .value("experimentsToken", "")
.object("locationInfo").end() .object("locationInfo").end()
.object("musicAppInfo").end() .object("musicAppInfo").end()
.end() .end()
@ -288,7 +287,7 @@ public class YoutubeMusicSearchExtractor extends SearchExtractor {
.getObject("musicResponsiveListItemRenderer", null); .getObject("musicResponsiveListItemRenderer", null);
if (info != null) { if (info != null) {
final String displayPolicy = info.getString("musicItemRendererDisplayPolicy", final String displayPolicy = info.getString("musicItemRendererDisplayPolicy",
EMPTY_STRING); "");
if (displayPolicy.equals("MUSIC_ITEM_RENDERER_DISPLAY_POLICY_GREY_OUT")) { if (displayPolicy.equals("MUSIC_ITEM_RENDERER_DISPLAY_POLICY_GREY_OUT")) {
continue; // No info about video URL available continue; // No info about video URL available
} }
@ -354,7 +353,7 @@ public class YoutubeMusicSearchExtractor extends SearchExtractor {
((JsonObject) item).getObject( ((JsonObject) item).getObject(
"menuNavigationItemRenderer"); "menuNavigationItemRenderer");
if (menuNavigationItemRenderer.getObject("icon") if (menuNavigationItemRenderer.getObject("icon")
.getString("iconType", EMPTY_STRING) .getString("iconType", "")
.equals("ARTIST")) { .equals("ARTIST")) {
return getUrlFromNavigationEndpoint( return getUrlFromNavigationEndpoint(
menuNavigationItemRenderer menuNavigationItemRenderer

View File

@ -11,7 +11,6 @@ import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getUrlFromNavigationEndpoint; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getUrlFromNavigationEndpoint;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getValidJsonResponseBody; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getValidJsonResponseBody;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareDesktopJsonBuilder; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareDesktopJsonBuilder;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonArray;
@ -217,19 +216,19 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
@Nonnull @Nonnull
@Override @Override
public String getSubChannelName() { public String getSubChannelName() {
return EMPTY_STRING; return "";
} }
@Nonnull @Nonnull
@Override @Override
public String getSubChannelUrl() { public String getSubChannelUrl() {
return EMPTY_STRING; return "";
} }
@Nonnull @Nonnull
@Override @Override
public String getSubChannelAvatarUrl() { public String getSubChannelAvatarUrl() {
return EMPTY_STRING; return "";
} }
@Nonnull @Nonnull

View File

@ -21,12 +21,12 @@
package org.schabi.newpipe.extractor.services.youtube.extractors; package org.schabi.newpipe.extractor.services.youtube.extractors;
import static org.schabi.newpipe.extractor.services.youtube.ItagItem.APPROX_DURATION_MS_UNKNOWN; import static org.schabi.newpipe.extractor.services.youtube.ItagItem.APPROX_DURATION_MS_UNKNOWN;
import static org.schabi.newpipe.extractor.services.youtube.ItagItem.CONTENT_LENGTH_UNKNOWN;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.CONTENT_CHECK_OK; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.CONTENT_CHECK_OK;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.CPN; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.CPN;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.RACY_CHECK_OK; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.RACY_CHECK_OK;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.VIDEO_ID; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.VIDEO_ID;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.createDesktopPlayerBody; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.createDesktopPlayerBody;
import static org.schabi.newpipe.extractor.services.youtube.ItagItem.CONTENT_LENGTH_UNKNOWN;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.fixThumbnailUrl; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.fixThumbnailUrl;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.generateContentPlaybackNonce; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.generateContentPlaybackNonce;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.generateTParameter; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.generateTParameter;
@ -37,7 +37,6 @@ import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareAndroidMobileJsonBuilder; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareAndroidMobileJsonBuilder;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareDesktopJsonBuilder; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareDesktopJsonBuilder;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareIosMobileJsonBuilder; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareIosMobileJsonBuilder;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonArray;
@ -185,18 +184,18 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Nullable @Nullable
@Override @Override
public String getTextualUploadDate() throws ParsingException { public String getTextualUploadDate() throws ParsingException {
if (!playerMicroFormatRenderer.getString("uploadDate", EMPTY_STRING).isEmpty()) { if (!playerMicroFormatRenderer.getString("uploadDate", "").isEmpty()) {
return playerMicroFormatRenderer.getString("uploadDate"); return playerMicroFormatRenderer.getString("uploadDate");
} else if (!playerMicroFormatRenderer.getString("publishDate", EMPTY_STRING).isEmpty()) { } else if (!playerMicroFormatRenderer.getString("publishDate", "").isEmpty()) {
return playerMicroFormatRenderer.getString("publishDate"); return playerMicroFormatRenderer.getString("publishDate");
} }
final JsonObject liveDetails = playerMicroFormatRenderer.getObject( final JsonObject liveDetails = playerMicroFormatRenderer.getObject(
"liveBroadcastDetails"); "liveBroadcastDetails");
if (!liveDetails.getString("endTimestamp", EMPTY_STRING).isEmpty()) { if (!liveDetails.getString("endTimestamp", "").isEmpty()) {
// an ended live stream // an ended live stream
return liveDetails.getString("endTimestamp"); return liveDetails.getString("endTimestamp");
} else if (!liveDetails.getString("startTimestamp", EMPTY_STRING).isEmpty()) { } else if (!liveDetails.getString("startTimestamp", "").isEmpty()) {
// a running live stream // a running live stream
return liveDetails.getString("startTimestamp"); return liveDetails.getString("startTimestamp");
} else if (getStreamType() == StreamType.LIVE_STREAM) { } else if (getStreamType() == StreamType.LIVE_STREAM) {
@ -331,7 +330,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
// Only JsonObjects allowed // Only JsonObjects allowed
.filter(JsonObject.class::isInstance) .filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)) .map(JsonObject.class::cast))
.map(run -> run.getString("text", EMPTY_STRING)) .map(run -> run.getString("text", ""))
.anyMatch(rowText -> rowText.contains("Age-restricted")); .anyMatch(rowText -> rowText.contains("Age-restricted"));
ageLimit = ageRestricted ? 18 : NO_AGE_LIMIT; ageLimit = ageRestricted ? 18 : NO_AGE_LIMIT;
@ -521,7 +520,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
throw new ParsingException("Could not get uploader avatar URL"); throw new ParsingException("Could not get uploader avatar URL");
} }
return EMPTY_STRING; return "";
} }
return fixThumbnailUrl(url); return fixThumbnailUrl(url);
@ -577,7 +576,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
.map(streamingDataObject -> streamingDataObject.getString(manifestKey)) .map(streamingDataObject -> streamingDataObject.getString(manifestKey))
.filter(Objects::nonNull) .filter(Objects::nonNull)
.findFirst() .findFirst()
.orElse(EMPTY_STRING); .orElse("");
} }
@Override @Override
@ -791,7 +790,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
final JsonObject playabilityStatus = playerResponse.getObject("playabilityStatus"); final JsonObject playabilityStatus = playerResponse.getObject("playabilityStatus");
final boolean isAgeRestricted = playabilityStatus.getString("reason", EMPTY_STRING) final boolean isAgeRestricted = playabilityStatus.getString("reason", "")
.contains("age"); .contains("age");
setStreamType(); setStreamType();
@ -1298,7 +1297,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
* <li>the height returned by the {@link ItagItem} + {@code p} + the frame rate if * <li>the height returned by the {@link ItagItem} + {@code p} + the frame rate if
* it is more than 30;</li> * it is more than 30;</li>
* <li>the default resolution string from the {@link ItagItem};</li> * <li>the default resolution string from the {@link ItagItem};</li>
* <li>an {@link Utils#EMPTY_STRING empty string}.</li> * <li>an empty string.</li>
* </ol> * </ol>
* </li> * </li>
* <li>the {@link DeliveryMethod#DASH DASH delivery method}, for OTF streams, live streams * <li>the {@link DeliveryMethod#DASH DASH delivery method}, for OTF streams, live streams
@ -1327,7 +1326,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
final String resolutionString = itagItem.getResolutionString(); final String resolutionString = itagItem.getResolutionString();
builder.setResolution(resolutionString != null ? resolutionString builder.setResolution(resolutionString != null ? resolutionString
: EMPTY_STRING); : "");
if (streamType != StreamType.VIDEO_STREAM || !itagInfo.getIsUrl()) { if (streamType != StreamType.VIDEO_STREAM || !itagInfo.getIsUrl()) {
// For YouTube videos on OTF streams and for all streams of post-live streams // For YouTube videos on OTF streams and for all streams of post-live streams
@ -1396,9 +1395,9 @@ public class YoutubeStreamExtractor extends StreamExtractor {
final JsonObject initRange = formatData.getObject("initRange"); final JsonObject initRange = formatData.getObject("initRange");
final JsonObject indexRange = formatData.getObject("indexRange"); final JsonObject indexRange = formatData.getObject("indexRange");
final String mimeType = formatData.getString("mimeType", EMPTY_STRING); final String mimeType = formatData.getString("mimeType", "");
final String codec = mimeType.contains("codecs") final String codec = mimeType.contains("codecs")
? mimeType.split("\"")[1] : EMPTY_STRING; ? mimeType.split("\"")[1] : "";
itagItem.setBitrate(formatData.getInt("bitrate")); itagItem.setBitrate(formatData.getInt("bitrate"));
itagItem.setWidth(formatData.getInt("width")); itagItem.setWidth(formatData.getInt("width"));
@ -1437,7 +1436,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
final ItagInfo itagInfo = new ItagInfo(streamUrl, itagItem); final ItagInfo itagInfo = new ItagInfo(streamUrl, itagItem);
if (streamType == StreamType.VIDEO_STREAM) { if (streamType == StreamType.VIDEO_STREAM) {
itagInfo.setIsUrl(!formatData.getString("type", EMPTY_STRING) itagInfo.setIsUrl(!formatData.getString("type", "")
.equalsIgnoreCase("FORMAT_STREAM_TYPE_OTF")); .equalsIgnoreCase("FORMAT_STREAM_TYPE_OTF"));
} else { } else {
// We are currently not able to generate DASH manifests for running // We are currently not able to generate DASH manifests for running
@ -1523,7 +1522,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Nonnull @Nonnull
@Override @Override
public String getCategory() { public String getCategory() {
return playerMicroFormatRenderer.getString("category", EMPTY_STRING); return playerMicroFormatRenderer.getString("category", "");
} }
@Nonnull @Nonnull

View File

@ -3,7 +3,6 @@ package org.schabi.newpipe.extractor.services.youtube.extractors;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getThumbnailUrlFromInfoItem; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getThumbnailUrlFromInfoItem;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getUrlFromNavigationEndpoint; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getUrlFromNavigationEndpoint;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import com.grack.nanojson.JsonArray; import com.grack.nanojson.JsonArray;
@ -71,8 +70,8 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor {
for (final Object badge : badges) { for (final Object badge : badges) {
final JsonObject badgeRenderer final JsonObject badgeRenderer
= ((JsonObject) badge).getObject("metadataBadgeRenderer"); = ((JsonObject) badge).getObject("metadataBadgeRenderer");
if (badgeRenderer.getString("style", EMPTY_STRING).equals("BADGE_STYLE_TYPE_LIVE_NOW") if (badgeRenderer.getString("style", "").equals("BADGE_STYLE_TYPE_LIVE_NOW")
|| badgeRenderer.getString("label", EMPTY_STRING).equals("LIVE NOW")) { || badgeRenderer.getString("label", "").equals("LIVE NOW")) {
cachedStreamType = StreamType.LIVE_STREAM; cachedStreamType = StreamType.LIVE_STREAM;
return cachedStreamType; return cachedStreamType;
} }
@ -81,7 +80,7 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor {
for (final Object overlay : videoInfo.getArray("thumbnailOverlays")) { for (final Object overlay : videoInfo.getArray("thumbnailOverlays")) {
final String style = ((JsonObject) overlay) final String style = ((JsonObject) overlay)
.getObject("thumbnailOverlayTimeStatusRenderer") .getObject("thumbnailOverlayTimeStatusRenderer")
.getString("style", EMPTY_STRING); .getString("style", "");
if (style.equalsIgnoreCase("LIVE")) { if (style.equalsIgnoreCase("LIVE")) {
cachedStreamType = StreamType.LIVE_STREAM; cachedStreamType = StreamType.LIVE_STREAM;
return cachedStreamType; return cachedStreamType;
@ -287,7 +286,7 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor {
final JsonArray badges = videoInfo.getArray("badges"); final JsonArray badges = videoInfo.getArray("badges");
for (final Object badge : badges) { for (final Object badge : badges) {
if (((JsonObject) badge).getObject("metadataBadgeRenderer") if (((JsonObject) badge).getObject("metadataBadgeRenderer")
.getString("label", EMPTY_STRING).equals("Premium")) { .getString("label", "").equals("Premium")) {
return true; return true;
} }
} }

View File

@ -3,14 +3,12 @@ package org.schabi.newpipe.extractor.stream;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
public class Description implements Serializable { public class Description implements Serializable {
public static final int HTML = 1; public static final int HTML = 1;
public static final int MARKDOWN = 2; public static final int MARKDOWN = 2;
public static final int PLAIN_TEXT = 3; public static final int PLAIN_TEXT = 3;
public static final Description EMPTY_DESCRIPTION = new Description(EMPTY_STRING, PLAIN_TEXT); public static final Description EMPTY_DESCRIPTION = new Description("", PLAIN_TEXT);
private final String content; private final String content;
private final int type; private final int type;

View File

@ -3,12 +3,10 @@ package org.schabi.newpipe.extractor.stream;
import org.schabi.newpipe.extractor.MediaFormat; import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.services.youtube.ItagItem; import org.schabi.newpipe.extractor.services.youtube.ItagItem;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Locale; import java.util.Locale;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public final class SubtitlesStream extends Stream { public final class SubtitlesStream extends Stream {
private final MediaFormat format; private final MediaFormat format;
@ -198,7 +196,7 @@ public final class SubtitlesStream extends Stream {
if (id == null) { if (id == null) {
id = languageCode + (mediaFormat != null ? "." + mediaFormat.suffix id = languageCode + (mediaFormat != null ? "." + mediaFormat.suffix
: EMPTY_STRING); : "");
} }
return new SubtitlesStream(id, content, isUrl, mediaFormat, deliveryMethod, return new SubtitlesStream(id, content, isUrl, mediaFormat, deliveryMethod,

View File

@ -25,7 +25,6 @@ public final class Utils {
*/ */
@Deprecated @Deprecated
public static final String UTF_8 = "UTF-8"; public static final String UTF_8 = "UTF-8";
public static final String EMPTY_STRING = "";
private static final Pattern M_PATTERN = Pattern.compile("(https?)?://m\\."); private static final Pattern M_PATTERN = Pattern.compile("(https?)?://m\\.");
private static final Pattern WWW_PATTERN = Pattern.compile("(https?)?://www\\."); private static final Pattern WWW_PATTERN = Pattern.compile("(https?)?://www\\.");

View File

@ -1,15 +1,14 @@
package org.schabi.newpipe.extractor.services.youtube.search; package org.schabi.newpipe.extractor.services.youtube.search;
import org.junit.jupiter.api.Test;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.CHANNELS; import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.CHANNELS;
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.MUSIC_SONGS; import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.MUSIC_SONGS;
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.PLAYLISTS; import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.PLAYLISTS;
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.VIDEOS; import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.VIDEOS;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING; import static java.util.Arrays.asList;
import org.junit.jupiter.api.Test;
public class YoutubeSearchQHTest { public class YoutubeSearchQHTest {
@ -21,37 +20,37 @@ public class YoutubeSearchQHTest {
assertEquals("https://www.youtube.com/results?search_query=G%C3%BCl%C3%BCm", YouTube.getSearchQHFactory().fromQuery("Gülüm").getUrl()); assertEquals("https://www.youtube.com/results?search_query=G%C3%BCl%C3%BCm", YouTube.getSearchQHFactory().fromQuery("Gülüm").getUrl());
assertEquals("https://www.youtube.com/results?search_query=%3Fj%24%29H%C2%A7B", YouTube.getSearchQHFactory().fromQuery("?j$)H§B").getUrl()); assertEquals("https://www.youtube.com/results?search_query=%3Fj%24%29H%C2%A7B", YouTube.getSearchQHFactory().fromQuery("?j$)H§B").getUrl());
assertEquals("https://music.youtube.com/search?q=asdf", YouTube.getSearchQHFactory().fromQuery("asdf", asList(new String[]{MUSIC_SONGS}), EMPTY_STRING).getUrl()); assertEquals("https://music.youtube.com/search?q=asdf", YouTube.getSearchQHFactory().fromQuery("asdf", asList(new String[]{MUSIC_SONGS}), "").getUrl());
assertEquals("https://music.youtube.com/search?q=hans", YouTube.getSearchQHFactory().fromQuery("hans", asList(new String[]{MUSIC_SONGS}), EMPTY_STRING).getUrl()); assertEquals("https://music.youtube.com/search?q=hans", YouTube.getSearchQHFactory().fromQuery("hans", asList(new String[]{MUSIC_SONGS}), "").getUrl());
assertEquals("https://music.youtube.com/search?q=Poifj%26jaijf", YouTube.getSearchQHFactory().fromQuery("Poifj&jaijf", asList(new String[]{MUSIC_SONGS}), EMPTY_STRING).getUrl()); assertEquals("https://music.youtube.com/search?q=Poifj%26jaijf", YouTube.getSearchQHFactory().fromQuery("Poifj&jaijf", asList(new String[]{MUSIC_SONGS}), "").getUrl());
assertEquals("https://music.youtube.com/search?q=G%C3%BCl%C3%BCm", YouTube.getSearchQHFactory().fromQuery("Gülüm", asList(new String[]{MUSIC_SONGS}), EMPTY_STRING).getUrl()); assertEquals("https://music.youtube.com/search?q=G%C3%BCl%C3%BCm", YouTube.getSearchQHFactory().fromQuery("Gülüm", asList(new String[]{MUSIC_SONGS}), "").getUrl());
assertEquals("https://music.youtube.com/search?q=%3Fj%24%29H%C2%A7B", YouTube.getSearchQHFactory().fromQuery("?j$)H§B", asList(new String[]{MUSIC_SONGS}), EMPTY_STRING).getUrl()); assertEquals("https://music.youtube.com/search?q=%3Fj%24%29H%C2%A7B", YouTube.getSearchQHFactory().fromQuery("?j$)H§B", asList(new String[]{MUSIC_SONGS}), "").getUrl());
} }
@Test @Test
public void testGetContentFilter() throws Exception { public void testGetContentFilter() throws Exception {
assertEquals(VIDEOS, YouTube.getSearchQHFactory() assertEquals(VIDEOS, YouTube.getSearchQHFactory()
.fromQuery(EMPTY_STRING, asList(new String[]{VIDEOS}), EMPTY_STRING).getContentFilters().get(0)); .fromQuery("", asList(new String[]{VIDEOS}), "").getContentFilters().get(0));
assertEquals(CHANNELS, YouTube.getSearchQHFactory() assertEquals(CHANNELS, YouTube.getSearchQHFactory()
.fromQuery("asdf", asList(new String[]{CHANNELS}), EMPTY_STRING).getContentFilters().get(0)); .fromQuery("asdf", asList(new String[]{CHANNELS}), "").getContentFilters().get(0));
assertEquals(MUSIC_SONGS, YouTube.getSearchQHFactory() assertEquals(MUSIC_SONGS, YouTube.getSearchQHFactory()
.fromQuery("asdf", asList(new String[]{MUSIC_SONGS}), EMPTY_STRING).getContentFilters().get(0)); .fromQuery("asdf", asList(new String[]{MUSIC_SONGS}), "").getContentFilters().get(0));
} }
@Test @Test
public void testWithContentfilter() throws Exception { public void testWithContentfilter() throws Exception {
assertEquals("https://www.youtube.com/results?search_query=asdf&sp=EgIQAQ%253D%253D", YouTube.getSearchQHFactory() assertEquals("https://www.youtube.com/results?search_query=asdf&sp=EgIQAQ%253D%253D", YouTube.getSearchQHFactory()
.fromQuery("asdf", asList(new String[]{VIDEOS}), EMPTY_STRING).getUrl()); .fromQuery("asdf", asList(new String[]{VIDEOS}), "").getUrl());
assertEquals("https://www.youtube.com/results?search_query=asdf&sp=EgIQAg%253D%253D", YouTube.getSearchQHFactory() assertEquals("https://www.youtube.com/results?search_query=asdf&sp=EgIQAg%253D%253D", YouTube.getSearchQHFactory()
.fromQuery("asdf", asList(new String[]{CHANNELS}), EMPTY_STRING).getUrl()); .fromQuery("asdf", asList(new String[]{CHANNELS}), "").getUrl());
assertEquals("https://www.youtube.com/results?search_query=asdf&sp=EgIQAw%253D%253D", YouTube.getSearchQHFactory() assertEquals("https://www.youtube.com/results?search_query=asdf&sp=EgIQAw%253D%253D", YouTube.getSearchQHFactory()
.fromQuery("asdf", asList(new String[]{PLAYLISTS}), EMPTY_STRING).getUrl()); .fromQuery("asdf", asList(new String[]{PLAYLISTS}), "").getUrl());
assertEquals("https://www.youtube.com/results?search_query=asdf", YouTube.getSearchQHFactory() assertEquals("https://www.youtube.com/results?search_query=asdf", YouTube.getSearchQHFactory()
.fromQuery("asdf", asList(new String[]{"fjiijie"}), EMPTY_STRING).getUrl()); .fromQuery("asdf", asList(new String[]{"fjiijie"}), "").getUrl());
assertEquals("https://music.youtube.com/search?q=asdf", YouTube.getSearchQHFactory() assertEquals("https://music.youtube.com/search?q=asdf", YouTube.getSearchQHFactory()
.fromQuery("asdf", asList(new String[]{MUSIC_SONGS}), EMPTY_STRING).getUrl()); .fromQuery("asdf", asList(new String[]{MUSIC_SONGS}), "").getUrl());
} }
@Test @Test

View File

@ -24,7 +24,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
@ -409,7 +408,7 @@ public class YoutubeStreamExtractorDefaultTest {
@Override public long expectedDislikeCountAtLeast() { return -1; } @Override public long expectedDislikeCountAtLeast() { return -1; }
@Override public List<MetaInfo> expectedMetaInfo() throws MalformedURLException { @Override public List<MetaInfo> expectedMetaInfo() throws MalformedURLException {
return Collections.singletonList(new MetaInfo( return Collections.singletonList(new MetaInfo(
EMPTY_STRING, "",
new Description("Funk is a German public broadcast service.", Description.PLAIN_TEXT), new Description("Funk is a German public broadcast service.", Description.PLAIN_TEXT),
Collections.singletonList(new URL("https://de.wikipedia.org/wiki/Funk_(Medienangebot)?wprov=yicw1")), Collections.singletonList(new URL("https://de.wikipedia.org/wiki/Funk_(Medienangebot)?wprov=yicw1")),
Collections.singletonList("Wikipedia (German)") Collections.singletonList("Wikipedia (German)")