Remove EMPTY_STRING.
This commit is contained in:
parent
20914a6035
commit
943b7c033b
34 changed files with 188 additions and 216 deletions
|
@ -6,7 +6,6 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeCommentsInfoItemExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -36,14 +35,14 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {
|
|||
* It may be language dependent
|
||||
*/
|
||||
default String getTextualLikeCount() throws ParsingException {
|
||||
return Utils.EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* The text of the comment
|
||||
*/
|
||||
default String getCommentText() throws ParsingException {
|
||||
return Utils.EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +51,7 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {
|
|||
* @see StreamExtractor#getTextualUploadDate()
|
||||
*/
|
||||
default String getTextualUploadDate() throws ParsingException {
|
||||
return Utils.EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,19 +65,19 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {
|
|||
}
|
||||
|
||||
default String getCommentId() throws ParsingException {
|
||||
return Utils.EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
default String getUploaderUrl() throws ParsingException {
|
||||
return Utils.EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
default String getUploaderName() throws ParsingException {
|
||||
return Utils.EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
default String getUploaderAvatarUrl() throws ParsingException {
|
||||
return Utils.EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.schabi.newpipe.extractor.linkhandler;
|
||||
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -32,7 +30,7 @@ public class ListLinkHandler extends LinkHandler {
|
|||
handler.url,
|
||||
handler.id,
|
||||
Collections.emptyList(),
|
||||
EMPTY_STRING);
|
||||
"");
|
||||
}
|
||||
|
||||
public List<String> getContentFilters() {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.schabi.newpipe.extractor.linkhandler;
|
||||
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
|
||||
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
|
||||
import java.util.Collections;
|
||||
|
@ -39,7 +37,7 @@ public abstract class SearchQueryHandlerFactory extends ListLinkHandlerFactory {
|
|||
}
|
||||
|
||||
public SearchQueryHandler fromQuery(final String query) throws ParsingException {
|
||||
return fromQuery(query, Collections.emptyList(), EMPTY_STRING);
|
||||
return fromQuery(query, Collections.emptyList(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,8 +8,6 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
|
||||
|
||||
public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
|
||||
|
||||
public PlaylistExtractor(final StreamingService service, final ListLinkHandler linkHandler) {
|
||||
|
@ -25,29 +23,29 @@ public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
|
|||
|
||||
@Nonnull
|
||||
public String getThumbnailUrl() throws ParsingException {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public String getBannerUrl() throws ParsingException {
|
||||
// Banner can't be handled by frontend right now.
|
||||
// Whoever is willing to implement this should also implement it in the frontend.
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public String getSubChannelName() throws ParsingException {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public String getSubChannelUrl() throws ParsingException {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public String getSubChannelAvatarUrl() throws ParsingException {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
public PlaylistInfo.PlaylistType getPlaylistType() throws ParsingException {
|
||||
|
|
|
@ -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.BandcampStreamExtractor.getAlbumInfoJson;
|
||||
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 com.grack.nanojson.JsonArray;
|
||||
|
@ -73,7 +72,7 @@ public class BandcampPlaylistExtractor extends PlaylistExtractor {
|
|||
@Override
|
||||
public String getThumbnailUrl() throws ParsingException {
|
||||
if (albumJson.isNull("art_id")) {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
} else {
|
||||
return getImageUrl(albumJson.getLong("art_id"), true);
|
||||
}
|
||||
|
@ -96,7 +95,7 @@ public class BandcampPlaylistExtractor extends PlaylistExtractor {
|
|||
return document.getElementsByClass("band-photo").stream()
|
||||
.map(element -> element.attr("src"))
|
||||
.findFirst()
|
||||
.orElse(EMPTY_STRING);
|
||||
.orElse("");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
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.JsonObject;
|
||||
import com.grack.nanojson.JsonParser;
|
||||
import com.grack.nanojson.JsonParserException;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Element;
|
||||
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.StreamSegment;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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 static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BandcampRadioStreamExtractor extends BandcampStreamExtractor {
|
||||
|
||||
|
@ -163,14 +164,14 @@ public class BandcampRadioStreamExtractor extends BandcampStreamExtractor {
|
|||
@Override
|
||||
public String getLicence() {
|
||||
// Contrary to other Bandcamp streams, radio streams don't have a license
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getCategory() {
|
||||
// Contrary to other Bandcamp streams, radio streams don't have categories
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -2,29 +2,30 @@
|
|||
|
||||
package org.schabi.newpipe.extractor.services.bandcamp.extractors;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.MetaInfo;
|
||||
import org.schabi.newpipe.extractor.MultiInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.Page;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.downloader.Downloader;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
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.services.bandcamp.extractors.streaminfoitem.BandcampSearchStreamInfoItemExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
|
||||
public class BandcampSearchExtractor extends SearchExtractor {
|
||||
|
||||
public BandcampSearchExtractor(final StreamingService service,
|
||||
|
@ -35,7 +36,7 @@ public class BandcampSearchExtractor extends SearchExtractor {
|
|||
@NonNull
|
||||
@Override
|
||||
public String getSearchSuggestion() {
|
||||
return Utils.EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +60,7 @@ public class BandcampSearchExtractor extends SearchExtractor {
|
|||
.flatMap(element -> element.getElementsByClass("itemtype").stream())
|
||||
.map(Element::text)
|
||||
.findFirst()
|
||||
.orElse(Utils.EMPTY_STRING);
|
||||
.orElse("");
|
||||
|
||||
switch (type) {
|
||||
case "ARTIST":
|
||||
|
|
|
@ -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.utils.Utils.EMPTY_STRING;
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.HTTPS;
|
||||
|
||||
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.Utils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BandcampStreamExtractor extends StreamExtractor {
|
||||
private JsonObject albumJson;
|
||||
private JsonObject current;
|
||||
|
@ -118,7 +118,7 @@ public class BandcampStreamExtractor extends StreamExtractor {
|
|||
@Override
|
||||
public String getThumbnailUrl() throws ParsingException {
|
||||
if (albumJson.isNull("art_id")) {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
return getImageUrl(albumJson.getLong("art_id"), true);
|
||||
|
@ -130,7 +130,7 @@ public class BandcampStreamExtractor extends StreamExtractor {
|
|||
return document.getElementsByClass("band-photo").stream()
|
||||
.map(element -> element.attr("src"))
|
||||
.findFirst()
|
||||
.orElse(Utils.EMPTY_STRING);
|
||||
.orElse("");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -194,7 +194,7 @@ public class BandcampStreamExtractor extends StreamExtractor {
|
|||
.flatMap(element -> element.getElementsByClass("tag").stream())
|
||||
.map(Element::text)
|
||||
.findFirst()
|
||||
.orElse(EMPTY_STRING);
|
||||
.orElse("");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
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.JsonObject;
|
||||
|
||||
|
@ -25,10 +28,6 @@ import java.util.stream.Collectors;
|
|||
|
||||
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 {
|
||||
private static final String STREAMS = "streams";
|
||||
private static final String URLS = "urls";
|
||||
|
@ -149,9 +148,9 @@ public class MediaCCCLiveStreamExtractor extends StreamExtractor {
|
|||
.map(JsonObject.class::cast)
|
||||
.map(streamObject -> streamObject.getObject(URLS))
|
||||
.filter(urls -> urls.has(deliveryMethod))
|
||||
.map(urls -> urls.getObject(deliveryMethod).getString(URL, EMPTY_STRING))
|
||||
.map(urls -> urls.getObject(deliveryMethod).getString(URL, ""))
|
||||
.findFirst()
|
||||
.orElse(EMPTY_STRING);
|
||||
.orElse("");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.schabi.newpipe.extractor.services.peertube.extractors;
|
||||
|
||||
import com.grack.nanojson.JsonObject;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.schabi.newpipe.extractor.ServiceList;
|
||||
|
@ -12,8 +13,6 @@ import org.schabi.newpipe.extractor.utils.JsonUtils;
|
|||
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
|
||||
|
||||
public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtractor {
|
||||
private final JsonObject item;
|
||||
private final String url;
|
||||
|
@ -66,7 +65,7 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
|
|||
final Document doc = Jsoup.parse(htmlText);
|
||||
return doc.body().text();
|
||||
} catch (final Exception e) {
|
||||
return htmlText.replaceAll("(?s)<[^>]*>(\\s*<[^>]*>)*", EMPTY_STRING);
|
||||
return htmlText.replaceAll("(?s)<[^>]*>(\\s*<[^>]*>)*", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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.isNullOrEmpty;
|
||||
|
||||
|
@ -45,9 +46,6 @@ import java.util.stream.Collectors;
|
|||
import javax.annotation.Nonnull;
|
||||
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 {
|
||||
private static final String ACCOUNT_HOST = "account.host";
|
||||
private static final String ACCOUNT_NAME = "account.name";
|
||||
|
@ -219,11 +217,10 @@ public class PeertubeStreamExtractor extends StreamExtractor {
|
|||
|
||||
if (getStreamType() == StreamType.VIDEO_STREAM
|
||||
&& !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,
|
||||
EMPTY_STRING);
|
||||
return json.getArray(STREAMING_PLAYLISTS).getObject(0).getString(PLAYLIST_URL, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -319,7 +316,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
|
|||
try {
|
||||
return JsonUtils.getString(json, "support");
|
||||
} catch (final ParsingException e) {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -440,9 +437,9 @@ public class PeertubeStreamExtractor extends StreamExtractor {
|
|||
.map(JsonObject.class::cast)
|
||||
.map(stream -> new VideoStream.Builder()
|
||||
.setId(String.valueOf(stream.getInt("id", -1)))
|
||||
.setContent(stream.getString(PLAYLIST_URL, EMPTY_STRING), true)
|
||||
.setContent(stream.getString(PLAYLIST_URL, ""), true)
|
||||
.setIsVideoOnly(false)
|
||||
.setResolution(EMPTY_STRING)
|
||||
.setResolution("")
|
||||
.setMediaFormat(MediaFormat.MPEG_4)
|
||||
.setDeliveryMethod(DeliveryMethod.HLS)
|
||||
.build())
|
||||
|
@ -457,7 +454,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
|
|||
|
||||
private void getStreams() throws ParsingException {
|
||||
// Progressive streams
|
||||
getStreamsFromArray(json.getArray(FILES), EMPTY_STRING);
|
||||
getStreamsFromArray(json.getArray(FILES), "");
|
||||
|
||||
// HLS streams
|
||||
try {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.schabi.newpipe.extractor.services.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.isNullOrEmpty;
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
|
||||
|
@ -313,17 +312,17 @@ public final class SoundcloudParsingHelper {
|
|||
|
||||
@Nonnull
|
||||
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);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
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);
|
||||
}
|
||||
|
||||
public static String getUploaderName(final JsonObject object) {
|
||||
return object.getObject("user").getString("username", EMPTY_STRING);
|
||||
return object.getObject("user").getString("username", "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
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.JsonParser;
|
||||
import com.grack.nanojson.JsonParserException;
|
||||
|
||||
import org.schabi.newpipe.extractor.Page;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
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.StreamInfoItemsCollector;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
||||
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;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class SoundcloudChannelExtractor extends ChannelExtractor {
|
||||
private String userId;
|
||||
|
@ -82,7 +83,7 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
|||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return user.getString("description", EMPTY_STRING);
|
||||
return user.getString("description", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
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 com.grack.nanojson.JsonObject;
|
||||
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
|
||||
|
||||
public class SoundcloudChannelInfoItemExtractor implements ChannelInfoItemExtractor {
|
||||
private final JsonObject itemObject;
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class SoundcloudChannelInfoItemExtractor implements ChannelInfoItemExtrac
|
|||
@Override
|
||||
public String getThumbnailUrl() {
|
||||
// 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
|
||||
|
@ -46,6 +46,6 @@ public class SoundcloudChannelInfoItemExtractor implements ChannelInfoItemExtrac
|
|||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return itemObject.getString("description", EMPTY_STRING);
|
||||
return itemObject.getString("description", "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
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.JsonObject;
|
||||
import com.grack.nanojson.JsonParser;
|
||||
|
@ -23,10 +26,6 @@ import java.util.List;
|
|||
|
||||
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 {
|
||||
private static final int STREAMS_PER_REQUESTED_PAGE = 15;
|
||||
|
||||
|
@ -87,7 +86,7 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
|
|||
}
|
||||
|
||||
if (artworkUrl == null) {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package org.schabi.newpipe.extractor.services.soundcloud.extractors;
|
||||
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
|
||||
|
||||
import com.grack.nanojson.JsonObject;
|
||||
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
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 {
|
||||
private static final String USER_KEY = "user";
|
||||
private static final String AVATAR_URL_KEY = "avatar_url";
|
||||
|
@ -32,7 +32,7 @@ public class SoundcloudPlaylistInfoItemExtractor implements PlaylistInfoItemExtr
|
|||
public String getThumbnailUrl() throws ParsingException {
|
||||
// Over-engineering at its finest
|
||||
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()) {
|
||||
// An artwork URL with a better resolution
|
||||
return artworkUrl.replace("large.jpg", "crop.jpg");
|
||||
|
@ -46,7 +46,7 @@ public class SoundcloudPlaylistInfoItemExtractor implements PlaylistInfoItemExtr
|
|||
|
||||
// First look for track artwork url
|
||||
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()) {
|
||||
// An artwork URL with a better resolution
|
||||
return artworkUrl.replace("large.jpg", "crop.jpg");
|
||||
|
@ -55,7 +55,7 @@ public class SoundcloudPlaylistInfoItemExtractor implements PlaylistInfoItemExtr
|
|||
|
||||
// Then look for track creator avatar url
|
||||
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()) {
|
||||
return creatorAvatar;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class SoundcloudPlaylistInfoItemExtractor implements PlaylistInfoItemExtr
|
|||
|
||||
try {
|
||||
// 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) {
|
||||
throw new ParsingException("Failed to extract playlist thumbnail url", e);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
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.JsonObject;
|
||||
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.InfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.MetaInfo;
|
||||
import org.schabi.newpipe.extractor.MultiInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.Page;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.downloader.Downloader;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
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.utils.Parser;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
|
@ -28,9 +30,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
|
||||
import static org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudSearchQueryHandlerFactory.ITEMS_PER_PAGE;
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class SoundcloudSearchExtractor extends SearchExtractor {
|
||||
private JsonArray initialSearchCollection;
|
||||
|
@ -114,7 +114,7 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
|
|||
}
|
||||
|
||||
final JsonObject searchResult = (JsonObject) result;
|
||||
final String kind = searchResult.getString("kind", EMPTY_STRING);
|
||||
final String kind = searchResult.getString("kind", "");
|
||||
switch (kind) {
|
||||
case "user":
|
||||
collector.commit(new SoundcloudChannelInfoItemExtractor(searchResult));
|
||||
|
|
|
@ -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.stream.AudioStream.UNKNOWN_BITRATE;
|
||||
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.isNullOrEmpty;
|
||||
|
||||
|
@ -58,7 +57,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
|||
ExtractionException {
|
||||
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")) {
|
||||
isAvailable = false;
|
||||
|
||||
|
@ -92,7 +91,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
|||
public String getTextualUploadDate() {
|
||||
return track.getString("created_at")
|
||||
.replace("T", " ")
|
||||
.replace("Z", EMPTY_STRING);
|
||||
.replace("Z", "");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -105,9 +104,9 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
|||
@Nonnull
|
||||
@Override
|
||||
public String getThumbnailUrl() {
|
||||
String artworkUrl = track.getString("artwork_url", EMPTY_STRING);
|
||||
String artworkUrl = track.getString("artwork_url", "");
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package org.schabi.newpipe.extractor.services.soundcloud.extractors;
|
||||
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
|
||||
|
||||
import com.grack.nanojson.JsonObject;
|
||||
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper;
|
||||
|
@ -9,9 +12,6 @@ import org.schabi.newpipe.extractor.stream.StreamType;
|
|||
|
||||
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 {
|
||||
|
||||
protected final JsonObject itemObject;
|
||||
|
@ -73,7 +73,7 @@ public class SoundcloudStreamInfoItemExtractor implements StreamInfoItemExtracto
|
|||
|
||||
@Override
|
||||
public String getThumbnailUrl() {
|
||||
String artworkUrl = itemObject.getString("artwork_url", EMPTY_STRING);
|
||||
String artworkUrl = itemObject.getString("artwork_url", "");
|
||||
if (artworkUrl.isEmpty()) {
|
||||
artworkUrl = itemObject.getObject("user").getString("avatar_url");
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
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.HTTPS;
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.UTF_8;
|
||||
|
@ -827,7 +826,7 @@ public final class YoutubeParsingHelper {
|
|||
.value("hl", "en-GB")
|
||||
.value("gl", "GB")
|
||||
.array("experimentIds").end()
|
||||
.value("experimentsToken", EMPTY_STRING)
|
||||
.value("experimentsToken", "")
|
||||
.object("locationInfo").end()
|
||||
.object("musicAppInfo").end()
|
||||
.end()
|
||||
|
@ -1397,10 +1396,10 @@ public final class YoutubeParsingHelper {
|
|||
@Nonnull final Response response) {
|
||||
final List<String> cookies = response.responseHeaders().get("set-cookie");
|
||||
if (cookies == null) {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
String result = EMPTY_STRING;
|
||||
String result = "";
|
||||
for (final String cookie : cookies) {
|
||||
final int startIndex = cookie.indexOf(cookieName);
|
||||
if (startIndex != -1) {
|
||||
|
@ -1426,7 +1425,7 @@ public final class YoutubeParsingHelper {
|
|||
if (!isNullOrEmpty(alerts)) {
|
||||
final JsonObject alertRenderer = alerts.getObject(0).getObject("alertRenderer");
|
||||
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 (alertText != null && alertText.contains("This account has been terminated")) {
|
||||
if (alertText.contains("violation") || alertText.contains("violating")
|
||||
|
|
|
@ -1,18 +1,5 @@
|
|||
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.RN_0;
|
||||
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.getInitializationResponse;
|
||||
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 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}.
|
||||
*/
|
||||
|
@ -112,8 +112,8 @@ public final class YoutubeOtfDashManifestCreator {
|
|||
// from video servers.
|
||||
final Response response = getInitializationResponse(realOtfBaseStreamingUrl,
|
||||
itagItem, DeliveryType.OTF);
|
||||
realOtfBaseStreamingUrl = response.latestUrl().replace(SQ_0, EMPTY_STRING)
|
||||
.replace(RN_0, EMPTY_STRING).replace(ALR_YES, EMPTY_STRING);
|
||||
realOtfBaseStreamingUrl = response.latestUrl().replace(SQ_0, "")
|
||||
.replace(RN_0, "").replace(ALR_YES, "");
|
||||
|
||||
final int responseCode = response.responseCode();
|
||||
if (responseCode != 200) {
|
||||
|
|
|
@ -1,18 +1,5 @@
|
|||
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.RN_0;
|
||||
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.getInitializationResponse;
|
||||
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 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
|
||||
* {@link DeliveryType#LIVE LIVE delivery type}).
|
||||
|
@ -130,8 +130,8 @@ public final class YoutubePostLiveStreamDvrDashManifestCreator {
|
|||
// from video servers.
|
||||
final Response response = getInitializationResponse(realPostLiveStreamDvrStreamingUrl,
|
||||
itagItem, DeliveryType.LIVE);
|
||||
realPostLiveStreamDvrStreamingUrl = response.latestUrl().replace(SQ_0, EMPTY_STRING)
|
||||
.replace(RN_0, EMPTY_STRING).replace(ALR_YES, EMPTY_STRING);
|
||||
realPostLiveStreamDvrStreamingUrl = response.latestUrl().replace(SQ_0, "")
|
||||
.replace(RN_0, "").replace(ALR_YES, "");
|
||||
|
||||
final int responseCode = response.responseCode();
|
||||
if (responseCode != 200) {
|
||||
|
|
|
@ -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.getValidJsonResponseBody;
|
||||
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.isNullOrEmpty;
|
||||
|
||||
|
@ -120,10 +119,10 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
|
||||
final String webPageType = endpoint.getObject("commandMetadata")
|
||||
.getObject("webCommandMetadata")
|
||||
.getString("webPageType", EMPTY_STRING);
|
||||
.getString("webPageType", "");
|
||||
|
||||
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")
|
||||
|| webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_CHANNEL")
|
||||
|
@ -171,10 +170,10 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
|
||||
final String webPageType = endpoint.getObject("commandMetadata")
|
||||
.getObject("webCommandMetadata")
|
||||
.getString("webPageType", EMPTY_STRING);
|
||||
.getString("webPageType", "");
|
||||
|
||||
final String browseId = endpoint.getObject("browseEndpoint").getString("browseId",
|
||||
EMPTY_STRING);
|
||||
"");
|
||||
|
||||
if (webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_BROWSE")
|
||||
|| webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_CHANNEL")
|
||||
|
@ -215,7 +214,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
public String getId() throws ParsingException {
|
||||
final String channelId = initialData.getObject("header")
|
||||
.getObject("c4TabbedHeaderRenderer")
|
||||
.getString("channelId", EMPTY_STRING);
|
||||
.getString("channelId", "");
|
||||
|
||||
if (!channelId.isEmpty()) {
|
||||
return channelId;
|
||||
|
@ -456,7 +455,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
for (final Object tab : tabs) {
|
||||
if (((JsonObject) tab).has("tabRenderer")) {
|
||||
if (((JsonObject) tab).getObject("tabRenderer").getString("title",
|
||||
EMPTY_STRING).equals("Videos")) {
|
||||
"").equals("Videos")) {
|
||||
foundVideoTab = ((JsonObject) tab).getObject("tabRenderer");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,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.utils.Utils.EMPTY_STRING;
|
||||
|
||||
import com.grack.nanojson.JsonArray;
|
||||
import com.grack.nanojson.JsonObject;
|
||||
|
@ -63,7 +62,7 @@ public class YoutubeCommentsInfoItemExtractor implements CommentsInfoItemExtract
|
|||
try {
|
||||
return getTextFromObject(JsonUtils.getObject(getCommentRenderer(), "authorText"));
|
||||
} catch (final Exception e) {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,12 +161,12 @@ public class YoutubeCommentsInfoItemExtractor implements CommentsInfoItemExtract
|
|||
try {
|
||||
// If a comment has no likes voteCount is not set
|
||||
if (!getCommentRenderer().has("voteCount")) {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
final JsonObject voteCountObj = JsonUtils.getObject(getCommentRenderer(), "voteCount");
|
||||
if (voteCountObj.isEmpty()) {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
return getTextFromObject(voteCountObj);
|
||||
} catch (final Exception e) {
|
||||
|
@ -182,7 +181,7 @@ public class YoutubeCommentsInfoItemExtractor implements CommentsInfoItemExtract
|
|||
if (contentText.isEmpty()) {
|
||||
// completely empty comments as described in
|
||||
// https://github.com/TeamNewPipe/NewPipeExtractor/issues/380#issuecomment-668808584
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
final String commentText = getTextFromObject(contentText);
|
||||
// YouTube adds U+FEFF in some comments.
|
||||
|
@ -235,7 +234,7 @@ public class YoutubeCommentsInfoItemExtractor implements CommentsInfoItemExtract
|
|||
try {
|
||||
return getTextFromObject(JsonUtils.getObject(getCommentRenderer(), "authorText"));
|
||||
} 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(),
|
||||
"authorEndpoint.browseEndpoint.browseId");
|
||||
} catch (final Exception e) {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.getValidJsonResponseBody;
|
||||
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.isNullOrEmpty;
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.stringToURL;
|
||||
|
@ -144,7 +143,7 @@ public class YoutubeMixPlaylistExtractor extends PlaylistExtractor {
|
|||
@Override
|
||||
public String getUploaderUrl() {
|
||||
// YouTube mixes are auto-generated by YouTube
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -156,7 +155,7 @@ public class YoutubeMixPlaylistExtractor extends PlaylistExtractor {
|
|||
@Override
|
||||
public String getUploaderAvatarUrl() {
|
||||
// YouTube mixes are auto-generated by YouTube
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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_SONGS;
|
||||
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.isNullOrEmpty;
|
||||
|
||||
|
@ -97,7 +96,7 @@ public class YoutubeMusicSearchExtractor extends SearchExtractor {
|
|||
.value("hl", "en-GB")
|
||||
.value("gl", getExtractorContentCountry().getCountryCode())
|
||||
.array("experimentIds").end()
|
||||
.value("experimentsToken", EMPTY_STRING)
|
||||
.value("experimentsToken", "")
|
||||
.object("locationInfo").end()
|
||||
.object("musicAppInfo").end()
|
||||
.end()
|
||||
|
@ -288,7 +287,7 @@ public class YoutubeMusicSearchExtractor extends SearchExtractor {
|
|||
.getObject("musicResponsiveListItemRenderer", null);
|
||||
if (info != null) {
|
||||
final String displayPolicy = info.getString("musicItemRendererDisplayPolicy",
|
||||
EMPTY_STRING);
|
||||
"");
|
||||
if (displayPolicy.equals("MUSIC_ITEM_RENDERER_DISPLAY_POLICY_GREY_OUT")) {
|
||||
continue; // No info about video URL available
|
||||
}
|
||||
|
@ -354,7 +353,7 @@ public class YoutubeMusicSearchExtractor extends SearchExtractor {
|
|||
((JsonObject) item).getObject(
|
||||
"menuNavigationItemRenderer");
|
||||
if (menuNavigationItemRenderer.getObject("icon")
|
||||
.getString("iconType", EMPTY_STRING)
|
||||
.getString("iconType", "")
|
||||
.equals("ARTIST")) {
|
||||
return getUrlFromNavigationEndpoint(
|
||||
menuNavigationItemRenderer
|
||||
|
|
|
@ -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.getValidJsonResponseBody;
|
||||
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 com.grack.nanojson.JsonArray;
|
||||
|
@ -217,19 +216,19 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
|
|||
@Nonnull
|
||||
@Override
|
||||
public String getSubChannelName() {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getSubChannelUrl() {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getSubChannelAvatarUrl() {
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
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.CONTENT_LENGTH_UNKNOWN;
|
||||
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.RACY_CHECK_OK;
|
||||
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.ItagItem.CONTENT_LENGTH_UNKNOWN;
|
||||
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.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.prepareDesktopJsonBuilder;
|
||||
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 com.grack.nanojson.JsonArray;
|
||||
|
@ -185,18 +184,18 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
@Nullable
|
||||
@Override
|
||||
public String getTextualUploadDate() throws ParsingException {
|
||||
if (!playerMicroFormatRenderer.getString("uploadDate", EMPTY_STRING).isEmpty()) {
|
||||
if (!playerMicroFormatRenderer.getString("uploadDate", "").isEmpty()) {
|
||||
return playerMicroFormatRenderer.getString("uploadDate");
|
||||
} else if (!playerMicroFormatRenderer.getString("publishDate", EMPTY_STRING).isEmpty()) {
|
||||
} else if (!playerMicroFormatRenderer.getString("publishDate", "").isEmpty()) {
|
||||
return playerMicroFormatRenderer.getString("publishDate");
|
||||
}
|
||||
|
||||
final JsonObject liveDetails = playerMicroFormatRenderer.getObject(
|
||||
"liveBroadcastDetails");
|
||||
if (!liveDetails.getString("endTimestamp", EMPTY_STRING).isEmpty()) {
|
||||
if (!liveDetails.getString("endTimestamp", "").isEmpty()) {
|
||||
// an ended live stream
|
||||
return liveDetails.getString("endTimestamp");
|
||||
} else if (!liveDetails.getString("startTimestamp", EMPTY_STRING).isEmpty()) {
|
||||
} else if (!liveDetails.getString("startTimestamp", "").isEmpty()) {
|
||||
// a running live stream
|
||||
return liveDetails.getString("startTimestamp");
|
||||
} else if (getStreamType() == StreamType.LIVE_STREAM) {
|
||||
|
@ -331,7 +330,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
// Only JsonObjects allowed
|
||||
.filter(JsonObject.class::isInstance)
|
||||
.map(JsonObject.class::cast))
|
||||
.map(run -> run.getString("text", EMPTY_STRING))
|
||||
.map(run -> run.getString("text", ""))
|
||||
.anyMatch(rowText -> rowText.contains("Age-restricted"));
|
||||
|
||||
ageLimit = ageRestricted ? 18 : NO_AGE_LIMIT;
|
||||
|
@ -521,7 +520,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
throw new ParsingException("Could not get uploader avatar URL");
|
||||
}
|
||||
|
||||
return EMPTY_STRING;
|
||||
return "";
|
||||
}
|
||||
|
||||
return fixThumbnailUrl(url);
|
||||
|
@ -577,7 +576,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
.map(streamingDataObject -> streamingDataObject.getString(manifestKey))
|
||||
.filter(Objects::nonNull)
|
||||
.findFirst()
|
||||
.orElse(EMPTY_STRING);
|
||||
.orElse("");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -791,7 +790,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
|
||||
final JsonObject playabilityStatus = playerResponse.getObject("playabilityStatus");
|
||||
|
||||
final boolean isAgeRestricted = playabilityStatus.getString("reason", EMPTY_STRING)
|
||||
final boolean isAgeRestricted = playabilityStatus.getString("reason", "")
|
||||
.contains("age");
|
||||
|
||||
setStreamType();
|
||||
|
@ -1298,7 +1297,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
* <li>the height returned by the {@link ItagItem} + {@code p} + the frame rate if
|
||||
* it is more than 30;</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>
|
||||
* </li>
|
||||
* <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();
|
||||
builder.setResolution(resolutionString != null ? resolutionString
|
||||
: EMPTY_STRING);
|
||||
: "");
|
||||
|
||||
if (streamType != StreamType.VIDEO_STREAM || !itagInfo.getIsUrl()) {
|
||||
// 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 indexRange = formatData.getObject("indexRange");
|
||||
final String mimeType = formatData.getString("mimeType", EMPTY_STRING);
|
||||
final String mimeType = formatData.getString("mimeType", "");
|
||||
final String codec = mimeType.contains("codecs")
|
||||
? mimeType.split("\"")[1] : EMPTY_STRING;
|
||||
? mimeType.split("\"")[1] : "";
|
||||
|
||||
itagItem.setBitrate(formatData.getInt("bitrate"));
|
||||
itagItem.setWidth(formatData.getInt("width"));
|
||||
|
@ -1437,7 +1436,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
final ItagInfo itagInfo = new ItagInfo(streamUrl, itagItem);
|
||||
|
||||
if (streamType == StreamType.VIDEO_STREAM) {
|
||||
itagInfo.setIsUrl(!formatData.getString("type", EMPTY_STRING)
|
||||
itagInfo.setIsUrl(!formatData.getString("type", "")
|
||||
.equalsIgnoreCase("FORMAT_STREAM_TYPE_OTF"));
|
||||
} else {
|
||||
// We are currently not able to generate DASH manifests for running
|
||||
|
@ -1523,7 +1522,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
@Nonnull
|
||||
@Override
|
||||
public String getCategory() {
|
||||
return playerMicroFormatRenderer.getString("category", EMPTY_STRING);
|
||||
return playerMicroFormatRenderer.getString("category", "");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -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.getThumbnailUrlFromInfoItem;
|
||||
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 com.grack.nanojson.JsonArray;
|
||||
|
@ -71,8 +70,8 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor {
|
|||
for (final Object badge : badges) {
|
||||
final JsonObject badgeRenderer
|
||||
= ((JsonObject) badge).getObject("metadataBadgeRenderer");
|
||||
if (badgeRenderer.getString("style", EMPTY_STRING).equals("BADGE_STYLE_TYPE_LIVE_NOW")
|
||||
|| badgeRenderer.getString("label", EMPTY_STRING).equals("LIVE NOW")) {
|
||||
if (badgeRenderer.getString("style", "").equals("BADGE_STYLE_TYPE_LIVE_NOW")
|
||||
|| badgeRenderer.getString("label", "").equals("LIVE NOW")) {
|
||||
cachedStreamType = StreamType.LIVE_STREAM;
|
||||
return cachedStreamType;
|
||||
}
|
||||
|
@ -81,7 +80,7 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor {
|
|||
for (final Object overlay : videoInfo.getArray("thumbnailOverlays")) {
|
||||
final String style = ((JsonObject) overlay)
|
||||
.getObject("thumbnailOverlayTimeStatusRenderer")
|
||||
.getString("style", EMPTY_STRING);
|
||||
.getString("style", "");
|
||||
if (style.equalsIgnoreCase("LIVE")) {
|
||||
cachedStreamType = StreamType.LIVE_STREAM;
|
||||
return cachedStreamType;
|
||||
|
@ -287,7 +286,7 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor {
|
|||
final JsonArray badges = videoInfo.getArray("badges");
|
||||
for (final Object badge : badges) {
|
||||
if (((JsonObject) badge).getObject("metadataBadgeRenderer")
|
||||
.getString("label", EMPTY_STRING).equals("Premium")) {
|
||||
.getString("label", "").equals("Premium")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,12 @@ package org.schabi.newpipe.extractor.stream;
|
|||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
|
||||
|
||||
public class Description implements Serializable {
|
||||
|
||||
public static final int HTML = 1;
|
||||
public static final int MARKDOWN = 2;
|
||||
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 int type;
|
||||
|
|
|
@ -3,12 +3,10 @@ package org.schabi.newpipe.extractor.stream;
|
|||
import org.schabi.newpipe.extractor.MediaFormat;
|
||||
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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 {
|
||||
private final MediaFormat format;
|
||||
|
@ -198,7 +196,7 @@ public final class SubtitlesStream extends Stream {
|
|||
|
||||
if (id == null) {
|
||||
id = languageCode + (mediaFormat != null ? "." + mediaFormat.suffix
|
||||
: EMPTY_STRING);
|
||||
: "");
|
||||
}
|
||||
|
||||
return new SubtitlesStream(id, content, isUrl, mediaFormat, deliveryMethod,
|
||||
|
|
|
@ -25,7 +25,6 @@ public final class Utils {
|
|||
*/
|
||||
@Deprecated
|
||||
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 WWW_PATTERN = Pattern.compile("(https?)?://www\\.");
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
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.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.MUSIC_SONGS;
|
||||
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.utils.Utils.EMPTY_STRING;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
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=%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=hans", YouTube.getSearchQHFactory().fromQuery("hans", 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}), 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}), 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}), 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}), "").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}), "").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
|
||||
public void testGetContentFilter() throws Exception {
|
||||
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()
|
||||
.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()
|
||||
.fromQuery("asdf", asList(new String[]{MUSIC_SONGS}), EMPTY_STRING).getContentFilters().get(0));
|
||||
.fromQuery("asdf", asList(new String[]{MUSIC_SONGS}), "").getContentFilters().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithContentfilter() throws Exception {
|
||||
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()
|
||||
.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()
|
||||
.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()
|
||||
.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()
|
||||
.fromQuery("asdf", asList(new String[]{MUSIC_SONGS}), EMPTY_STRING).getUrl());
|
||||
.fromQuery("asdf", asList(new String[]{MUSIC_SONGS}), "").getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -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.assertThrows;
|
||||
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.Disabled;
|
||||
|
@ -409,7 +408,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
|||
@Override public long expectedDislikeCountAtLeast() { return -1; }
|
||||
@Override public List<MetaInfo> expectedMetaInfo() throws MalformedURLException {
|
||||
return Collections.singletonList(new MetaInfo(
|
||||
EMPTY_STRING,
|
||||
"",
|
||||
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("Wikipedia (German)")
|
||||
|
|
Loading…
Reference in a new issue