From 9d3761a3717081e952c5e773f38b6ae42ea91e11 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sun, 6 Aug 2023 13:01:59 +0200 Subject: [PATCH] [YouTube] Directly use playlist collector in channel tabs wrapper Note that this introduces a "Raw use of parameterized class 'InfoItemsPage'" warning, but it can be ignored since the type missing would be , and StreamInfoItem extends InfoItem --- .../YoutubeChannelTabPlaylistExtractor.java | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelTabPlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelTabPlaylistExtractor.java index da50db631..26ccd6d94 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelTabPlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelTabPlaylistExtractor.java @@ -1,6 +1,7 @@ package org.schabi.newpipe.extractor.services.youtube.extractors; -import org.schabi.newpipe.extractor.InfoItem; +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; + import org.schabi.newpipe.extractor.Page; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor; @@ -12,14 +13,11 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubePlaylistLinkHandlerFactory; -import org.schabi.newpipe.extractor.stream.StreamInfoItem; -import javax.annotation.Nonnull; import java.io.IOException; -import java.util.ArrayList; import java.util.List; -import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; +import javax.annotation.Nonnull; /** * A {@link ChannelTabExtractor} for YouTube system playlists using a @@ -74,35 +72,19 @@ public class YoutubeChannelTabPlaylistExtractor extends ChannelTabExtractor { @Nonnull @Override - public InfoItemsPage getInitialPage() throws IOException, ExtractionException { + public InfoItemsPage getInitialPage() throws IOException, ExtractionException { if (!playlistExisting) { return InfoItemsPage.emptyPage(); } - - final InfoItemsPage playlistInitialPage = - playlistExtractorInstance.getInitialPage(); - - // We can't provide the playlist page as it is due to a type conflict, we need to wrap the - // page items and provide a new InfoItemsPage - final List infoItems = new ArrayList<>(playlistInitialPage.getItems()); - return new InfoItemsPage<>(infoItems, playlistInitialPage.getNextPage(), - playlistInitialPage.getErrors()); + return playlistExtractorInstance.getInitialPage(); } @Override - public InfoItemsPage getPage(final Page page) - throws IOException, ExtractionException { + public InfoItemsPage getPage(final Page page) throws IOException, ExtractionException { if (!playlistExisting) { return InfoItemsPage.emptyPage(); } - - final InfoItemsPage playlistPage = playlistExtractorInstance.getPage(page); - - // We can't provide the playlist page as it is due to a type conflict, we need to wrap the - // page items and provide a new InfoItemsPage - final List infoItems = new ArrayList<>(playlistPage.getItems()); - return new InfoItemsPage<>(infoItems, playlistPage.getNextPage(), - playlistPage.getErrors()); + return playlistExtractorInstance.getPage(page); } /**