Add Kugou

This commit is contained in:
FongMi 2023-10-29 00:15:10 +08:00
parent f3414da84a
commit ec8514031f
3 changed files with 11 additions and 20 deletions

View File

@ -1,7 +1,13 @@
package com.github.catvod.spider; package com.github.catvod.spider;
import android.text.TextUtils; import android.text.TextUtils;
import com.github.catvod.bean.Class;
import com.github.catvod.bean.Result;
import com.github.catvod.bean.Vod;
import com.github.catvod.crawler.Spider; import com.github.catvod.crawler.Spider;
import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Utils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -9,20 +15,12 @@ import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.github.catvod.bean.Result;
import com.github.catvod.bean.Vod;
import com.github.catvod.bean.Class;
/** /**
* @author Qile * @author Qile
@ -41,14 +39,12 @@ public class Kugou extends Spider {
List<Vod> list = new ArrayList<>(); List<Vod> list = new ArrayList<>();
List<String> typeIds = Arrays.asList("6666|0", "33162|1", "4681|2"); List<String> typeIds = Arrays.asList("6666|0", "33162|1", "4681|2");
List<String> typeNames = Arrays.asList("热门榜单", "特色音乐榜", "全球榜"); List<String> typeNames = Arrays.asList("热门榜单", "特色音乐榜", "全球榜");
for (int i = 0; i < typeIds.size(); i++) for (int i = 0; i < typeIds.size(); i++) classes.add(new Class(typeIds.get(i), typeNames.get(i)));
classes.add(new Class(typeIds.get(i), typeNames.get(i)));
return Result.string(classes, list); return Result.string(classes, list);
} }
@Override @Override
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
throws Exception {
HashMap<String, String> ext = new HashMap<>(); HashMap<String, String> ext = new HashMap<>();
if (extend != null && extend.size() > 0) ext.putAll(extend); if (extend != null && extend.size() > 0) ext.putAll(extend);
String[] item = tid.split("\\|"); String[] item = tid.split("\\|");
@ -63,15 +59,10 @@ public class Kugou extends Spider {
for (Element li : lis) { for (Element li : lis) {
String vid = li.attr("href"); String vid = li.attr("href");
String name = li.attr("title"); String name = li.attr("title");
JSONObject vod = new JSONObject() JSONObject vod = new JSONObject().put("vod_id", vid).put("vod_name", name);
.put("vod_id", vid)
.put("vod_name", name);
videos.put(vod); videos.put(vod);
} }
JSONObject result = new JSONObject() JSONObject result = new JSONObject().put("total", lis.size()).put("pagecount", 1).put("list", videos);
.put("total", lis.size())
.put("pagecount", 1)
.put("list", videos);
return result.toString(); return result.toString();
} }

Binary file not shown.

View File

@ -1 +1 @@
aa238f375f2bb1161db6d60835f44692 d0ae5fa6fb705a6c020f930a73f44714