正在查看: Kreate v1.5.0 应用的 SoundcloudChannelTabExtractor.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Kreate v1.5.0 应用的 SoundcloudChannelTabExtractor.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.schabi.newpipe.extractor.services.soundcloud.extractors;
import java.io.IOException;
import javax.annotation.Nonnull;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.MultiInfoItemsCollector;
import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor;
import org.schabi.newpipe.extractor.downloader.Downloader;
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.services.soundcloud.SoundcloudParsingHelper;
import org.schabi.newpipe.extractor.utils.Utils;
public class SoundcloudChannelTabExtractor extends ChannelTabExtractor {
private static final String USERS_ENDPOINT = "https://api-v2.soundcloud.com/users/";
private final String userId;
@Override
public void onFetchPage(@Nonnull Downloader downloader) {
}
public SoundcloudChannelTabExtractor(StreamingService streamingService, ListLinkHandler listLinkHandler) {
super(streamingService, listLinkHandler);
this.userId = getLinkHandler().getId();
}
@Nonnull
private String getEndpoint() throws ParsingException {
String name = getName();
name.hashCode();
switch (name) {
case "playlists":
return "/playlists_without_albums";
case "albums":
return "/albums";
case "tracks":
return "/tracks";
default:
throw new ParsingException("Unsupported tab: " + getName());
}
}
@Override
@Nonnull
public String getId() {
return this.userId;
}
@Override
@Nonnull
public ListExtractor.InfoItemsPage<InfoItem> getInitialPage() throws IOException, ExtractionException {
return getPage(new Page(USERS_ENDPOINT + this.userId + getEndpoint() + "?client_id=" + SoundcloudParsingHelper.clientId() + "&limit=20&linked_partitioning=1"));
}
@Override
public ListExtractor.InfoItemsPage<InfoItem> getPage(Page page) throws IOException, ExtractionException {
if (page == null || Utils.isNullOrEmpty(page.getUrl())) {
throw new IllegalArgumentException("Page doesn't contain an URL");
}
MultiInfoItemsCollector multiInfoItemsCollector = new MultiInfoItemsCollector(getServiceId());
return new ListExtractor.InfoItemsPage<>(multiInfoItemsCollector, new Page(SoundcloudParsingHelper.getInfoItemsFromApi(multiInfoItemsCollector, page.getUrl())));
}
}