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

This commit is contained in:
AudricV 2022-07-21 00:17:45 +02:00
parent 0f4a5a8184
commit 9d8098576e
No known key found for this signature in database
GPG Key ID: DA92EC7905614198
3 changed files with 72 additions and 52 deletions

View File

@ -1,6 +1,27 @@
/*
* Created by Christian Schabesberger on 25.07.16.
*
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
* ChannelExtractor.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 <https://www.gnu.org/licenses/>.
*/
package org.schabi.newpipe.extractor.channel; package org.schabi.newpipe.extractor.channel;
import org.schabi.newpipe.extractor.Extractor; import org.schabi.newpipe.extractor.Extractor;
import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
@ -8,26 +29,6 @@ import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
/*
* Created by Christian Schabesberger on 25.07.16.
*
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
* ChannelExtractor.java is part of NewPipe.
*
* NewPipe 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,
* 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 <http://www.gnu.org/licenses/>.
*/
public abstract class ChannelExtractor extends Extractor { public abstract class ChannelExtractor extends Extractor {
public static final long UNKNOWN_SUBSCRIBER_COUNT = -1; public static final long UNKNOWN_SUBSCRIBER_COUNT = -1;
@ -36,14 +37,17 @@ public abstract class ChannelExtractor extends Extractor {
super(service, linkHandler); super(service, linkHandler);
} }
public abstract String getAvatarUrl() throws ParsingException; @Nonnull
public abstract String getBannerUrl() throws ParsingException; public abstract List<Image> getAvatars() throws ParsingException;
@Nonnull
public abstract List<Image> getBanners() throws ParsingException;
public abstract String getFeedUrl() throws ParsingException; public abstract String getFeedUrl() throws ParsingException;
public abstract long getSubscriberCount() throws ParsingException; public abstract long getSubscriberCount() throws ParsingException;
public abstract String getDescription() throws ParsingException; public abstract String getDescription() throws ParsingException;
public abstract String getParentChannelName() throws ParsingException; public abstract String getParentChannelName() throws ParsingException;
public abstract String getParentChannelUrl() throws ParsingException; public abstract String getParentChannelUrl() throws ParsingException;
public abstract String getParentChannelAvatarUrl() throws ParsingException; @Nonnull
public abstract List<Image> getParentChannelAvatars() throws ParsingException;
public abstract boolean isVerified() throws ParsingException; public abstract boolean isVerified() throws ParsingException;
@Nonnull @Nonnull
public abstract List<ListLinkHandler> getTabs() throws ParsingException; public abstract List<ListLinkHandler> getTabs() throws ParsingException;

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.playlist; package org.schabi.newpipe.extractor.playlist;
import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
@ -9,6 +10,9 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> { public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
public PlaylistExtractor(final StreamingService service, final ListLinkHandler linkHandler) { public PlaylistExtractor(final StreamingService service, final ListLinkHandler linkHandler) {
@ -17,7 +21,8 @@ public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
public abstract String getUploaderUrl() throws ParsingException; public abstract String getUploaderUrl() throws ParsingException;
public abstract String getUploaderName() throws ParsingException; public abstract String getUploaderName() throws ParsingException;
public abstract String getUploaderAvatarUrl() throws ParsingException; @Nonnull
public abstract List<Image> getUploaderAvatars() throws ParsingException;
public abstract boolean isUploaderVerified() throws ParsingException; public abstract boolean isUploaderVerified() throws ParsingException;
public abstract long getStreamCount() throws ParsingException; public abstract long getStreamCount() throws ParsingException;
@ -26,15 +31,13 @@ public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
public abstract Description getDescription() throws ParsingException; public abstract Description getDescription() throws ParsingException;
@Nonnull @Nonnull
public String getThumbnailUrl() throws ParsingException { public List<Image> getThumbnails() throws ParsingException {
return ""; return Collections.emptyList();
} }
@Nonnull @Nonnull
public String getBannerUrl() throws ParsingException { public List<Image> getBanners() throws ParsingException {
// Banner can't be handled by frontend right now. return List.of();
// Whoever is willing to implement this should also implement it in the frontend.
return "";
} }
@Nonnull @Nonnull
@ -48,8 +51,8 @@ public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
} }
@Nonnull @Nonnull
public String getSubChannelAvatarUrl() throws ParsingException { public List<Image> getSubChannelAvatars() throws ParsingException {
return ""; return List.of();
} }
public PlaylistInfo.PlaylistType getPlaylistType() throws ParsingException { public PlaylistInfo.PlaylistType getPlaylistType() throws ParsingException {

View File

@ -1,25 +1,26 @@
package org.schabi.newpipe.extractor.stream;
/* /*
* Created by Christian Schabesberger on 10.08.18. * Created by Christian Schabesberger on 10.08.18.
* *
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org> * Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
* 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 * 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.InfoItemsCollector; import org.schabi.newpipe.extractor.InfoItemsCollector;
import org.schabi.newpipe.extractor.InfoItemExtractor; import org.schabi.newpipe.extractor.InfoItemExtractor;
@ -87,13 +88,12 @@ public abstract class StreamExtractor extends Extractor {
} }
/** /**
* This will return the url to the thumbnail of the stream. Try to return the medium resolution * This will return the thumbnails of the stream.
* here.
* *
* @return The url of the thumbnail. * @return the thumbnails of the stream
*/ */
@Nonnull @Nonnull
public abstract String getThumbnailUrl() throws ParsingException; public abstract List<Image> getThumbnails() throws ParsingException;
/** /**
* This is the stream description. * This is the stream description.
@ -208,14 +208,18 @@ public abstract class StreamExtractor extends Extractor {
} }
/** /**
* The url to the image file/profile picture/avatar of the creator/uploader of the stream. * The image files/profile pictures/avatars of the creator/uploader of the stream.
* If the url is not available you can return an empty String.
* *
* @return The url of the image file of the uploader or an empty String * <p>
* 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.
* </p>
*
* @return the avatars of the sub-channel of the stream or an empty list (default)
*/ */
@Nonnull @Nonnull
public String getUploaderAvatarUrl() throws ParsingException { public List<Image> getUploaderAvatars() throws ParsingException {
return ""; return List.of();
} }
/** /**
@ -243,14 +247,23 @@ public abstract class StreamExtractor extends Extractor {
} }
/** /**
* The url to the image file/profile picture/avatar of the sub-channel of the stream. * The avatars of the sub-channel of the stream.
* If the url is not available you can return an empty String.
* *
* @return The url of the image file of the sub-channel or an empty String * <p>
* 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.
* </p>
*
* <p>
* If the concept of sub-channels doesn't apply to the stream's service, keep the default
* implementation.
* </p>
*
* @return the avatars of the sub-channel of the stream or an empty list (default)
*/ */
@Nonnull @Nonnull
public String getSubChannelAvatarUrl() throws ParsingException { public List<Image> getSubChannelAvatars() throws ParsingException {
return ""; return List.of();
} }
/** /**