Changes due to channel tabs

This commit is contained in:
Stypox 2023-12-29 18:43:54 +01:00
parent b8eb1212a8
commit 1dc746a599
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
6 changed files with 36 additions and 17 deletions

View File

@ -283,18 +283,18 @@ public abstract class StreamingService {
return getChannelExtractor(getChannelLHFactory().fromUrl(url));
}
public ChannelTabExtractor getChannelTabExtractorFromId(final String id, final String tab)
public ChannelTabExtractor getChannelTabExtractorFromId(final String id, final FilterItem tab)
throws ExtractionException {
return getChannelTabExtractor(getChannelTabLHFactory().fromQuery(
id, Collections.singletonList(tab), ""));
id, List.of(tab), List.of()));
}
public ChannelTabExtractor getChannelTabExtractorFromIdAndBaseUrl(final String id,
final String tab,
final FilterItem tab,
final String baseUrl)
throws ExtractionException {
return getChannelTabExtractor(getChannelTabLHFactory().fromQuery(
id, Collections.singletonList(tab), "", baseUrl));
id, List.of(tab), List.of(), baseUrl));
}
public PlaylistExtractor getPlaylistExtractor(final String url) throws ExtractionException {

View File

@ -4,6 +4,7 @@ import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.search.filter.FilterItem;
import javax.annotation.Nonnull;
@ -18,8 +19,13 @@ public abstract class ChannelTabExtractor extends ListExtractor<InfoItem> {
}
@Nonnull
@Override
public String getName() {
public FilterItem getChannelTabType() {
return getLinkHandler().getContentFilters().get(0);
}
@Nonnull
@Override
public String getName() {
return getChannelTabType().getName();
}
}

View File

@ -17,7 +17,7 @@ public class ChannelTabInfo extends ListInfo<InfoItem> {
public ChannelTabInfo(final int serviceId,
@Nonnull final ListLinkHandler linkHandler) {
super(serviceId, linkHandler, linkHandler.getContentFilters().get(0));
super(serviceId, linkHandler, linkHandler.getContentFilters().get(0).getNameId().name());
}
/**

View File

@ -1,16 +1,26 @@
package org.schabi.newpipe.extractor.channel.tabs;
import org.schabi.newpipe.extractor.search.filter.FilterItem;
/**
* Constants of channel tabs supported by the extractor.
*/
public final class ChannelTabs {
public static final String VIDEOS = "videos";
public static final String TRACKS = "tracks";
public static final String SHORTS = "shorts";
public static final String LIVESTREAMS = "livestreams";
public static final String CHANNELS = "channels";
public static final String PLAYLISTS = "playlists";
public static final String ALBUMS = "albums";
public static final int ID_VIDEOS = 0;
public static final int ID_TRACKS = 1;
public static final int ID_SHORTS = 2;
public static final int ID_LIVESTREAMS = 3;
public static final int ID_CHANNELS = 4;
public static final int ID_PLAYLISTS = 5;
public static final int ID_ALBUMS = 6;
public static final FilterItem VIDEOS = new FilterItem(ID_VIDEOS, "Videos");
public static final FilterItem TRACKS = new FilterItem(ID_TRACKS, "Tracks");
public static final FilterItem SHORTS = new FilterItem(ID_SHORTS, "Shorts");
public static final FilterItem LIVESTREAMS = new FilterItem(ID_LIVESTREAMS, "Livestreams");
public static final FilterItem CHANNELS = new FilterItem(ID_CHANNELS, "Channels");
public static final FilterItem PLAYLISTS = new FilterItem(ID_PLAYLISTS, "Playlists");
public static final FilterItem ALBUMS = new FilterItem(ID_ALBUMS, "Albums");
private ChannelTabs() {
}

View File

@ -1,7 +1,9 @@
package org.schabi.newpipe.extractor.exceptions;
import org.schabi.newpipe.extractor.search.filter.FilterItem;
public final class UnsupportedTabException extends UnsupportedOperationException {
public UnsupportedTabException(final String unsupportedTab) {
public UnsupportedTabException(final FilterItem unsupportedTab) {
super("Unsupported tab " + unsupportedTab);
}
}

View File

@ -2,6 +2,7 @@ package org.schabi.newpipe.extractor.linkhandler;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor;
import org.schabi.newpipe.extractor.search.filter.FilterItem;
import javax.annotation.Nonnull;
import java.io.Serializable;
@ -42,9 +43,9 @@ public class ReadyChannelTabListLinkHandler extends ListLinkHandler {
public ReadyChannelTabListLinkHandler(
final String url,
final String channelId,
@Nonnull final String channelTab,
@Nonnull final FilterItem channelTab,
@Nonnull final ChannelTabExtractorBuilder extractorBuilder) {
super(url, url, channelId, List.of(channelTab), "");
super(url, url, channelId, List.of(channelTab), List.of());
this.extractorBuilder = extractorBuilder;
}