From d85454186a9766c73c2937a349f1b4e1d16c5f3d Mon Sep 17 00:00:00 2001
From: AudricV <74829229+AudricV@users.noreply.github.com>
Date: Sat, 12 Aug 2023 22:56:25 +0200
Subject: [PATCH 01/35] Add an Image class to the extractor
Objects of this serializable class contains four properties: a URL (as a
string), a width, a height (represented as integers) and an estimated
resolution level, which can be constructed from a given height.
Possible resolution levels are:
- UNKNOWN: for unknown heights or heights <= 0;
- LOW: for heights > 0 & < 175;
- MEDIUM: for heights >= 175 & < 720;
- HIGH: for heights >= 720.
Getters of these properties are available and the constructor needs these four
properties.
---
.../org/schabi/newpipe/extractor/Image.java | 211 ++++++++++++++++++
1 file changed, 211 insertions(+)
create mode 100644 extractor/src/main/java/org/schabi/newpipe/extractor/Image.java
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/Image.java b/extractor/src/main/java/org/schabi/newpipe/extractor/Image.java
new file mode 100644
index 0000000000..e0d56e14ad
--- /dev/null
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/Image.java
@@ -0,0 +1,211 @@
+package org.schabi.newpipe.extractor;
+
+import javax.annotation.Nonnull;
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Class representing images in the extractor.
+ *
+ *
+ * An image has four properties: its URL, its height, its width and its estimated quality level.
+ *
+ *
+ *
+ * Depending of the services, the height, the width or both properties may be not known.
+ * Implementations must use the relevant unknown constants in this case
+ * ({@link #HEIGHT_UNKNOWN} and {@link #WIDTH_UNKNOWN}), to ensure properly the lack of knowledge
+ * of one or both of these properties to extractor clients.
+ *
+ *
+ *
+ * They should also respect the ranges defined in the estimated image resolution levels as much as
+ * possible, to ensure consistency to extractor clients.
+ *
+ */
+public final class Image implements Serializable {
+
+ /**
+ * Constant representing that the height of an {@link Image} is unknown.
+ */
+ public static final int HEIGHT_UNKNOWN = -1;
+
+ /**
+ * Constant representing that the width of an {@link Image} is unknown.
+ */
+ public static final int WIDTH_UNKNOWN = -1;
+
+ @Nonnull
+ private final String url;
+ private final int height;
+ private final int width;
+ @Nonnull
+ private final ResolutionLevel estimatedResolutionLevel;
+
+ /**
+ * Construct an {@link Image} instance.
+ *
+ * @param url the URL to the image, which should be not null or empty
+ * @param height the image's height
+ * @param width the image's width
+ * @param estimatedResolutionLevel the image's estimated resolution level, which must not be
+ * null
+ * @throws NullPointerException if {@code estimatedResolutionLevel} is null
+ */
+ public Image(@Nonnull final String url,
+ final int height,
+ final int width,
+ @Nonnull final ResolutionLevel estimatedResolutionLevel)
+ throws NullPointerException {
+ this.url = url;
+ this.height = height;
+ this.width = width;
+ this.estimatedResolutionLevel = Objects.requireNonNull(
+ estimatedResolutionLevel, "estimatedResolutionLevel is null");
+ }
+
+ /**
+ * Get the URL of this {@link Image}.
+ *
+ * @return the {@link Image}'s URL.
+ */
+ @Nonnull
+ public String getUrl() {
+ return url;
+ }
+
+ /**
+ * Get the height of this {@link Image}.
+ *
+ *
+ * If it is unknown, {@link #HEIGHT_UNKNOWN} is returned instead.
+ *
+ *
+ * @return the {@link Image}'s height or {@link #HEIGHT_UNKNOWN}
+ */
+ public int getHeight() {
+ return height;
+ }
+
+ /**
+ * Get the width of this {@link Image}.
+ *
+ *
+ * If it is unknown, {@link #WIDTH_UNKNOWN} is returned instead.
+ *
+ *
+ * @return the {@link Image}'s width or {@link #WIDTH_UNKNOWN}
+ */
+ public int getWidth() {
+ return width;
+ }
+
+ /**
+ * Get the estimated resolution level of this image.
+ *
+ *
+ * If it is unknown, {@link ResolutionLevel#UNKNOWN} is returned instead.
+ *
+ *
+ * @return the estimated resolution level, which is never {@code null}
+ * @see ResolutionLevel
+ */
+ @Nonnull
+ public ResolutionLevel getEstimatedResolutionLevel() {
+ return estimatedResolutionLevel;
+ }
+
+ /**
+ * Get a string representation of this {@link Image} instance.
+ *
+ *
+ * The representation will be in the following format, where {@code url}, {@code height},
+ * {@code width} and {@code estimatedResolutionLevel} represent the corresponding properties:
+ *
+ *
+ * {@code Image {url=url, height='height, width=width,
+ * estimatedResolutionLevel=estimatedResolutionLevel}'}
+ *
+ *
+ * @return a string representation of this {@link Image} instance
+ */
+ @Nonnull
+ @Override
+ public String toString() {
+ return "Image {" + "url=" + url + ", height=" + height + ", width=" + width
+ + ", estimatedResolutionLevel=" + estimatedResolutionLevel + "}";
+ }
+
+ /**
+ * The estimated resolution level of an {@link Image}.
+ *
+ *
+ * Some services don't return the size of their images, but we may know for a specific image
+ * type that a service returns, according to real data, an approximation of the resolution
+ * level.
+ *
+ */
+ public enum ResolutionLevel {
+
+ /**
+ * The high resolution level.
+ *
+ *
+ * This level applies to images with a height greater than or equal to 720px.
+ *
+ */
+ HIGH,
+
+ /**
+ * The medium resolution level.
+ *
+ *
+ * This level applies to images with a height between 175px inclusive and 720px exclusive.
+ *
+ */
+ MEDIUM,
+
+ /**
+ * The low resolution level.
+ *
+ *
+ * This level applies to images with a height between 1px inclusive and 175px exclusive.
+ *
+ */
+ LOW,
+
+ /**
+ * The unknown resolution level.
+ *
+ *
+ * This value is returned when the extractor doesn't know what resolution level an image
+ * could have, for example if the extractor loops in an array of images with different
+ * resolution levels without knowing the height.
+ *
+ */
+ UNKNOWN;
+
+ /**
+ * Get a {@link ResolutionLevel} based from the given height.
+ *
+ * @param heightPx the height from which returning the good {@link ResolutionLevel}
+ * @return the {@link ResolutionLevel} corresponding to the height provided. See the
+ * {@link ResolutionLevel} values for details about what value is returned.
+ */
+ public static ResolutionLevel fromHeight(final int heightPx) {
+ if (heightPx <= 0) {
+ return UNKNOWN;
+ }
+
+ if (heightPx < 175) {
+ return LOW;
+ }
+
+ if (heightPx < 720) {
+ return MEDIUM;
+ }
+
+ return HIGH;
+ }
+ }
+}
From 78ce65769fe39bcdba7f9532b8f240ca2e8b4837 Mon Sep 17 00:00:00 2001
From: AudricV <74829229+AudricV@users.noreply.github.com>
Date: Sat, 12 Aug 2023 22:56:25 +0200
Subject: [PATCH 02/35] Add an ImageSuffix class to the extractor
The goal of this utility class is to simply store suffixes which need to be
appended to image URLs, in order to get images at the suffix resolution.
This class contains four properties: the suffix (as a string), the height,
the width (as integers) and the estimated resolution level of the image
corresponding to the one represented by the suffix.
---
.../newpipe/extractor/utils/ImageSuffix.java | 104 ++++++++++++++++++
1 file changed, 104 insertions(+)
create mode 100644 extractor/src/main/java/org/schabi/newpipe/extractor/utils/ImageSuffix.java
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/utils/ImageSuffix.java b/extractor/src/main/java/org/schabi/newpipe/extractor/utils/ImageSuffix.java
new file mode 100644
index 0000000000..d1ba7359c9
--- /dev/null
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/utils/ImageSuffix.java
@@ -0,0 +1,104 @@
+package org.schabi.newpipe.extractor.utils;
+
+import org.schabi.newpipe.extractor.Image.ResolutionLevel;
+
+import javax.annotation.Nonnull;
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Serializable class representing a suffix (including its format extension, such as {@code .jpg})
+ * which needs to be added to get an image/thumbnail URL with its corresponding height, width and
+ * estimated resolution level.
+ *
+ *
+ * This class is used to construct {@link org.schabi.newpipe.extractor.Image Image}
+ * instances from a single base URL/path, in order to get all or most image resolutions provided,
+ * depending of the service and the resolutions provided.
+ *
+ *
+ *
+ * Note that this class is not intended to be used externally and so should only be used when
+ * interfacing with the extractor.
+ *
+ */
+public final class ImageSuffix implements Serializable {
+ @Nonnull
+ private final String suffix;
+ private final int height;
+ private final int width;
+ @Nonnull
+ private final ResolutionLevel resolutionLevel;
+
+ /**
+ * Create a new {@link ImageSuffix} instance.
+ *
+ * @param suffix the suffix string
+ * @param height the height corresponding to the image suffix
+ * @param width the width corresponding to the image suffix
+ * @param estimatedResolutionLevel the {@link ResolutionLevel} of the image suffix, which must
+ * not be null
+ * @throws NullPointerException if {@code estimatedResolutionLevel} is {@code null}
+ */
+ public ImageSuffix(@Nonnull final String suffix,
+ final int height,
+ final int width,
+ @Nonnull final ResolutionLevel estimatedResolutionLevel)
+ throws NullPointerException {
+ this.suffix = suffix;
+ this.height = height;
+ this.width = width;
+ this.resolutionLevel = Objects.requireNonNull(estimatedResolutionLevel,
+ "estimatedResolutionLevel is null");
+ }
+
+ /**
+ * @return the suffix which needs to be appended to get the full image URL
+ */
+ @Nonnull
+ public String getSuffix() {
+ return suffix;
+ }
+
+ /**
+ * @return the height corresponding to the image suffix, which may be unknown
+ */
+ public int getHeight() {
+ return height;
+ }
+
+ /**
+ * @return the width corresponding to the image suffix, which may be unknown
+ */
+ public int getWidth() {
+ return width;
+ }
+
+ /**
+ * @return the estimated {@link ResolutionLevel} of the suffix, which is never null.
+ */
+ @Nonnull
+ public ResolutionLevel getResolutionLevel() {
+ return resolutionLevel;
+ }
+
+ /**
+ * Get a string representation of this {@link ImageSuffix} instance.
+ *
+ *
+ * The representation will be in the following format, where {@code suffix}, {@code height},
+ * {@code width} and {@code resolutionLevel} represent the corresponding properties:
+ *
+ *
+ * {@code ImageSuffix {url=url, height=height, width=width, resolutionLevel=resolutionLevel}'}
+ *
+ *
+ * @return a string representation of this {@link ImageSuffix} instance
+ */
+ @Nonnull
+ @Override
+ public String toString() {
+ return "ImageSuffix {" + "suffix=" + suffix + ", height=" + height + ", width="
+ + width + ", resolutionLevel=" + resolutionLevel + "}";
+ }
+}
From 2f3ee8a3f2adf1cfd0f99542054c5becb8fa9d98 Mon Sep 17 00:00:00 2001
From: AudricV <74829229+AudricV@users.noreply.github.com>
Date: Wed, 20 Jul 2022 23:28:06 +0200
Subject: [PATCH 03/35] Replace avatar and thumbnail URLs attributes and
methods to List in InfoItems
---
.../schabi/newpipe/extractor/InfoItem.java | 26 ++++++++-------
.../extractor/comments/CommentsInfoItem.java | 19 +++++++----
.../extractor/stream/StreamInfoItem.java | 32 +++++++++++--------
3 files changed, 45 insertions(+), 32 deletions(-)
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItem.java b/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItem.java
index cbcab0a50c..3925911d73 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItem.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItem.java
@@ -1,33 +1,36 @@
-package org.schabi.newpipe.extractor;
-
/*
* Created by Christian Schabesberger on 11.02.17.
*
* Copyright (C) Christian Schabesberger 2017
- * InfoItem.java is part of NewPipe.
+ * InfoItem.java is part of NewPipe Extractor.
*
- * NewPipe is free software: you can redistribute it and/or modify
+ * NewPipe Extractor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * NewPipe is distributed in the hope that it will be useful,
+ * NewPipe Extractor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with NewPipe. If not, see .
+ * along with NewPipe Extractor. If not, see .
*/
+package org.schabi.newpipe.extractor;
+
+import javax.annotation.Nonnull;
import java.io.Serializable;
+import java.util.List;
public abstract class InfoItem implements Serializable {
private final InfoType infoType;
private final int serviceId;
private final String url;
private final String name;
- private String thumbnailUrl;
+ @Nonnull
+ private List thumbnails = List.of();
public InfoItem(final InfoType infoType,
final int serviceId,
@@ -55,12 +58,13 @@ public String getName() {
return name;
}
- public void setThumbnailUrl(final String thumbnailUrl) {
- this.thumbnailUrl = thumbnailUrl;
+ public void setThumbnails(@Nonnull final List thumbnails) {
+ this.thumbnails = thumbnails;
}
- public String getThumbnailUrl() {
- return thumbnailUrl;
+ @Nonnull
+ public List getThumbnails() {
+ return thumbnails;
}
@Override
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java
index 0752e9b745..1b679f2cf2 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java
@@ -1,18 +1,22 @@
package org.schabi.newpipe.extractor.comments;
+import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.localization.DateWrapper;
import org.schabi.newpipe.extractor.stream.Description;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import java.util.List;
public class CommentsInfoItem extends InfoItem {
private String commentId;
private Description commentText;
private String uploaderName;
- private String uploaderAvatarUrl;
+ @Nonnull
+ private List uploaderAvatars = List.of();
private String uploaderUrl;
private boolean uploaderVerified;
private String textualUploadDate;
@@ -60,12 +64,13 @@ public void setUploaderName(final String uploaderName) {
this.uploaderName = uploaderName;
}
- public String getUploaderAvatarUrl() {
- return uploaderAvatarUrl;
+ @Nonnull
+ public List getUploaderAvatars() {
+ return uploaderAvatars;
}
- public void setUploaderAvatarUrl(final String uploaderAvatarUrl) {
- this.uploaderAvatarUrl = uploaderAvatarUrl;
+ public void setUploaderAvatars(@Nonnull final List uploaderAvatars) {
+ this.uploaderAvatars = uploaderAvatars;
}
public String getUploaderUrl() {
@@ -94,8 +99,8 @@ public void setUploadDate(@Nullable final DateWrapper uploadDate) {
}
/**
- * @return the comment's like count
- * or {@link CommentsInfoItem#NO_LIKE_COUNT} if it is unavailable
+ * @return the comment's like count or {@link CommentsInfoItem#NO_LIKE_COUNT} if it is
+ * unavailable
*/
public int getLikeCount() {
return likeCount;
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java
index 37adb475f4..a478a6994b 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java
@@ -1,32 +1,35 @@
-package org.schabi.newpipe.extractor.stream;
-
/*
* Created by Christian Schabesberger on 26.08.15.
*
* Copyright (C) Christian Schabesberger 2016
- * StreamInfoItem.java is part of NewPipe.
+ * StreamInfoItem.java is part of NewPipe Extractor.
*
- * NewPipe is free software: you can redistribute it and/or modify
+ * NewPipe Extractor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * NewPipe is distributed in the hope that it will be useful,
+ * NewPipe Extractor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with NewPipe. If not, see .
+ * along with NewPipe Extractor. If not, see .
*/
+package org.schabi.newpipe.extractor.stream;
+
+import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.localization.DateWrapper;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import java.util.List;
/**
- * Info object for previews of unopened videos, eg search results, related videos
+ * Info object for previews of unopened videos, e.g. search results, related videos.
*/
public class StreamInfoItem extends InfoItem {
private final StreamType streamType;
@@ -40,7 +43,8 @@ public class StreamInfoItem extends InfoItem {
private long duration = -1;
private String uploaderUrl = null;
- private String uploaderAvatarUrl = null;
+ @Nonnull
+ private List uploaderAvatars = List.of();
private boolean uploaderVerified = false;
private boolean shortFormContent = false;
@@ -88,13 +92,13 @@ public void setUploaderUrl(final String uploaderUrl) {
this.uploaderUrl = uploaderUrl;
}
- @Nullable
- public String getUploaderAvatarUrl() {
- return uploaderAvatarUrl;
+ @Nonnull
+ public List getUploaderAvatars() {
+ return uploaderAvatars;
}
- public void setUploaderAvatarUrl(final String uploaderAvatarUrl) {
- this.uploaderAvatarUrl = uploaderAvatarUrl;
+ public void setUploaderAvatars(@Nonnull final List uploaderAvatars) {
+ this.uploaderAvatars = uploaderAvatars;
}
public String getShortDescription() {
@@ -152,7 +156,7 @@ public String toString() {
+ ", serviceId=" + getServiceId()
+ ", url='" + getUrl() + '\''
+ ", name='" + getName() + '\''
- + ", thumbnailUrl='" + getThumbnailUrl() + '\''
+ + ", thumbnails='" + getThumbnails() + '\''
+ ", uploaderVerified='" + isUploaderVerified() + '\''
+ '}';
}
From ca1d4a6fa4e3c679dba514098c409a463d676af8 Mon Sep 17 00:00:00 2001
From: AudricV <74829229+AudricV@users.noreply.github.com>
Date: Wed, 20 Jul 2022 23:31:47 +0200
Subject: [PATCH 04/35] Replace avatar and thumbnail URLs attributes and
methods to List in InfoItemExtractors
---
.../newpipe/extractor/InfoItemExtractor.java | 6 +-
.../comments/CommentsInfoItemExtractor.java | 8 ++-
.../stream/StreamInfoItemExtractor.java | 55 ++++++++++---------
3 files changed, 41 insertions(+), 28 deletions(-)
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItemExtractor.java
index 0e38ceecda..ed59741764 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/InfoItemExtractor.java
@@ -2,8 +2,12 @@
import org.schabi.newpipe.extractor.exceptions.ParsingException;
+import javax.annotation.Nonnull;
+import java.util.List;
+
public interface InfoItemExtractor {
String getName() throws ParsingException;
String getUrl() throws ParsingException;
- String getThumbnailUrl() throws ParsingException;
+ @Nonnull
+ List getThumbnails() throws ParsingException;
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java
index 695478764f..dfff3bda4f 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java
@@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.comments;
+import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.InfoItemExtractor;
import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
@@ -8,7 +9,9 @@
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import java.util.List;
public interface CommentsInfoItemExtractor extends InfoItemExtractor {
@@ -77,8 +80,9 @@ default String getUploaderName() throws ParsingException {
return "";
}
- default String getUploaderAvatarUrl() throws ParsingException {
- return "";
+ @Nonnull
+ default List getUploaderAvatars() throws ParsingException {
+ return List.of();
}
/**
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java
index 77a633e2dc..62e69a4338 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java
@@ -1,39 +1,41 @@
-package org.schabi.newpipe.extractor.stream;
-
-import org.schabi.newpipe.extractor.InfoItemExtractor;
-import org.schabi.newpipe.extractor.exceptions.ParsingException;
-import org.schabi.newpipe.extractor.localization.DateWrapper;
-
-import javax.annotation.Nullable;
-
/*
* Created by Christian Schabesberger on 28.02.16.
*
* Copyright (C) Christian Schabesberger 2016
- * StreamInfoItemExtractor.java is part of NewPipe.
+ * StreamInfoItemExtractor.java is part of NewPipe Extractor.
*
- * NewPipe is free software: you can redistribute it and/or modify
+ * NewPipe Extractor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * NewPipe is distributed in the hope that it will be useful,
+ * NewPipe Extractor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with NewPipe. If not, see .
+ * along with NewPipe Extractor. If not, see .
*/
-public interface StreamInfoItemExtractor extends InfoItemExtractor {
+package org.schabi.newpipe.extractor.stream;
+import org.schabi.newpipe.extractor.Image;
+import org.schabi.newpipe.extractor.InfoItemExtractor;
+import org.schabi.newpipe.extractor.exceptions.ParsingException;
+import org.schabi.newpipe.extractor.localization.DateWrapper;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.List;
+
+public interface StreamInfoItemExtractor extends InfoItemExtractor {
/**
* Get the stream type
*
* @return the stream type
- * @throws ParsingException thrown if there is an error in the extraction
+ * @throws ParsingException if there is an error in the extraction
*/
StreamType getStreamType() throws ParsingException;
@@ -41,7 +43,7 @@ public interface StreamInfoItemExtractor extends InfoItemExtractor {
* Check if the stream is an ad.
*
* @return {@code true} if the stream is an ad.
- * @throws ParsingException thrown if there is an error in the extraction
+ * @throws ParsingException if there is an error in the extraction
*/
boolean isAd() throws ParsingException;
@@ -49,7 +51,7 @@ public interface StreamInfoItemExtractor extends InfoItemExtractor {
* Get the stream duration in seconds
*
* @return the stream duration in seconds
- * @throws ParsingException thrown if there is an error in the extraction
+ * @throws ParsingException if there is an error in the extraction
*/
long getDuration() throws ParsingException;
@@ -57,7 +59,7 @@ public interface StreamInfoItemExtractor extends InfoItemExtractor {
* Parses the number of views
*
* @return the number of views or -1 for live streams
- * @throws ParsingException thrown if there is an error in the extraction
+ * @throws ParsingException if there is an error in the extraction
*/
long getViewCount() throws ParsingException;
@@ -65,27 +67,29 @@ public interface StreamInfoItemExtractor extends InfoItemExtractor {
* Get the uploader name
*
* @return the uploader name
- * @throws ParsingException if parsing fails
+ * @throws ParsingException if there is an error in the extraction
*/
String getUploaderName() throws ParsingException;
String getUploaderUrl() throws ParsingException;
/**
- * Get the uploader's avatar
+ * Get the uploader avatars.
*
- * @return The uploader's avatar url or {@code null} if not provided by the service.
+ * @return the uploader avatars or an empty list if not provided by the service
* @throws ParsingException if there is an error in the extraction
*/
- @Nullable
- String getUploaderAvatarUrl() throws ParsingException;
+ @Nonnull
+ default List getUploaderAvatars() throws ParsingException {
+ return List.of();
+ }
/**
* Whether the uploader has been verified by the service's provider.
* If there is no verification implemented, return false
.
*
* @return whether the uploader has been verified by the service's provider
- * @throws ParsingException
+ * @throws ParsingException if there is an error in the extraction
*/
boolean isUploaderVerified() throws ParsingException;
@@ -109,8 +113,8 @@ public interface StreamInfoItemExtractor extends InfoItemExtractor {
*
*
* @return The date and time (can be approximated) this item was uploaded or {@code null}.
- * @throws ParsingException if there is an error in the extraction
- * or the extracted date couldn't be parsed.
+ * @throws ParsingException if there is an error in the extraction or the extracted date
+ * couldn't be parsed
* @see #getTextualUploadDate()
*/
@Nullable
@@ -137,6 +141,7 @@ default String getShortDescription() throws ParsingException {
*
*
* @return whether the stream is a short-form content
+ * @throws ParsingException if there is an error in the extraction
*/
default boolean isShortFormContent() throws ParsingException {
return false;
From 0f4a5a81841df6c03352a4c9778b36d808d779c0 Mon Sep 17 00:00:00 2001
From: AudricV <74829229+AudricV@users.noreply.github.com>
Date: Wed, 20 Jul 2022 23:36:27 +0200
Subject: [PATCH 05/35] Replace avatar and thumbnail URLs attributes and
methods to List in InfoItemsCollectors
---
.../channel/ChannelInfoItemsCollector.java | 20 ++++++------
.../comments/CommentsInfoItemsCollector.java | 4 +--
.../playlist/PlaylistInfoItemsCollector.java | 2 +-
.../stream/StreamInfoItemsCollector.java | 31 +++++++++----------
4 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java
index 5b085f8b86..5b8ff6918c 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java
@@ -1,28 +1,28 @@
-package org.schabi.newpipe.extractor.channel;
-
-import org.schabi.newpipe.extractor.InfoItemsCollector;
-import org.schabi.newpipe.extractor.exceptions.ParsingException;
-
/*
* Created by Christian Schabesberger on 12.02.17.
*
* Copyright (C) Christian Schabesberger 2017
- * ChannelInfoItemsCollector.java is part of NewPipe.
+ * ChannelInfoItemsCollector.java is part of NewPipe Extractor.
*
- * NewPipe is free software: you can redistribute it and/or modify
+ * NewPipe Extractor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * NewPipe is distributed in the hope that it will be useful,
+ * NewPipe Extractor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with NewPipe. If not, see .
+ * along with NewPipe Extractor. If not, see .
*/
+package org.schabi.newpipe.extractor.channel;
+
+import org.schabi.newpipe.extractor.InfoItemsCollector;
+import org.schabi.newpipe.extractor.exceptions.ParsingException;
+
public final class ChannelInfoItemsCollector
extends InfoItemsCollector {
public ChannelInfoItemsCollector(final int serviceId) {
@@ -47,7 +47,7 @@ public ChannelInfoItem extract(final ChannelInfoItemExtractor extractor)
addError(e);
}
try {
- resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
+ resultItem.setThumbnails(extractor.getThumbnails());
} catch (final Exception e) {
addError(e);
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java
index 3afeb04554..fca5bdf59b 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java
@@ -36,7 +36,7 @@ public CommentsInfoItem extract(final CommentsInfoItemExtractor extractor)
addError(e);
}
try {
- resultItem.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
+ resultItem.setUploaderAvatars(extractor.getUploaderAvatars());
} catch (final Exception e) {
addError(e);
}
@@ -66,7 +66,7 @@ public CommentsInfoItem extract(final CommentsInfoItemExtractor extractor)
addError(e);
}
try {
- resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
+ resultItem.setThumbnails(extractor.getThumbnails());
} catch (final Exception e) {
addError(e);
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java
index 4fe35e40e8..0b854a999f 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java
@@ -32,7 +32,7 @@ public PlaylistInfoItem extract(final PlaylistInfoItemExtractor extractor)
addError(e);
}
try {
- resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
+ resultItem.setThumbnails(extractor.getThumbnails());
} catch (final Exception e) {
addError(e);
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java
index 35cf7fd328..c0e1ac1e68 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemsCollector.java
@@ -1,31 +1,31 @@
-package org.schabi.newpipe.extractor.stream;
-
-import org.schabi.newpipe.extractor.InfoItemsCollector;
-import org.schabi.newpipe.extractor.exceptions.FoundAdException;
-import org.schabi.newpipe.extractor.exceptions.ParsingException;
-
-import java.util.Comparator;
-
/*
* Created by Christian Schabesberger on 28.02.16.
*
* Copyright (C) Christian Schabesberger 2016
- * StreamInfoItemsCollector.java is part of NewPipe.
+ * StreamInfoItemsCollector.java is part of NewPipe Extractor.
*
- * NewPipe is free software: you can redistribute it and/or modify
+ * NewPipe Extractor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * NewPipe is distributed in the hope that it will be useful,
+ * NewPipe Extractor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with NewPipe. If not, see .
+ * along with NewPipe Extractor. If not, see .
*/
+package org.schabi.newpipe.extractor.stream;
+
+import org.schabi.newpipe.extractor.InfoItemsCollector;
+import org.schabi.newpipe.extractor.exceptions.FoundAdException;
+import org.schabi.newpipe.extractor.exceptions.ParsingException;
+
+import java.util.Comparator;
+
public class StreamInfoItemsCollector
extends InfoItemsCollector {
@@ -74,7 +74,7 @@ public StreamInfoItem extract(final StreamInfoItemExtractor extractor) throws Pa
addError(e);
}
try {
- resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
+ resultItem.setThumbnails(extractor.getThumbnails());
} catch (final Exception e) {
addError(e);
}
@@ -84,7 +84,7 @@ public StreamInfoItem extract(final StreamInfoItemExtractor extractor) throws Pa
addError(e);
}
try {
- resultItem.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
+ resultItem.setUploaderAvatars(extractor.getUploaderAvatars());
} catch (final Exception e) {
addError(e);
}
@@ -111,8 +111,7 @@ public StreamInfoItem extract(final StreamInfoItemExtractor extractor) throws Pa
public void commit(final StreamInfoItemExtractor extractor) {
try {
addItem(extract(extractor));
- } catch (final FoundAdException ae) {
- //System.out.println("AD_WARNING: " + ae.getMessage());
+ } catch (final FoundAdException ignored) {
} catch (final Exception e) {
addError(e);
}
From 9d8098576ea3da32277cf417ff4e52acfeeb176a Mon Sep 17 00:00:00 2001
From: AudricV <74829229+AudricV@users.noreply.github.com>
Date: Thu, 21 Jul 2022 00:17:45 +0200
Subject: [PATCH 06/35] Replace avatar and thumbnail URLs attributes and
methods to List in Extractors
---
.../extractor/channel/ChannelExtractor.java | 38 +++++++------
.../extractor/playlist/PlaylistExtractor.java | 21 ++++----
.../extractor/stream/StreamExtractor.java | 53 ++++++++++++-------
3 files changed, 66 insertions(+), 46 deletions(-)
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java
index db0333647a..d5587ec4ed 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java
@@ -1,33 +1,34 @@
-package org.schabi.newpipe.extractor.channel;
-
-import org.schabi.newpipe.extractor.Extractor;
-import org.schabi.newpipe.extractor.StreamingService;
-import org.schabi.newpipe.extractor.exceptions.ParsingException;
-import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
-
-import javax.annotation.Nonnull;
-import java.util.List;
-
/*
* Created by Christian Schabesberger on 25.07.16.
*
* Copyright (C) Christian Schabesberger 2016
- * ChannelExtractor.java is part of NewPipe.
+ * ChannelExtractor.java is part of NewPipe Extractor.
*
- * NewPipe is free software: you can redistribute it and/or modify
+ * NewPipe Extractor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * NewPipe is distributed in the hope that it will be useful,
+ * NewPipe Extractor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with NewPipe. If not, see .
+ * along with NewPipe Extractor. If not, see .
*/
+package org.schabi.newpipe.extractor.channel;
+
+import org.schabi.newpipe.extractor.Extractor;
+import org.schabi.newpipe.extractor.Image;
+import org.schabi.newpipe.extractor.StreamingService;
+import org.schabi.newpipe.extractor.exceptions.ParsingException;
+import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
+
+import javax.annotation.Nonnull;
+import java.util.List;
+
public abstract class ChannelExtractor extends Extractor {
public static final long UNKNOWN_SUBSCRIBER_COUNT = -1;
@@ -36,14 +37,17 @@ protected ChannelExtractor(final StreamingService service, final ListLinkHandler
super(service, linkHandler);
}
- public abstract String getAvatarUrl() throws ParsingException;
- public abstract String getBannerUrl() throws ParsingException;
+ @Nonnull
+ public abstract List getAvatars() throws ParsingException;
+ @Nonnull
+ public abstract List getBanners() throws ParsingException;
public abstract String getFeedUrl() throws ParsingException;
public abstract long getSubscriberCount() throws ParsingException;
public abstract String getDescription() throws ParsingException;
public abstract String getParentChannelName() throws ParsingException;
public abstract String getParentChannelUrl() throws ParsingException;
- public abstract String getParentChannelAvatarUrl() throws ParsingException;
+ @Nonnull
+ public abstract List getParentChannelAvatars() throws ParsingException;
public abstract boolean isVerified() throws ParsingException;
@Nonnull
public abstract List getTabs() throws ParsingException;
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java
index bc4eee467c..a714deadb7 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java
@@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.playlist;
+import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
@@ -9,6 +10,9 @@
import javax.annotation.Nonnull;
+import java.util.Collections;
+import java.util.List;
+
public abstract class PlaylistExtractor extends ListExtractor {
public PlaylistExtractor(final StreamingService service, final ListLinkHandler linkHandler) {
@@ -17,7 +21,8 @@ public PlaylistExtractor(final StreamingService service, final ListLinkHandler l
public abstract String getUploaderUrl() throws ParsingException;
public abstract String getUploaderName() throws ParsingException;
- public abstract String getUploaderAvatarUrl() throws ParsingException;
+ @Nonnull
+ public abstract List getUploaderAvatars() throws ParsingException;
public abstract boolean isUploaderVerified() throws ParsingException;
public abstract long getStreamCount() throws ParsingException;
@@ -26,15 +31,13 @@ public PlaylistExtractor(final StreamingService service, final ListLinkHandler l
public abstract Description getDescription() throws ParsingException;
@Nonnull
- public String getThumbnailUrl() throws ParsingException {
- return "";
+ public List getThumbnails() throws ParsingException {
+ return Collections.emptyList();
}
@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 "";
+ public List getBanners() throws ParsingException {
+ return List.of();
}
@Nonnull
@@ -48,8 +51,8 @@ public String getSubChannelUrl() throws ParsingException {
}
@Nonnull
- public String getSubChannelAvatarUrl() throws ParsingException {
- return "";
+ public List getSubChannelAvatars() throws ParsingException {
+ return List.of();
}
public PlaylistInfo.PlaylistType getPlaylistType() throws ParsingException {
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java
index 6fbcf8fbb5..f974cade0e 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java
@@ -1,25 +1,26 @@
-package org.schabi.newpipe.extractor.stream;
-
/*
* Created by Christian Schabesberger on 10.08.18.
*
* Copyright (C) Christian Schabesberger 2016
- * StreamExtractor.java is part of NewPipe.
+ * StreamExtractor.java is part of NewPipe Extractor.
*
- * NewPipe is free software: you can redistribute it and/or modify
+ * NewPipe Extractor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * NewPipe is distributed in the hope that it will be useful,
+ * NewPipe Extractor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with NewPipe. If not, see .
+ * along with NewPipe Extractor. If not, see .
*/
+package org.schabi.newpipe.extractor.stream;
+
+import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.InfoItemsCollector;
import org.schabi.newpipe.extractor.InfoItemExtractor;
@@ -87,13 +88,12 @@ public DateWrapper getUploadDate() throws ParsingException {
}
/**
- * This will return the url to the thumbnail of the stream. Try to return the medium resolution
- * here.
+ * This will return the thumbnails of the stream.
*
- * @return The url of the thumbnail.
+ * @return the thumbnails of the stream
*/
@Nonnull
- public abstract String getThumbnailUrl() throws ParsingException;
+ public abstract List getThumbnails() throws ParsingException;
/**
* This is the stream description.
@@ -208,14 +208,18 @@ public long getUploaderSubscriberCount() throws ParsingException {
}
/**
- * The url to the image file/profile picture/avatar of the creator/uploader of the stream.
- * If the url is not available you can return an empty String.
+ * The image files/profile pictures/avatars of the creator/uploader of the stream.
*
- * @return The url of the image file of the uploader or an empty String
+ *
+ * If they are not available in the stream on specific cases, you must return an empty list for
+ * these ones, like it is made by default.
+ *
+ *
+ * @return the avatars of the sub-channel of the stream or an empty list (default)
*/
@Nonnull
- public String getUploaderAvatarUrl() throws ParsingException {
- return "";
+ public List getUploaderAvatars() throws ParsingException {
+ return List.of();
}
/**
@@ -243,14 +247,23 @@ public String getSubChannelName() throws ParsingException {
}
/**
- * The url to the image file/profile picture/avatar of the sub-channel of the stream.
- * If the url is not available you can return an empty String.
+ * The avatars of the sub-channel of the stream.
*
- * @return The url of the image file of the sub-channel or an empty String
+ *
+ * If they are not available in the stream on specific cases, you must return an empty list for
+ * these ones, like it is made by default.
+ *
+ *
+ *
+ * If the concept of sub-channels doesn't apply to the stream's service, keep the default
+ * implementation.
+ *
+ *
+ * @return the avatars of the sub-channel of the stream or an empty list (default)
*/
@Nonnull
- public String getSubChannelAvatarUrl() throws ParsingException {
- return "";
+ public List getSubChannelAvatars() throws ParsingException {
+ return List.of();
}
/**
From d56b880cae7393ed71f31deec770182352f8e412 Mon Sep 17 00:00:00 2001
From: AudricV <74829229+AudricV@users.noreply.github.com>
Date: Fri, 22 Jul 2022 15:22:14 +0200
Subject: [PATCH 07/35] Replace avatar and thumbnail URLs attributes and
methods to List in Infos
---
.../extractor/channel/ChannelInfo.java | 77 ++++++------
.../extractor/playlist/PlaylistInfo.java | 67 +++++-----
.../newpipe/extractor/stream/StreamInfo.java | 119 ++++++++----------
3 files changed, 133 insertions(+), 130 deletions(-)
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java
index 4c05de6920..502901e29c 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java
@@ -1,36 +1,37 @@
-package org.schabi.newpipe.extractor.channel;
-
-import org.schabi.newpipe.extractor.Info;
-import org.schabi.newpipe.extractor.NewPipe;
-import org.schabi.newpipe.extractor.StreamingService;
-import org.schabi.newpipe.extractor.exceptions.ExtractionException;
-import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
-
-import java.io.IOException;
-import java.util.List;
-
-import javax.annotation.Nonnull;
-
/*
* Created by Christian Schabesberger on 31.07.16.
*
* Copyright (C) Christian Schabesberger 2016
- * ChannelInfo.java is part of NewPipe.
+ * ChannelInfo.java is part of NewPipe Extractor.
*
- * NewPipe is free software: you can redistribute it and/or modify
+ * NewPipe Extractor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * NewPipe is distributed in the hope that it will be useful,
+ * NewPipe Extractor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with NewPipe. If not, see .
+ * along with NewPipe Extractor. If not, see .
*/
+package org.schabi.newpipe.extractor.channel;
+
+import org.schabi.newpipe.extractor.Info;
+import org.schabi.newpipe.extractor.Image;
+import org.schabi.newpipe.extractor.NewPipe;
+import org.schabi.newpipe.extractor.StreamingService;
+import org.schabi.newpipe.extractor.exceptions.ExtractionException;
+import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.annotation.Nonnull;
+
public class ChannelInfo extends Info {
public ChannelInfo(final int serviceId,
@@ -64,13 +65,13 @@ public static ChannelInfo getInfo(final ChannelExtractor extractor)
final ChannelInfo info = new ChannelInfo(serviceId, id, url, originalUrl, name);
try {
- info.setAvatarUrl(extractor.getAvatarUrl());
+ info.setAvatars(extractor.getAvatars());
} catch (final Exception e) {
info.addError(e);
}
try {
- info.setBannerUrl(extractor.getBannerUrl());
+ info.setBanners(extractor.getBanners());
} catch (final Exception e) {
info.addError(e);
}
@@ -106,7 +107,7 @@ public static ChannelInfo getInfo(final ChannelExtractor extractor)
}
try {
- info.setParentChannelAvatarUrl(extractor.getParentChannelAvatarUrl());
+ info.setParentChannelAvatars(extractor.getParentChannelAvatars());
} catch (final Exception e) {
info.addError(e);
}
@@ -132,15 +133,18 @@ public static ChannelInfo getInfo(final ChannelExtractor extractor)
return info;
}
- private String avatarUrl;
private String parentChannelName;
private String parentChannelUrl;
- private String parentChannelAvatarUrl;
- private String bannerUrl;
private String feedUrl;
private long subscriberCount = -1;
private String description;
private String[] donationLinks;
+ @Nonnull
+ private List avatars = List.of();
+ @Nonnull
+ private List banners = List.of();
+ @Nonnull
+ private List parentChannelAvatars = List.of();
private boolean verified;
private List tabs = List.of();
private List tags = List.of();
@@ -161,28 +165,31 @@ public void setParentChannelUrl(final String parentChannelUrl) {
this.parentChannelUrl = parentChannelUrl;
}
- public String getParentChannelAvatarUrl() {
- return parentChannelAvatarUrl;
+ @Nonnull
+ public List getParentChannelAvatars() {
+ return parentChannelAvatars;
}
- public void setParentChannelAvatarUrl(final String parentChannelAvatarUrl) {
- this.parentChannelAvatarUrl = parentChannelAvatarUrl;
+ public void setParentChannelAvatars(@Nonnull final List parentChannelAvatars) {
+ this.parentChannelAvatars = parentChannelAvatars;
}
- public String getAvatarUrl() {
- return avatarUrl;
+ @Nonnull
+ public List getAvatars() {
+ return avatars;
}
- public void setAvatarUrl(final String avatarUrl) {
- this.avatarUrl = avatarUrl;
+ public void setAvatars(@Nonnull final List avatars) {
+ this.avatars = avatars;
}
- public String getBannerUrl() {
- return bannerUrl;
+ @Nonnull
+ public List getBanners() {
+ return banners;
}
- public void setBannerUrl(final String bannerUrl) {
- this.bannerUrl = bannerUrl;
+ public void setBanners(@Nonnull final List banners) {
+ this.banners = banners;
}
public String getFeedUrl() {
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java
index 97a0d530d8..bb29ca7d0f 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java
@@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.playlist;
+import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
import org.schabi.newpipe.extractor.ListInfo;
import org.schabi.newpipe.extractor.NewPipe;
@@ -12,6 +13,7 @@
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
+import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -109,26 +111,23 @@ public static PlaylistInfo getInfo(final PlaylistExtractor extractor)
info.addError(e);
}
try {
- info.setThumbnailUrl(extractor.getThumbnailUrl());
+ info.setThumbnails(extractor.getThumbnails());
} catch (final Exception e) {
info.addError(e);
}
try {
info.setUploaderUrl(extractor.getUploaderUrl());
} catch (final Exception e) {
- info.setUploaderUrl("");
uploaderParsingErrors.add(e);
}
try {
info.setUploaderName(extractor.getUploaderName());
} catch (final Exception e) {
- info.setUploaderName("");
uploaderParsingErrors.add(e);
}
try {
- info.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
+ info.setUploaderAvatars(extractor.getUploaderAvatars());
} catch (final Exception e) {
- info.setUploaderAvatarUrl("");
uploaderParsingErrors.add(e);
}
try {
@@ -142,12 +141,12 @@ public static PlaylistInfo getInfo(final PlaylistExtractor extractor)
uploaderParsingErrors.add(e);
}
try {
- info.setSubChannelAvatarUrl(extractor.getSubChannelAvatarUrl());
+ info.setSubChannelAvatars(extractor.getSubChannelAvatars());
} catch (final Exception e) {
uploaderParsingErrors.add(e);
}
try {
- info.setBannerUrl(extractor.getBannerUrl());
+ info.setBanners(extractor.getBanners());
} catch (final Exception e) {
info.addError(e);
}
@@ -171,32 +170,38 @@ public static PlaylistInfo getInfo(final PlaylistExtractor extractor)
return info;
}
- private String thumbnailUrl;
- private String bannerUrl;
- private String uploaderUrl;
- private String uploaderName;
- private String uploaderAvatarUrl;
+ private String uploaderUrl = "";
+ private String uploaderName = "";
private String subChannelUrl;
private String subChannelName;
- private String subChannelAvatarUrl;
- private long streamCount = 0;
private Description description;
+ @Nonnull
+ private List banners = List.of();
+ @Nonnull
+ private List subChannelAvatars = List.of();
+ @Nonnull
+ private List thumbnails = List.of();
+ @Nonnull
+ private List uploaderAvatars = List.of();
+ private long streamCount;
private PlaylistType playlistType;
- public String getThumbnailUrl() {
- return thumbnailUrl;
+ @Nonnull
+ public List getThumbnails() {
+ return thumbnails;
}
- public void setThumbnailUrl(final String thumbnailUrl) {
- this.thumbnailUrl = thumbnailUrl;
+ public void setThumbnails(@Nonnull final List thumbnails) {
+ this.thumbnails = thumbnails;
}
- public String getBannerUrl() {
- return bannerUrl;
+ @Nonnull
+ public List getBanners() {
+ return banners;
}
- public void setBannerUrl(final String bannerUrl) {
- this.bannerUrl = bannerUrl;
+ public void setBanners(@Nonnull final List banners) {
+ this.banners = banners;
}
public String getUploaderUrl() {
@@ -215,12 +220,13 @@ public void setUploaderName(final String uploaderName) {
this.uploaderName = uploaderName;
}
- public String getUploaderAvatarUrl() {
- return uploaderAvatarUrl;
+ @Nonnull
+ public List getUploaderAvatars() {
+ return uploaderAvatars;
}
- public void setUploaderAvatarUrl(final String uploaderAvatarUrl) {
- this.uploaderAvatarUrl = uploaderAvatarUrl;
+ public void setUploaderAvatars(@Nonnull final List uploaderAvatars) {
+ this.uploaderAvatars = uploaderAvatars;
}
public String getSubChannelUrl() {
@@ -239,12 +245,13 @@ public void setSubChannelName(final String subChannelName) {
this.subChannelName = subChannelName;
}
- public String getSubChannelAvatarUrl() {
- return subChannelAvatarUrl;
+ @Nonnull
+ public List getSubChannelAvatars() {
+ return subChannelAvatars;
}
- public void setSubChannelAvatarUrl(final String subChannelAvatarUrl) {
- this.subChannelAvatarUrl = subChannelAvatarUrl;
+ public void setSubChannelAvatars(@Nonnull final List subChannelAvatars) {
+ this.subChannelAvatars = subChannelAvatars;
}
public long getStreamCount() {
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java
index fa979c34b2..252bc7f149 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java
@@ -1,5 +1,26 @@
+/*
+ * Created by Christian Schabesberger on 26.08.15.
+ *
+ * Copyright (C) Christian Schabesberger 2016
+ * StreamInfo.java is part of NewPipe Extractor.
+ *
+ * NewPipe Extractor is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * NewPipe Extractor is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with NewPipe Extractor. If not, see .
+ */
+
package org.schabi.newpipe.extractor.stream;
+import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.Info;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.MetaInfo;
@@ -12,8 +33,6 @@
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Locale;
@@ -21,26 +40,6 @@
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
-/*
- * Created by Christian Schabesberger on 26.08.15.
- *
- * Copyright (C) Christian Schabesberger 2016
- * StreamInfo.java is part of NewPipe Extractor.
- *
- * NewPipe Extractor is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * NewPipe Extractor is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with NewPipe Extractor. If not, see .
- */
-
/**
* Info object for opened contents, i.e. the content ready to play.
*/
@@ -106,9 +105,7 @@ private static StreamInfo extractImportantData(@Nonnull final StreamExtractor ex
// Important data, without it the content can't be displayed.
// If one of these is not available, the frontend will receive an exception directly.
- final int serviceId = extractor.getServiceId();
final String url = extractor.getUrl();
- final String originalUrl = extractor.getOriginalUrl();
final StreamType streamType = extractor.getStreamType();
final String id = extractor.getId();
final String name = extractor.getName();
@@ -148,7 +145,6 @@ private static void extractStreams(final StreamInfo streamInfo,
streamInfo.addError(new ExtractionException("Couldn't get HLS manifest", e));
}
- /* Load and extract audio */
try {
streamInfo.setAudioStreams(extractor.getAudioStreams());
} catch (final ContentNotSupportedException e) {
@@ -157,31 +153,18 @@ private static void extractStreams(final StreamInfo streamInfo,
streamInfo.addError(new ExtractionException("Couldn't get audio streams", e));
}
- /* Extract video stream url */
try {
streamInfo.setVideoStreams(extractor.getVideoStreams());
} catch (final Exception e) {
streamInfo.addError(new ExtractionException("Couldn't get video streams", e));
}
- /* Extract video only stream url */
try {
streamInfo.setVideoOnlyStreams(extractor.getVideoOnlyStreams());
} catch (final Exception e) {
streamInfo.addError(new ExtractionException("Couldn't get video only streams", e));
}
- // Lists can be null if an exception was thrown during extraction
- if (streamInfo.getVideoStreams() == null) {
- streamInfo.setVideoStreams(Collections.emptyList());
- }
- if (streamInfo.getVideoOnlyStreams() == null) {
- streamInfo.setVideoOnlyStreams(Collections.emptyList());
- }
- if (streamInfo.getAudioStreams() == null) {
- streamInfo.setAudioStreams(Collections.emptyList());
- }
-
// Either audio or video has to be available, otherwise we didn't get a stream (since
// videoOnly are optional, they don't count).
if ((streamInfo.videoStreams.isEmpty()) && (streamInfo.audioStreams.isEmpty())) {
@@ -199,7 +182,7 @@ private static void extractOptionalData(final StreamInfo streamInfo,
// so the frontend can afterwards check where errors happened.
try {
- streamInfo.setThumbnailUrl(extractor.getThumbnailUrl());
+ streamInfo.setThumbnails(extractor.getThumbnails());
} catch (final Exception e) {
streamInfo.addError(e);
}
@@ -219,7 +202,7 @@ private static void extractOptionalData(final StreamInfo streamInfo,
streamInfo.addError(e);
}
try {
- streamInfo.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
+ streamInfo.setUploaderAvatars(extractor.getUploaderAvatars());
} catch (final Exception e) {
streamInfo.addError(e);
}
@@ -245,7 +228,7 @@ private static void extractOptionalData(final StreamInfo streamInfo,
streamInfo.addError(e);
}
try {
- streamInfo.setSubChannelAvatarUrl(extractor.getSubChannelAvatarUrl());
+ streamInfo.setSubChannelAvatars(extractor.getSubChannelAvatars());
} catch (final Exception e) {
streamInfo.addError(e);
}
@@ -353,7 +336,8 @@ private static void extractOptionalData(final StreamInfo streamInfo,
}
private StreamType streamType;
- private String thumbnailUrl = "";
+ @Nonnull
+ private List thumbnails = List.of();
private String textualUploadDate;
private DateWrapper uploadDate;
private long duration = -1;
@@ -366,24 +350,26 @@ private static void extractOptionalData(final StreamInfo streamInfo,
private String uploaderName = "";
private String uploaderUrl = "";
- private String uploaderAvatarUrl = "";
+ @Nonnull
+ private List uploaderAvatars = List.of();
private boolean uploaderVerified = false;
private long uploaderSubscriberCount = -1;
private String subChannelName = "";
private String subChannelUrl = "";
- private String subChannelAvatarUrl = "";
+ @Nonnull
+ private List subChannelAvatars = List.of();
- private List videoStreams = new ArrayList<>();
- private List audioStreams = new ArrayList<>();
- private List videoOnlyStreams = new ArrayList<>();
+ private List videoStreams = List.of();
+ private List audioStreams = List.of();
+ private List videoOnlyStreams = List.of();
private String dashMpdUrl = "";
private String hlsUrl = "";
- private List relatedItems = new ArrayList<>();
+ private List relatedItems = List.of();
private long startPosition = 0;
- private List subtitles = new ArrayList<>();
+ private List subtitles = List.of();
private String host = "";
private StreamExtractor.Privacy privacy;
@@ -391,15 +377,15 @@ private static void extractOptionalData(final StreamInfo streamInfo,
private String licence = "";
private String supportInfo = "";
private Locale language = null;
- private List tags = new ArrayList<>();
- private List streamSegments = new ArrayList<>();
- private List metaInfo = new ArrayList<>();
+ private List tags = List.of();
+ private List streamSegments = List.of();
+ private List metaInfo = List.of();
private boolean shortFormContent = false;
/**
* Preview frames, e.g. for the storyboard / seekbar thumbnail preview
*/
- private List