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] 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 cbcab0a50..3925911d7 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 abstract class InfoItem implements Serializable { 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 0752e9b74..1b679f2cf 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 class CommentsInfoItem extends InfoItem { 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 class CommentsInfoItem extends InfoItem { } /** - * @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 37adb475f..a478a6994 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 class StreamInfoItem extends InfoItem { 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 class StreamInfoItem extends InfoItem { + ", serviceId=" + getServiceId() + ", url='" + getUrl() + '\'' + ", name='" + getName() + '\'' - + ", thumbnailUrl='" + getThumbnailUrl() + '\'' + + ", thumbnails='" + getThumbnails() + '\'' + ", uploaderVerified='" + isUploaderVerified() + '\'' + '}'; }