This commit is contained in:
GH Action - Upstream Sync 2023-10-29 01:13:08 +00:00
commit 6c31e61d1d
5 changed files with 108 additions and 3 deletions

View File

@ -0,0 +1,97 @@
package com.github.catvod.spider;
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.net.OkHttp;
import com.github.catvod.utils.Utils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Qile
*/
public class Kugou extends Spider {
private Map<String, String> getHeader() {
Map<String, String> header = new HashMap<>();
header.put("User-Agent", Utils.CHROME);
return header;
}
@Override
public String homeContent(boolean filter) throws Exception {
List<Class> classes = new ArrayList<>();
List<Vod> list = new ArrayList<>();
List<String> typeIds = Arrays.asList("6666|0", "33162|1", "4681|2");
List<String> typeNames = Arrays.asList("热门榜单", "特色音乐榜", "全球榜");
for (int i = 0; i < typeIds.size(); i++) classes.add(new Class(typeIds.get(i), typeNames.get(i)));
return Result.string(classes, list);
}
@Override
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
HashMap<String, String> ext = new HashMap<>();
if (extend != null && extend.size() > 0) ext.putAll(extend);
String[] item = tid.split("\\|");
String id = item[0];
String digit = item[1];
int digitValue = Integer.parseInt(digit);
String cateId = ext.get("cateId") == null ? id : ext.get("cateId");
String cateUrl = String.format("https://www.kugou.com/yy/rank/home/1-%s.html?from=rank", cateId);
Document doc = Jsoup.parse(OkHttp.string(cateUrl, getHeader()));
Elements lis = doc.select(".pc_rank_sidebar").eq(digitValue).select("ul li a");
JSONArray videos = new JSONArray();
for (Element li : lis) {
String vid = li.attr("href");
String name = li.attr("title");
JSONObject vod = new JSONObject().put("vod_id", vid).put("vod_name", name);
videos.put(vod);
}
JSONObject result = new JSONObject().put("total", lis.size()).put("pagecount", 1).put("list", videos);
return result.toString();
}
@Override
public String detailContent(List<String> ids) throws Exception {
Document doc = Jsoup.parse(OkHttp.string(ids.get(0), getHeader()));
Elements playlist = doc.select(".pc_temp_songlist ul li");
List<String> vodItems = new ArrayList<>();
for (int j = 0; j < playlist.size(); j++) {
Element a = playlist.get(j);
String href = a.select("a.pc_temp_songname").attr("href");
String text = a.select("a.pc_temp_songname").text();
vodItems.add(text + "$" + href);
}
String title = doc.select(".pc_temp_title h3").text();
String remark = doc.select(".rank_update").text();
String vod_play_from = "Qile";
String vod_play_url = TextUtils.join("#", vodItems);
Vod vod = new Vod();
vod.setVodId(ids.get(0));
vod.setVodName(title);
vod.setVodRemarks(remark);
vod.setVodPlayFrom(vod_play_from);
vod.setVodPlayUrl(vod_play_url);
return Result.string(vod);
}
@Override
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
return Result.get().url(id).parse().header(getHeader()).string();
}
}

Binary file not shown.

View File

@ -1 +1 @@
aa238f375f2bb1161db6d60835f44692 d0ae5fa6fb705a6c020f930a73f44714

View File

@ -1,5 +1,5 @@
{ {
"spider": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;aa238f375f2bb1161db6d60835f44692", "spider": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;d0ae5fa6fb705a6c020f930a73f44714",
"wallpaper": "https://gao.chuqiuyu.tk", "wallpaper": "https://gao.chuqiuyu.tk",
"sites": [ "sites": [
{ {

View File

@ -1,5 +1,5 @@
{ {
"spider": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;aa238f375f2bb1161db6d60835f44692", "spider": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;d0ae5fa6fb705a6c020f930a73f44714",
"wallpaper": "http://饭太硬.top/深色壁纸/api.php", "wallpaper": "http://饭太硬.top/深色壁纸/api.php",
"sites": [ "sites": [
{ {
@ -200,6 +200,14 @@
"cookie": "" "cookie": ""
} }
}, },
{
"key": "酷狗",
"name": "酷狗",
"type": 3,
"api": "csp_Kugou",
"searchable": 0,
"changeable": 0
},
{ {
"key": "本地", "key": "本地",
"name": "本地", "name": "本地",