Skip to content

Commit 9d3761a

Browse files
committed
[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 <InfoItem>, and StreamInfoItem extends InfoItem
1 parent e34b4f1 commit 9d3761a

1 file changed

Lines changed: 7 additions & 25 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelTabPlaylistExtractor.java

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.schabi.newpipe.extractor.services.youtube.extractors;
22

3-
import org.schabi.newpipe.extractor.InfoItem;
3+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
4+
45
import org.schabi.newpipe.extractor.Page;
56
import org.schabi.newpipe.extractor.StreamingService;
67
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor;
@@ -12,14 +13,11 @@
1213
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
1314
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
1415
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubePlaylistLinkHandlerFactory;
15-
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
1616

17-
import javax.annotation.Nonnull;
1817
import java.io.IOException;
19-
import java.util.ArrayList;
2018
import java.util.List;
2119

22-
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
20+
import javax.annotation.Nonnull;
2321

2422
/**
2523
* A {@link ChannelTabExtractor} for YouTube system playlists using a
@@ -74,35 +72,19 @@ public void onFetchPage(@Nonnull final Downloader downloader)
7472

7573
@Nonnull
7674
@Override
77-
public InfoItemsPage<InfoItem> getInitialPage() throws IOException, ExtractionException {
75+
public InfoItemsPage getInitialPage() throws IOException, ExtractionException {
7876
if (!playlistExisting) {
7977
return InfoItemsPage.emptyPage();
8078
}
81-
82-
final InfoItemsPage<StreamInfoItem> playlistInitialPage =
83-
playlistExtractorInstance.getInitialPage();
84-
85-
// We can't provide the playlist page as it is due to a type conflict, we need to wrap the
86-
// page items and provide a new InfoItemsPage
87-
final List<InfoItem> infoItems = new ArrayList<>(playlistInitialPage.getItems());
88-
return new InfoItemsPage<>(infoItems, playlistInitialPage.getNextPage(),
89-
playlistInitialPage.getErrors());
79+
return playlistExtractorInstance.getInitialPage();
9080
}
9181

9282
@Override
93-
public InfoItemsPage<InfoItem> getPage(final Page page)
94-
throws IOException, ExtractionException {
83+
public InfoItemsPage getPage(final Page page) throws IOException, ExtractionException {
9584
if (!playlistExisting) {
9685
return InfoItemsPage.emptyPage();
9786
}
98-
99-
final InfoItemsPage<StreamInfoItem> playlistPage = playlistExtractorInstance.getPage(page);
100-
101-
// We can't provide the playlist page as it is due to a type conflict, we need to wrap the
102-
// page items and provide a new InfoItemsPage
103-
final List<InfoItem> infoItems = new ArrayList<>(playlistPage.getItems());
104-
return new InfoItemsPage<>(infoItems, playlistPage.getNextPage(),
105-
playlistPage.getErrors());
87+
return playlistExtractorInstance.getPage(page);
10688
}
10789

10890
/**

0 commit comments

Comments
 (0)