fix: link handler urls for tabs
This commit is contained in:
parent
8a3545c8b2
commit
7dba12be76
|
@ -16,6 +16,7 @@ import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
|
|||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||
import org.schabi.newpipe.extractor.services.bandcamp.extractors.streaminfoitem.BandcampDiscographStreamInfoItemExtractor;
|
||||
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampChannelTabHandler;
|
||||
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampChannelTabLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
|
||||
|
@ -114,10 +115,10 @@ public class BandcampChannelExtractor extends ChannelExtractor {
|
|||
|
||||
if (discography.stream().anyMatch(o -> (
|
||||
(JsonObject) o).getString("item_type").equals("album"))) {
|
||||
final ListLinkHandler lh = getLinkHandler();
|
||||
return Collections.singletonList(
|
||||
new BandcampChannelTabHandler(lh.getUrl(), lh.getId(),
|
||||
ChannelTabs.ALBUMS, discography));
|
||||
new BandcampChannelTabHandler(getUrl()
|
||||
+ BandcampChannelTabLinkHandlerFactory.URL_SUFFIX,
|
||||
getId(), ChannelTabs.ALBUMS, discography));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@ public final class BandcampChannelTabLinkHandlerFactory extends ListLinkHandlerF
|
|||
private static final BandcampChannelTabLinkHandlerFactory INSTANCE
|
||||
= new BandcampChannelTabLinkHandlerFactory();
|
||||
|
||||
// This is not an actual page on the Bandcamp website, but it auto-redirects
|
||||
// to the main page and we need a unique URL for the album tab
|
||||
public static final String URL_SUFFIX = "/album";
|
||||
|
||||
private BandcampChannelTabLinkHandlerFactory() {
|
||||
}
|
||||
|
||||
|
@ -30,9 +34,7 @@ public final class BandcampChannelTabLinkHandlerFactory extends ListLinkHandlerF
|
|||
throw new ParsingException("tab " + tab + " not supported");
|
||||
}
|
||||
|
||||
// This is not an actual page on the Bandcamp website, but it auto-redirects
|
||||
// to the main page and we need a unique URL for the album tab
|
||||
return BandcampChannelLinkHandlerFactory.getInstance().getUrl(id) + "/album";
|
||||
return BandcampChannelLinkHandlerFactory.getInstance().getUrl(id) + URL_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
|
|||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||
import org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelTabLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
||||
|
@ -126,8 +127,8 @@ public class PeertubeAccountExtractor extends ChannelExtractor {
|
|||
@Override
|
||||
public List<ListLinkHandler> getTabs() throws ParsingException {
|
||||
return Collections.singletonList(
|
||||
new ListLinkHandler(getOriginalUrl(), getUrl(), getId(),
|
||||
Collections.singletonList(ChannelTabs.CHANNELS), "")
|
||||
PeertubeChannelTabLinkHandlerFactory.getInstance().fromQuery(getId(),
|
||||
Collections.singletonList(ChannelTabs.CHANNELS), "", getBaseUrl())
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
|
|||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||
import org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelTabLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
||||
|
@ -105,8 +106,8 @@ public class PeertubeChannelExtractor extends ChannelExtractor {
|
|||
@Override
|
||||
public List<ListLinkHandler> getTabs() throws ParsingException {
|
||||
return Collections.singletonList(
|
||||
new ListLinkHandler(getOriginalUrl(), getUrl(), getId(),
|
||||
Collections.singletonList(ChannelTabs.PLAYLISTS), "")
|
||||
PeertubeChannelTabLinkHandlerFactory.getInstance().fromQuery(getId(),
|
||||
Collections.singletonList(ChannelTabs.PLAYLISTS), "", getBaseUrl())
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper;
|
||||
import org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudChannelTabLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
|
||||
|
@ -111,10 +112,15 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
|||
@Nonnull
|
||||
@Override
|
||||
public List<ListLinkHandler> getTabs() throws ParsingException {
|
||||
final String urlPlaylists = getUrl()
|
||||
+ SoundcloudChannelTabLinkHandlerFactory.getUrlSuffix(ChannelTabs.PLAYLISTS);
|
||||
final String urlAlbums = getUrl()
|
||||
+ SoundcloudChannelTabLinkHandlerFactory.getUrlSuffix(ChannelTabs.ALBUMS);
|
||||
|
||||
return Arrays.asList(
|
||||
new ListLinkHandler(getOriginalUrl(), getUrl(), getId(),
|
||||
new ListLinkHandler(urlPlaylists, urlPlaylists, getId(),
|
||||
Collections.singletonList(ChannelTabs.PLAYLISTS), ""),
|
||||
new ListLinkHandler(getOriginalUrl(), getUrl(), getId(),
|
||||
new ListLinkHandler(urlAlbums, urlAlbums, getId(),
|
||||
Collections.singletonList(ChannelTabs.ALBUMS), "")
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public final class SoundcloudChannelTabLinkHandlerFactory extends ListLinkHandle
|
|||
return INSTANCE;
|
||||
}
|
||||
|
||||
private static String getUrlSuffix(final String tab) throws ParsingException {
|
||||
public static String getUrlSuffix(final String tab) throws ParsingException {
|
||||
switch (tab) {
|
||||
case ChannelTabs.PLAYLISTS:
|
||||
return "/sets";
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
|||
import org.schabi.newpipe.extractor.localization.TimeAgoParser;
|
||||
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelTabLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
||||
|
@ -390,13 +391,10 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
JsonObject foundVideoTab = null;
|
||||
tabs = new ArrayList<>();
|
||||
|
||||
final String visitorData = initialData.getObject("responseContext")
|
||||
.getString("visitorData");
|
||||
|
||||
final Consumer<String> addTab = tab -> {
|
||||
try {
|
||||
tabs.add(new ListLinkHandler(getOriginalUrl(), getUrl(), redirectedChannelId,
|
||||
Collections.singletonList(tab), ""));
|
||||
tabs.add(YoutubeChannelTabLinkHandlerFactory.getInstance().fromQuery(
|
||||
redirectedChannelId, Collections.singletonList(tab), ""));
|
||||
} catch (final ParsingException ignored) {
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue