导航菜单

页面标题

页面副标题

Kreate v1.5.0 - SoundcloudChartsExtractor.java 源代码

正在查看: Kreate v1.5.0 应用的 SoundcloudChartsExtractor.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package org.schabi.newpipe.extractor.services.soundcloud.extractors;

import java.io.IOException;
import javax.annotation.Nonnull;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.downloader.Downloader;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.localization.ContentCountry;
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
import org.schabi.newpipe.extractor.utils.Utils;

public class SoundcloudChartsExtractor extends KioskExtractor<StreamInfoItem> {
    @Override
    public void onFetchPage(@Nonnull Downloader downloader) {
    }

    public SoundcloudChartsExtractor(StreamingService streamingService, ListLinkHandler listLinkHandler, String str) {
        super(streamingService, listLinkHandler, str);
    }

    @Override
    @Nonnull
    public String getName() {
        return getId();
    }

    @Override
    public ListExtractor.InfoItemsPage<StreamInfoItem> getPage(Page page) throws IOException, ExtractionException {
        if (page == null || Utils.isNullOrEmpty(page.getUrl())) {
            throw new IllegalArgumentException("Page doesn't contain an URL");
        }
        StreamInfoItemsCollector streamInfoItemsCollector = new StreamInfoItemsCollector(getServiceId());
        return new ListExtractor.InfoItemsPage<>(streamInfoItemsCollector, new Page(SoundcloudParsingHelper.getStreamsFromApi(streamInfoItemsCollector, page.getUrl(), true)));
    }

    @Override
    @Nonnull
    public ListExtractor.InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
        String str;
        String str2;
        String streamsFromApi;
        StreamInfoItemsCollector streamInfoItemsCollector = new StreamInfoItemsCollector(getServiceId());
        String str3 = "https://api-v2.soundcloud.com/charts?genre=soundcloud:genres:all-music&client_id=" + SoundcloudParsingHelper.clientId();
        if (getId().equals("Top 50")) {
            str = str3 + "&kind=top";
        } else {
            str = str3 + "&kind=trending";
        }
        ContentCountry contentCountry = ServiceList.SoundCloud.getContentCountry();
        if (getService().getSupportedCountries().contains(contentCountry)) {
            str2 = str + "&region=soundcloud:regions:" + contentCountry.getCountryCode();
        } else {
            str2 = null;
        }
        if (str2 == null) {
            str2 = str;
        }
        try {
            streamsFromApi = SoundcloudParsingHelper.getStreamsFromApi(streamInfoItemsCollector, str2, true);
        } catch (IOException unused) {
            streamsFromApi = SoundcloudParsingHelper.getStreamsFromApi(streamInfoItemsCollector, str, true);
        }
        return new ListExtractor.InfoItemsPage<>(streamInfoItemsCollector, new Page(streamsFromApi));
    }
}