Replace avatar and thumbnail URLs attributes and methods to List<Image> in InfoItems

This commit is contained in:
AudricV 2022-07-20 23:28:06 +02:00
parent 78ce65769f
commit 2f3ee8a3f2
No known key found for this signature in database
GPG Key ID: DA92EC7905614198
3 changed files with 45 additions and 32 deletions

View File

@ -1,33 +1,36 @@
package org.schabi.newpipe.extractor;
/* /*
* Created by Christian Schabesberger on 11.02.17. * Created by Christian Schabesberger on 11.02.17.
* *
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org> * Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>. * along with NewPipe Extractor. If not, see <https://www.gnu.org/licenses/>.
*/ */
package org.schabi.newpipe.extractor;
import javax.annotation.Nonnull;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
public abstract class InfoItem implements Serializable { public abstract class InfoItem implements Serializable {
private final InfoType infoType; private final InfoType infoType;
private final int serviceId; private final int serviceId;
private final String url; private final String url;
private final String name; private final String name;
private String thumbnailUrl; @Nonnull
private List<Image> thumbnails = List.of();
public InfoItem(final InfoType infoType, public InfoItem(final InfoType infoType,
final int serviceId, final int serviceId,
@ -55,12 +58,13 @@ public abstract class InfoItem implements Serializable {
return name; return name;
} }
public void setThumbnailUrl(final String thumbnailUrl) { public void setThumbnails(@Nonnull final List<Image> thumbnails) {
this.thumbnailUrl = thumbnailUrl; this.thumbnails = thumbnails;
} }
public String getThumbnailUrl() { @Nonnull
return thumbnailUrl; public List<Image> getThumbnails() {
return thumbnails;
} }
@Override @Override

View File

@ -1,18 +1,22 @@
package org.schabi.newpipe.extractor.comments; package org.schabi.newpipe.extractor.comments;
import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.Page; import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.localization.DateWrapper; import org.schabi.newpipe.extractor.localization.DateWrapper;
import org.schabi.newpipe.extractor.stream.Description; import org.schabi.newpipe.extractor.stream.Description;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List;
public class CommentsInfoItem extends InfoItem { public class CommentsInfoItem extends InfoItem {
private String commentId; private String commentId;
private Description commentText; private Description commentText;
private String uploaderName; private String uploaderName;
private String uploaderAvatarUrl; @Nonnull
private List<Image> uploaderAvatars = List.of();
private String uploaderUrl; private String uploaderUrl;
private boolean uploaderVerified; private boolean uploaderVerified;
private String textualUploadDate; private String textualUploadDate;
@ -60,12 +64,13 @@ public class CommentsInfoItem extends InfoItem {
this.uploaderName = uploaderName; this.uploaderName = uploaderName;
} }
public String getUploaderAvatarUrl() { @Nonnull
return uploaderAvatarUrl; public List<Image> getUploaderAvatars() {
return uploaderAvatars;
} }
public void setUploaderAvatarUrl(final String uploaderAvatarUrl) { public void setUploaderAvatars(@Nonnull final List<Image> uploaderAvatars) {
this.uploaderAvatarUrl = uploaderAvatarUrl; this.uploaderAvatars = uploaderAvatars;
} }
public String getUploaderUrl() { public String getUploaderUrl() {
@ -94,8 +99,8 @@ public class CommentsInfoItem extends InfoItem {
} }
/** /**
* @return the comment's like count * @return the comment's like count or {@link CommentsInfoItem#NO_LIKE_COUNT} if it is
* or {@link CommentsInfoItem#NO_LIKE_COUNT} if it is unavailable * unavailable
*/ */
public int getLikeCount() { public int getLikeCount() {
return likeCount; return likeCount;

View File

@ -1,32 +1,35 @@
package org.schabi.newpipe.extractor.stream;
/* /*
* Created by Christian Schabesberger on 26.08.15. * Created by Christian Schabesberger on 26.08.15.
* *
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org> * Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>. * along with NewPipe Extractor. If not, see <https://www.gnu.org/licenses/>.
*/ */
package org.schabi.newpipe.extractor.stream;
import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.localization.DateWrapper; import org.schabi.newpipe.extractor.localization.DateWrapper;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; 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 { public class StreamInfoItem extends InfoItem {
private final StreamType streamType; private final StreamType streamType;
@ -40,7 +43,8 @@ public class StreamInfoItem extends InfoItem {
private long duration = -1; private long duration = -1;
private String uploaderUrl = null; private String uploaderUrl = null;
private String uploaderAvatarUrl = null; @Nonnull
private List<Image> uploaderAvatars = List.of();
private boolean uploaderVerified = false; private boolean uploaderVerified = false;
private boolean shortFormContent = false; private boolean shortFormContent = false;
@ -88,13 +92,13 @@ public class StreamInfoItem extends InfoItem {
this.uploaderUrl = uploaderUrl; this.uploaderUrl = uploaderUrl;
} }
@Nullable @Nonnull
public String getUploaderAvatarUrl() { public List<Image> getUploaderAvatars() {
return uploaderAvatarUrl; return uploaderAvatars;
} }
public void setUploaderAvatarUrl(final String uploaderAvatarUrl) { public void setUploaderAvatars(@Nonnull final List<Image> uploaderAvatars) {
this.uploaderAvatarUrl = uploaderAvatarUrl; this.uploaderAvatars = uploaderAvatars;
} }
public String getShortDescription() { public String getShortDescription() {
@ -152,7 +156,7 @@ public class StreamInfoItem extends InfoItem {
+ ", serviceId=" + getServiceId() + ", serviceId=" + getServiceId()
+ ", url='" + getUrl() + '\'' + ", url='" + getUrl() + '\''
+ ", name='" + getName() + '\'' + ", name='" + getName() + '\''
+ ", thumbnailUrl='" + getThumbnailUrl() + '\'' + ", thumbnails='" + getThumbnails() + '\''
+ ", uploaderVerified='" + isUploaderVerified() + '\'' + ", uploaderVerified='" + isUploaderVerified() + '\''
+ '}'; + '}';
} }