[PeerTube]
This commit is contained in:
parent
9e75344611
commit
c7ef8a9e68
|
@ -115,9 +115,9 @@ public class PeertubeAccountExtractor extends ChannelExtractor {
|
||||||
public List<ListLinkHandler> getTabs() throws ParsingException {
|
public List<ListLinkHandler> getTabs() throws ParsingException {
|
||||||
return List.of(
|
return List.of(
|
||||||
PeertubeChannelTabLinkHandlerFactory.getInstance().fromQuery(getId(),
|
PeertubeChannelTabLinkHandlerFactory.getInstance().fromQuery(getId(),
|
||||||
List.of(ChannelTabs.VIDEOS), "", getBaseUrl()),
|
List.of(ChannelTabs.VIDEOS), List.of(), getBaseUrl()),
|
||||||
PeertubeChannelTabLinkHandlerFactory.getInstance().fromQuery(getId(),
|
PeertubeChannelTabLinkHandlerFactory.getInstance().fromQuery(getId(),
|
||||||
List.of(ChannelTabs.CHANNELS), "", getBaseUrl()));
|
List.of(ChannelTabs.CHANNELS), List.of(), getBaseUrl()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -89,9 +89,9 @@ public class PeertubeChannelExtractor extends ChannelExtractor {
|
||||||
public List<ListLinkHandler> getTabs() throws ParsingException {
|
public List<ListLinkHandler> getTabs() throws ParsingException {
|
||||||
return List.of(
|
return List.of(
|
||||||
PeertubeChannelTabLinkHandlerFactory.getInstance().fromQuery(getId(),
|
PeertubeChannelTabLinkHandlerFactory.getInstance().fromQuery(getId(),
|
||||||
List.of(ChannelTabs.VIDEOS), "", getBaseUrl()),
|
List.of(ChannelTabs.VIDEOS), List.of(), getBaseUrl()),
|
||||||
PeertubeChannelTabLinkHandlerFactory.getInstance().fromQuery(getId(),
|
PeertubeChannelTabLinkHandlerFactory.getInstance().fromQuery(getId(),
|
||||||
List.of(ChannelTabs.PLAYLISTS), "", getBaseUrl()));
|
List.of(ChannelTabs.PLAYLISTS), List.of(), getBaseUrl()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,8 +44,8 @@ public class PeertubeChannelTabExtractor extends ChannelTabExtractor {
|
||||||
@Override
|
@Override
|
||||||
public InfoItemsPage<InfoItem> getInitialPage() throws IOException, ExtractionException {
|
public InfoItemsPage<InfoItem> getInitialPage() throws IOException, ExtractionException {
|
||||||
return getPage(new Page(baseUrl + PeertubeChannelLinkHandlerFactory.API_ENDPOINT
|
return getPage(new Page(baseUrl + PeertubeChannelLinkHandlerFactory.API_ENDPOINT
|
||||||
+ getId() + getUrlSuffix(getName()) + "?" + START_KEY + "=0&" + COUNT_KEY + "="
|
+ getId() + getUrlSuffix(getChannelTabType()) + "?" + START_KEY + "=0&"
|
||||||
+ ITEMS_PER_PAGE));
|
+ COUNT_KEY + "=" + ITEMS_PER_PAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,8 +4,11 @@ import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.UnsupportedTabException;
|
import org.schabi.newpipe.extractor.exceptions.UnsupportedTabException;
|
||||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
|
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
|
||||||
|
import org.schabi.newpipe.extractor.search.filter.FilterItem;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class PeertubeChannelTabLinkHandlerFactory extends ListLinkHandlerFactory {
|
public final class PeertubeChannelTabLinkHandlerFactory extends ListLinkHandlerFactory {
|
||||||
|
@ -20,15 +23,14 @@ public final class PeertubeChannelTabLinkHandlerFactory extends ListLinkHandlerF
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static String getUrlSuffix(@Nonnull final String tab)
|
public static String getUrlSuffix(@Nonnull final FilterItem tab)
|
||||||
throws UnsupportedTabException {
|
throws UnsupportedTabException {
|
||||||
switch (tab) {
|
if (tab.equals(ChannelTabs.VIDEOS)) {
|
||||||
case ChannelTabs.VIDEOS:
|
return "/videos";
|
||||||
return "/videos";
|
} else if (tab.equals(ChannelTabs.CHANNELS)) { // only available on accounts
|
||||||
case ChannelTabs.CHANNELS: // only available on accounts
|
return "/video-channels";
|
||||||
return "/video-channels";
|
} else if (tab.equals(ChannelTabs.PLAYLISTS)) { // only available on channels
|
||||||
case ChannelTabs.PLAYLISTS: // only available on channels
|
return "/video-playlists";
|
||||||
return "/video-playlists";
|
|
||||||
}
|
}
|
||||||
throw new UnsupportedTabException(tab);
|
throw new UnsupportedTabException(tab);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +41,9 @@ public final class PeertubeChannelTabLinkHandlerFactory extends ListLinkHandlerF
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(final String id, final List<String> contentFilter, final String sortFilter)
|
public String getUrl(final String id,
|
||||||
|
@Nonnull final List<FilterItem> contentFilter,
|
||||||
|
@Nullable final List<FilterItem> sortFilter)
|
||||||
throws ParsingException, UnsupportedOperationException {
|
throws ParsingException, UnsupportedOperationException {
|
||||||
return PeertubeChannelLinkHandlerFactory.getInstance().getUrl(id)
|
return PeertubeChannelLinkHandlerFactory.getInstance().getUrl(id)
|
||||||
+ getUrlSuffix(contentFilter.get(0));
|
+ getUrlSuffix(contentFilter.get(0));
|
||||||
|
@ -47,11 +51,12 @@ public final class PeertubeChannelTabLinkHandlerFactory extends ListLinkHandlerF
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(final String id,
|
public String getUrl(final String id,
|
||||||
final List<String> contentFilter,
|
final List<FilterItem> contentFilter,
|
||||||
final String sortFilter,
|
final List<FilterItem> sortFilter,
|
||||||
final String baseUrl)
|
final String baseUrl)
|
||||||
throws ParsingException, UnsupportedOperationException {
|
throws ParsingException, UnsupportedOperationException {
|
||||||
return PeertubeChannelLinkHandlerFactory.getInstance().getUrl(id, null, null, baseUrl)
|
return PeertubeChannelLinkHandlerFactory.getInstance()
|
||||||
|
.getUrl(id, null, null, baseUrl)
|
||||||
+ getUrlSuffix(contentFilter.get(0));
|
+ getUrlSuffix(contentFilter.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,13 +64,4 @@ public final class PeertubeChannelTabLinkHandlerFactory extends ListLinkHandlerF
|
||||||
public boolean onAcceptUrl(final String url) throws ParsingException {
|
public boolean onAcceptUrl(final String url) throws ParsingException {
|
||||||
return PeertubeChannelLinkHandlerFactory.getInstance().onAcceptUrl(url);
|
return PeertubeChannelLinkHandlerFactory.getInstance().onAcceptUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getAvailableContentFilter() {
|
|
||||||
return new String[] {
|
|
||||||
ChannelTabs.VIDEOS,
|
|
||||||
ChannelTabs.CHANNELS,
|
|
||||||
ChannelTabs.PLAYLISTS,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue