Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public enum InfoType {
STREAM,
PLAYLIST,
CHANNEL,
COMMENT
COMMENT,
RENDERER_LIST
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
import org.schabi.newpipe.extractor.channel.ChannelInfoItemsCollector;
import org.schabi.newpipe.extractor.channel.tabs.rendererlist.RendererListInfoItemExtractor;
import org.schabi.newpipe.extractor.channel.tabs.rendererlist.RendererListInfoItemsCollector;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemExtractor;
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemsCollector;
Expand Down Expand Up @@ -41,6 +43,7 @@
* <li>{@link StreamInfoItemExtractor}</li>
* <li>{@link ChannelInfoItemExtractor}</li>
* <li>{@link PlaylistInfoItemExtractor}</li>
* <li>{@link RendererListInfoItemExtractor}</li>
* </ul>
* Calling {@link #extract(InfoItemExtractor)} or {@link #commit(InfoItemExtractor)} with any
* other extractor type will raise an exception.
Expand All @@ -49,12 +52,14 @@ public class MultiInfoItemsCollector extends InfoItemsCollector<InfoItem, InfoIt
private final StreamInfoItemsCollector streamCollector;
private final ChannelInfoItemsCollector userCollector;
private final PlaylistInfoItemsCollector playlistCollector;
private final RendererListInfoItemsCollector rendererListCollector;

public MultiInfoItemsCollector(final int serviceId) {
super(serviceId);
streamCollector = new StreamInfoItemsCollector(serviceId);
userCollector = new ChannelInfoItemsCollector(serviceId);
playlistCollector = new PlaylistInfoItemsCollector(serviceId);
rendererListCollector = new RendererListInfoItemsCollector(serviceId);
}

@Override
Expand All @@ -63,6 +68,7 @@ public List<Throwable> getErrors() {
errors.addAll(streamCollector.getErrors());
errors.addAll(userCollector.getErrors());
errors.addAll(playlistCollector.getErrors());
errors.addAll(rendererListCollector.getErrors());

return Collections.unmodifiableList(errors);
}
Expand All @@ -73,6 +79,7 @@ public void reset() {
streamCollector.reset();
userCollector.reset();
playlistCollector.reset();
rendererListCollector.reset();
}

@Override
Expand All @@ -84,6 +91,8 @@ public InfoItem extract(final InfoItemExtractor extractor) throws ParsingExcepti
return userCollector.extract((ChannelInfoItemExtractor) extractor);
} else if (extractor instanceof PlaylistInfoItemExtractor) {
return playlistCollector.extract((PlaylistInfoItemExtractor) extractor);
} else if (extractor instanceof RendererListInfoItemExtractor) {
return rendererListCollector.extract((RendererListInfoItemExtractor) extractor);
} else {
throw new IllegalArgumentException("Invalid extractor type: " + extractor);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.schabi.newpipe.extractor;

import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.channel.list.ChannelListExtractor;
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor;
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
Expand Down Expand Up @@ -88,7 +89,7 @@ public enum LinkType {
NONE,
STREAM,
CHANNEL,
PLAYLIST
PLAYLIST,
}

private final int serviceId;
Expand Down Expand Up @@ -223,6 +224,17 @@ public abstract ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler
public abstract ChannelTabExtractor getChannelTabExtractor(ListLinkHandler linkHandler)
throws ExtractionException;

/**
* Must create a new instance of a ChannelListExtractor implementation.
* @param linkHandler is pointing to the channel which should be handled by this new instance.
* @return a new ChannelListExtractor
* <p>
* In services which there's no other way to retrieve them, null should be returned.
*
*/
public abstract ChannelListExtractor getChannelListExtractor(ListLinkHandler linkHandler)
throws ExtractionException;

/**
* Must crete a new instance of a PlaylistExtractor implementation.
* @param linkHandler is pointing to the playlist which should be handled by this new instance.
Expand Down Expand Up @@ -295,6 +307,15 @@ public ChannelTabExtractor getChannelTabExtractorFromIdAndBaseUrl(final String i
id, Collections.singletonList(tab), "", baseUrl));
}

public ChannelListExtractor getChannelListExtractor(final String id,
final List<String> contentFilter,
final String baseUrl)
throws ExtractionException {
return getChannelListExtractor(getChannelTabLHFactory().fromQuery(
id, contentFilter, "", baseUrl));
}


public PlaylistExtractor getPlaylistExtractor(final String url) throws ExtractionException {
return getPlaylistExtractor(getPlaylistLHFactory().fromUrl(url));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.schabi.newpipe.extractor.channel.list;

import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;

public abstract class ChannelListExtractor extends ListExtractor<ChannelInfoItem> {
public ChannelListExtractor(final StreamingService service,

Check warning on line 9 in extractor/src/main/java/org/schabi/newpipe/extractor/channel/list/ChannelListExtractor.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Change the visibility of this constructor to "protected".

See more on https://sonarcloud.io/project/issues?id=TeamNewPipe_NewPipeExtractor&issues=AZz-eWSntAxTmA_RSLXn&open=AZz-eWSntAxTmA_RSLXn&pullRequest=1468
final ListLinkHandler linkHandler) {
super(service, linkHandler);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.schabi.newpipe.extractor.channel.list;

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.channel.ChannelInfoItem;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.utils.ExtractorHelper;

import java.io.IOException;

import javax.annotation.Nonnull;

public class ChannelListInfo extends ListInfo<ChannelInfoItem> {
public ChannelListInfo(final int serviceId,
@Nonnull final ListLinkHandler linkHandler,
final String name) {
super(serviceId, linkHandler, name);
}

/**
* Get a {@link ChannelListInfo} instance from the given service and link handler.
*
* @param service streaming service
* @param linkHandler Channel list handler (from {@link ChannelListInfo})
* @return the extracted {@link ChannelListInfo}
*/
@Nonnull
public static ChannelListInfo getInfo(@Nonnull final StreamingService service,
@Nonnull final ListLinkHandler linkHandler)
throws ExtractionException, IOException {
final ChannelListExtractor extractor = service
.getChannelListExtractor(linkHandler);
extractor.fetchPage();

return getInfo(extractor);
}

/**
* Get a {@link ChannelListInfo} instance from a {@link ChannelListExtractor}.
*
* @param extractor an extractor where {@code fetchPage()} was already got called on
* @return the extracted {@link ChannelListInfo}
*/
@Nonnull
public static ChannelListInfo getInfo(@Nonnull final ChannelListExtractor extractor)
throws ParsingException {
final ChannelListInfo info =
new ChannelListInfo(extractor.getServiceId(),
extractor.getLinkHandler(),
extractor.getName());
try {

info.setOriginalUrl(extractor.getOriginalUrl());
} catch (final Exception e) {
info.addError(e);
}

final ListExtractor.InfoItemsPage<ChannelInfoItem> page
= ExtractorHelper.getItemsPageOrLogError(info, extractor);
info.setRelatedItems(page.getItems());
info.setNextPage(page.getNextPage());

return info;
}

public static ListExtractor.InfoItemsPage<ChannelInfoItem> getMoreItems(
@Nonnull final StreamingService service,
@Nonnull final ListLinkHandler linkHandler,
@Nonnull final Page page) throws ExtractionException, IOException {
return service.getChannelListExtractor(linkHandler).getPage(page);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Constants of channel tabs supported by the extractor.
*/
public final class ChannelTabs {

public static final String FEATURED = "featured";
public static final String VIDEOS = "videos";
public static final String TRACKS = "tracks";
public static final String SHORTS = "shorts";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.schabi.newpipe.extractor.channel.tabs.rendererlist;

import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;

public class RendererListInfoItem extends InfoItem {

private String title;
private ListLinkHandler listLinkHandler;
private String rendererListItemType;

public RendererListInfoItem(final int serviceId, final String url, final String name) {
super(InfoType.RENDERER_LIST, serviceId, url, name);
}

public String getTitle() {
return this.title;
}

public void setTitle(final String title) {
this.title = title;
}

public ListLinkHandler getListLinkHandler() {
return this.listLinkHandler;
}

public void setListLinkHandler(final ListLinkHandler listLinkHandler) {
this.listLinkHandler = listLinkHandler;
}

public String getRendererListItemType() {
return this.rendererListItemType;
}

public void setRendererListItemType(final String rendererListItemType) {
this.rendererListItemType = rendererListItemType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.schabi.newpipe.extractor.channel.tabs.rendererlist;

import org.schabi.newpipe.extractor.InfoItemExtractor;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;

public interface RendererListInfoItemExtractor extends InfoItemExtractor {

/**
* Get the list link handler of the renderer list item for extraction
* @return the ListLinkHandler of the list
*/
ListLinkHandler getListLinkHandler() throws ParsingException;

/**
* Gets the item type as a string for this render list item
* @return the item type of the render list string
*/
String getRendererListItemType() throws ParsingException;

/**
* Get the uploader including tab url
* @return the uploader including tab url
*/
String getUploaderTabUrl() throws ParsingException;

/**
* Get the uploader name
* @return the uploader name
*/
String getUploaderName() throws ParsingException;

/**
* Get the uploader url
* @return the uploader url
*/
String getUploaderUrl() throws ParsingException;

/**
* Get whether the uploader is verified
* @return whether the uploader is verified
*/
boolean isUploaderVerified() throws ParsingException;

/**
* Creates a render list index that can be used in the content filter
* @return render list index string as a content filter
*/
static String createIndexContentFilter(final int index) {
return "rendererlist_index=" + index;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.schabi.newpipe.extractor.channel.tabs.rendererlist;

import org.schabi.newpipe.extractor.InfoItemsCollector;
import org.schabi.newpipe.extractor.exceptions.ParsingException;

public final class RendererListInfoItemsCollector extends
InfoItemsCollector<RendererListInfoItem, RendererListInfoItemExtractor> {

public RendererListInfoItemsCollector(final int serviceId) {
super(serviceId);
}

@Override
public RendererListInfoItem extract(final RendererListInfoItemExtractor extractor)
throws ParsingException {

final RendererListInfoItem resultItem = new RendererListInfoItem(
getServiceId(), extractor.getUrl(), extractor.getName());

try {
resultItem.setTitle(extractor.getName());
} catch (final Exception e) {
addError(e);
}
try {
resultItem.setListLinkHandler(extractor.getListLinkHandler());
} catch (final Exception e) {
addError(e);
}
try {
resultItem.setRendererListItemType(extractor.getRendererListItemType());
} catch (final Exception e) {
addError(e);
}

return resultItem;
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.channel.list.ChannelListExtractor;
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor;
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
Expand Down Expand Up @@ -154,6 +155,12 @@ public ChannelTabExtractor getChannelTabExtractor(final ListLinkHandler linkHand
}
}

@Override
public ChannelListExtractor getChannelListExtractor(final ListLinkHandler linkHandler)
throws ExtractionException {
return null;
}

@Override
public PlaylistExtractor getPlaylistExtractor(final ListLinkHandler linkHandler) {
return new BandcampPlaylistExtractor(this, linkHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.channel.list.ChannelListExtractor;
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor;
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
Expand Down Expand Up @@ -101,6 +102,12 @@ public ChannelTabExtractor getChannelTabExtractor(final ListLinkHandler linkHand
}
}

@Override
public ChannelListExtractor getChannelListExtractor(final ListLinkHandler linkHandler)
throws ExtractionException {
return null;
}

@Override
public PlaylistExtractor getPlaylistExtractor(final ListLinkHandler linkHandler) {
return null;
Expand Down
Loading