mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-04-29 00:10:35 +05:30
[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
This commit is contained in:
parent
e34b4f1978
commit
9d3761a371
@ -1,6 +1,7 @@
|
|||||||
package org.schabi.newpipe.extractor.services.youtube.extractors;
|
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.Page;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor;
|
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.linkhandler.ListLinkHandler;
|
||||||
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubePlaylistLinkHandlerFactory;
|
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.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
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
|
* A {@link ChannelTabExtractor} for YouTube system playlists using a
|
||||||
@ -74,35 +72,19 @@ public class YoutubeChannelTabPlaylistExtractor extends ChannelTabExtractor {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public InfoItemsPage<InfoItem> getInitialPage() throws IOException, ExtractionException {
|
public InfoItemsPage getInitialPage() throws IOException, ExtractionException {
|
||||||
if (!playlistExisting) {
|
if (!playlistExisting) {
|
||||||
return InfoItemsPage.emptyPage();
|
return InfoItemsPage.emptyPage();
|
||||||
}
|
}
|
||||||
|
return playlistExtractorInstance.getInitialPage();
|
||||||
final InfoItemsPage<StreamInfoItem> 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<InfoItem> infoItems = new ArrayList<>(playlistInitialPage.getItems());
|
|
||||||
return new InfoItemsPage<>(infoItems, playlistInitialPage.getNextPage(),
|
|
||||||
playlistInitialPage.getErrors());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InfoItemsPage<InfoItem> getPage(final Page page)
|
public InfoItemsPage getPage(final Page page) throws IOException, ExtractionException {
|
||||||
throws IOException, ExtractionException {
|
|
||||||
if (!playlistExisting) {
|
if (!playlistExisting) {
|
||||||
return InfoItemsPage.emptyPage();
|
return InfoItemsPage.emptyPage();
|
||||||
}
|
}
|
||||||
|
return playlistExtractorInstance.getPage(page);
|
||||||
final InfoItemsPage<StreamInfoItem> 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<InfoItem> infoItems = new ArrayList<>(playlistPage.getItems());
|
|
||||||
return new InfoItemsPage<>(infoItems, playlistPage.getNextPage(),
|
|
||||||
playlistPage.getErrors());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user