导航菜单

页面标题

页面副标题

Kreate v1.5.0 - SoundcloudSuggestionExtractor.java 源代码

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

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


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

import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper;
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
import org.schabi.newpipe.extractor.utils.Utils;

public class SoundcloudSuggestionExtractor extends SuggestionExtractor {
    public SoundcloudSuggestionExtractor(StreamingService streamingService) {
        super(streamingService);
    }

    @Override
    public List<String> suggestionList(String str) throws IOException, ExtractionException {
        ArrayList arrayList = new ArrayList();
        try {
            Iterator it = ((JsonObject) JsonParser.object().from(NewPipe.getDownloader().get("https://api-v2.soundcloud.com/search/queries?q=" + Utils.encodeUrlUtf8(str) + "&client_id=" + SoundcloudParsingHelper.clientId() + "&limit=10", getExtractorLocalization()).responseBody())).getArray("collection").iterator();
            while (it.hasNext()) {
                Object next = it.next();
                if (next instanceof JsonObject) {
                    arrayList.add(((JsonObject) next).getString("query"));
                }
            }
            return arrayList;
        } catch (JsonParserException e) {
            throw new ParsingException("Could not parse json response", e);
        }
    }
}