package org.schabi.newpipe.extractor.channel; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.ListInfo; import org.schabi.newpipe.extractor.Page; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.utils.ExtractorHelper; import java.io.IOException; public class ChannelTabInfo extends ListInfo { public ChannelTabInfo(final int serviceId, final ListLinkHandler linkHandler) { super(serviceId, linkHandler, linkHandler.getContentFilters().get(0)); } /** * Get ChannelTabInfo from the given service and tab handler * * @param service streaming service * @param linkHandler Channel tab handler (from {@link ChannelInfo}) * @return extracted {@link ChannelTabInfo} */ public static ChannelTabInfo getInfo(final StreamingService service, final ListLinkHandler linkHandler) throws ExtractionException, IOException { final ChannelTabExtractor extractor = service.getChannelTabExtractor(linkHandler); extractor.fetchPage(); return getInfo(extractor); } /** * Get ChannelTabInfo from a ChannelTabExtractor * * @param extractor an extractor where fetchPage() was already got called on. * @return extracted {@link ChannelTabInfo} */ public static ChannelTabInfo getInfo(final ChannelTabExtractor extractor) { final ChannelTabInfo info = new ChannelTabInfo(extractor.getServiceId(), extractor.getLinkHandler()); try { info.setOriginalUrl(extractor.getOriginalUrl()); } catch (final Exception e) { info.addError(e); } final ListExtractor.InfoItemsPage page = ExtractorHelper.getItemsPageOrLogError(info, extractor); info.setRelatedItems(page.getItems()); info.setNextPage(page.getNextPage()); return info; } public static ListExtractor.InfoItemsPage getMoreItems( final StreamingService service, final ListLinkHandler linkHandler, final Page page) throws ExtractionException, IOException { return service.getChannelTabExtractor(linkHandler).getPage(page); } }