Merge branch 'main' of https://github.com/FongMi/CatVodSpider
This commit is contained in:
commit
57f6b8e98c
|
|
@ -13,6 +13,7 @@ import com.github.catvod.bean.star.Detail;
|
||||||
import com.github.catvod.bean.star.Query;
|
import com.github.catvod.bean.star.Query;
|
||||||
import com.github.catvod.crawler.Spider;
|
import com.github.catvod.crawler.Spider;
|
||||||
import com.github.catvod.net.OkHttp;
|
import com.github.catvod.net.OkHttp;
|
||||||
|
import com.github.catvod.utils.Utils;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
|
|
@ -30,12 +31,20 @@ public class Star extends Spider {
|
||||||
private static final String apiUrl = "https://aws.ulivetv.net/v3/web/api/filter";
|
private static final String apiUrl = "https://aws.ulivetv.net/v3/web/api/filter";
|
||||||
private static final String siteUrl = "https://www.histar.tv/";
|
private static final String siteUrl = "https://www.histar.tv/";
|
||||||
private static final String detail = siteUrl + "vod/detail/";
|
private static final String detail = siteUrl + "vod/detail/";
|
||||||
private static final String data = "/_next/data/";
|
private static final String data = "_next/data/";
|
||||||
private LinkedHashMap<String, String> map;
|
private LinkedHashMap<String, String> map;
|
||||||
private String ver;
|
private String ver;
|
||||||
|
|
||||||
|
private Map<String, String> getHeader() {
|
||||||
|
Map<String, String> headers = new HashMap<>();
|
||||||
|
headers.put("User-Agent", Utils.CHROME);
|
||||||
|
headers.put("Cookie", "userIP=127.0.0.1; aws-waf-token=");
|
||||||
|
headers.put("Referer", siteUrl);
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
private String getVer() {
|
private String getVer() {
|
||||||
for (Element script : Jsoup.parse(OkHttp.string(siteUrl)).select("script")) if (script.attr("src").contains("buildManifest.js")) return script.attr("src").split("/")[3];
|
for (Element script : Jsoup.parse(OkHttp.string(siteUrl, getHeader())).select("script")) if (script.attr("src").contains("buildManifest.js")) return script.attr("src").split("/")[3];
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,8 +65,8 @@ public class Star extends Spider {
|
||||||
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
||||||
for (Map.Entry<String, String> entry : map.entrySet()) classes.add(new Class(entry.getKey(), entry.getValue()));
|
for (Map.Entry<String, String> entry : map.entrySet()) classes.add(new Class(entry.getKey(), entry.getValue()));
|
||||||
for (Class type : classes) {
|
for (Class type : classes) {
|
||||||
String json = OkHttp.string(siteUrl + data + ver + "/" + type.getTypeId() + "/all/all/all.json");
|
Element script = Jsoup.parse(OkHttp.string(siteUrl + type.getTypeId() + "/all/all/all", getHeader())).select("#__NEXT_DATA__").get(0);
|
||||||
JSONObject obj = new JSONObject(json).getJSONObject("pageProps").getJSONObject("filterCondition");
|
JSONObject obj = new JSONObject(script.data()).getJSONObject("props").getJSONObject("pageProps").getJSONObject("filterCondition");
|
||||||
Condition item = Condition.objectFrom(obj.toString());
|
Condition item = Condition.objectFrom(obj.toString());
|
||||||
filters.put(type.getTypeId(), item.getFilter());
|
filters.put(type.getTypeId(), item.getFilter());
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +103,7 @@ public class Star extends Spider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String detailContent(List<String> ids) throws Exception {
|
public String detailContent(List<String> ids) throws Exception {
|
||||||
Element script = Jsoup.parse(OkHttp.string(detail.concat(ids.get(0)))).select("#__NEXT_DATA__").get(0);
|
Element script = Jsoup.parse(OkHttp.string(detail.concat(ids.get(0)), getHeader())).select("#__NEXT_DATA__").get(0);
|
||||||
Detail detail = Detail.objectFrom(new JSONObject(script.data()).getJSONObject("props").getJSONObject("pageProps").getJSONObject("pageData").toString());
|
Detail detail = Detail.objectFrom(new JSONObject(script.data()).getJSONObject("props").getJSONObject("pageProps").getJSONObject("pageData").toString());
|
||||||
Vod vod = new Vod();
|
Vod vod = new Vod();
|
||||||
vod.setVodId(ids.get(0));
|
vod.setVodId(ids.get(0));
|
||||||
|
|
@ -117,7 +126,7 @@ public class Star extends Spider {
|
||||||
@Override
|
@Override
|
||||||
public String searchContent(String key, boolean quick) throws Exception {
|
public String searchContent(String key, boolean quick) throws Exception {
|
||||||
List<Vod> list = new ArrayList<>();
|
List<Vod> list = new ArrayList<>();
|
||||||
String json = OkHttp.string(siteUrl + data + ver + "/search.json?word=" + URLEncoder.encode(key));
|
String json = OkHttp.string(siteUrl + data + ver + "/search.json?word=" + URLEncoder.encode(key), getHeader());
|
||||||
List<Card> items = Card.arrayFrom(new JSONObject(json).getJSONObject("pageProps").getJSONArray("initList").toString());
|
List<Card> items = Card.arrayFrom(new JSONObject(json).getJSONObject("pageProps").getJSONArray("initList").toString());
|
||||||
for (Card item : items) list.add(item.vod());
|
for (Card item : items) list.add(item.vod());
|
||||||
return Result.string(list);
|
return Result.string(list);
|
||||||
|
|
|
||||||
|
|
@ -1,167 +0,0 @@
|
||||||
package com.github.catvod.spider;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import com.github.catvod.bean.Class;
|
|
||||||
import com.github.catvod.bean.Filter;
|
|
||||||
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.FileUtil;
|
|
||||||
import com.github.catvod.utils.Utils;
|
|
||||||
|
|
||||||
import org.jsoup.Jsoup;
|
|
||||||
import org.jsoup.nodes.Document;
|
|
||||||
import org.jsoup.nodes.Element;
|
|
||||||
import org.jsoup.select.Elements;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
public class YingShi extends Spider {
|
|
||||||
|
|
||||||
private final String siteUrl = "https://www.yingshi.tv";
|
|
||||||
private ExecutorService service;
|
|
||||||
|
|
||||||
public File getCache() {
|
|
||||||
return FileUtil.getCacheFile("ying_shi_home");
|
|
||||||
}
|
|
||||||
|
|
||||||
private HashMap<String, String> getHeaders() {
|
|
||||||
HashMap<String, String> headers = new HashMap<>();
|
|
||||||
headers.put("User-Agent", Utils.CHROME);
|
|
||||||
headers.put("Referer", siteUrl);
|
|
||||||
return headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(Context context, String extend) {
|
|
||||||
service = Executors.newCachedThreadPool();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String homeContent(boolean filter) throws Exception {
|
|
||||||
if (getCache().exists()) return FileUtil.read(getCache());
|
|
||||||
List<Class> classes = new ArrayList<>();
|
|
||||||
classes.add(new Class("1", "電視劇"));
|
|
||||||
classes.add(new Class("2", "電影"));
|
|
||||||
classes.add(new Class("4", "動漫"));
|
|
||||||
classes.add(new Class("3", "綜藝"));
|
|
||||||
classes.add(new Class("5", "紀錄片"));
|
|
||||||
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
|
||||||
for (Class type : classes) filters.put(type.getTypeId(), service.submit(new Job(type.getTypeId())).get());
|
|
||||||
String result = Result.string(classes, filters);
|
|
||||||
FileUtil.write(getCache(), result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String homeVideoContent() {
|
|
||||||
Document doc = Jsoup.parse(OkHttp.string(siteUrl));
|
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
for (Element e : doc.select("div#desktop-container").select("li.ys_show_item")) {
|
|
||||||
String id = e.select("a").attr("href").split("/")[4];
|
|
||||||
String pic = e.select("img").attr("src");
|
|
||||||
String name = e.select("h2.ys_show_title").text();
|
|
||||||
String remark = e.select("span.ys_show_episode_text").text();
|
|
||||||
if (!TextUtils.isEmpty(name)) list.add(new Vod(id, name, pic, remark));
|
|
||||||
}
|
|
||||||
return Result.string(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
|
||||||
String by = extend.containsKey("by") ? extend.get("by") : "time";
|
|
||||||
String cls = extend.containsKey("class") ? extend.get("class") : "";
|
|
||||||
String area = extend.containsKey("area") ? extend.get("area") : "";
|
|
||||||
String lang = extend.containsKey("lang") ? extend.get("lang") : "";
|
|
||||||
String year = extend.containsKey("year") ? extend.get("year") : "";
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put("mid", "1");
|
|
||||||
params.put("by", by);
|
|
||||||
params.put("tid", tid);
|
|
||||||
params.put("page", pg);
|
|
||||||
params.put("class", cls);
|
|
||||||
params.put("year", year);
|
|
||||||
params.put("lang", lang);
|
|
||||||
params.put("area", area);
|
|
||||||
params.put("limit", "35");
|
|
||||||
return OkHttp.get(siteUrl + "/ajax/data", params, getHeaders());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String detailContent(List<String> ids) throws Exception {
|
|
||||||
Document doc = Jsoup.parse(OkHttp.string(siteUrl + "/vod/play/id/" + ids.get(0) + "/sid/1/nid/1.html"));
|
|
||||||
String json = doc.html().split("let data = ")[1].split("let obj = ")[0].trim();
|
|
||||||
json = json.substring(0, json.length() - 1).replace("&", " ");
|
|
||||||
Vod vod = Vod.objectFrom(json);
|
|
||||||
return Result.string(vod);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
|
||||||
return Result.get().url(id).string();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String searchContent(String key, boolean quick) throws Exception {
|
|
||||||
return searchContent(key, "1");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String searchContent(String key, boolean quick, String pg) throws Exception {
|
|
||||||
return searchContent(key, pg);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String searchContent(String key, String pg) {
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put("mid", "1");
|
|
||||||
params.put("page", pg);
|
|
||||||
params.put("limit", "18");
|
|
||||||
params.put("wd", URLEncoder.encode(key));
|
|
||||||
return OkHttp.get(siteUrl + "/ajax/search.html", params, getHeaders());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Job implements Callable<List<Filter>> {
|
|
||||||
|
|
||||||
private final String typeId;
|
|
||||||
|
|
||||||
public Job(String typeId) {
|
|
||||||
this.typeId = typeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Filter> call() {
|
|
||||||
List<Filter> items = new ArrayList<>();
|
|
||||||
String url = "https://www.yingshi.tv/vod/show/by/hits_day/id/%s/order/desc.html";
|
|
||||||
Document doc = Jsoup.parse(OkHttp.string(String.format(url, typeId)));
|
|
||||||
items.add(filter(doc.select("div.ys_filter_list_show_types").get(0).select("div.ys_filter.flex").get(1).select("div > div"), "by", "排序", 4));
|
|
||||||
items.add(filter(doc.select("div#ys_filter_by_class").get(0).select("div > div"), "class", "類型", 6));
|
|
||||||
items.add(filter(doc.select("div#ys_filter_by_country").get(0).select("div > div"), "area", "地區", 4));
|
|
||||||
items.add(filter(doc.select("div#ys_filter_by_lang").get(0).select("div > div"), "lang", "語言", 8));
|
|
||||||
items.add(filter(doc.select("div#ys_filter_by_year").get(0).select("div > div"), "year", "時間", 10));
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Filter filter(Elements elements, String key, String name, int index) {
|
|
||||||
List<Filter.Value> values = new ArrayList<>();
|
|
||||||
for (Element e : elements) {
|
|
||||||
String n = e.select("p").text();
|
|
||||||
boolean all = n.contains("全部");
|
|
||||||
String v = all ? "" : e.select("a").attr("href").split("/")[index].replace(".html", "");
|
|
||||||
values.add(new Filter.Value(n, v));
|
|
||||||
}
|
|
||||||
return new Filter(key, name, values);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.github.catvod.utils;
|
package com.github.catvod.utils;
|
||||||
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
|
@ -26,7 +25,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36";
|
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36";
|
||||||
public static final String ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
|
public static final String ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
|
||||||
public static final List<String> MEDIA = Arrays.asList("mp4", "mkv", "wmv", "flv", "avi", "mp3", "aac", "flac", "m4a", "ape", "ogg");
|
public static final List<String> MEDIA = Arrays.asList("mp4", "mkv", "wmv", "flv", "avi", "mp3", "aac", "flac", "m4a", "ape", "ogg");
|
||||||
public static final Pattern RULE = Pattern.compile("http((?!http).){12,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)\\?.*|" + "http((?!http).){12,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)|" + "http((?!http).)*?video/tos*");
|
public static final Pattern RULE = Pattern.compile("http((?!http).){12,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)\\?.*|" + "http((?!http).){12,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)|" + "http((?!http).)*?video/tos*");
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
f5b3145384dbe67650ea3fe783764bd0
|
8ebaf83ea4ffc0082680d3c8484479f2
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"spider": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;f5b3145384dbe67650ea3fe783764bd0",
|
"spider": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;8ebaf83ea4ffc0082680d3c8484479f2",
|
||||||
"wallpaper": "https://gao.chuqiuyu.tk",
|
"wallpaper": "https://gao.chuqiuyu.tk",
|
||||||
"sites": [
|
"sites": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,7 @@
|
||||||
{
|
{
|
||||||
"spider": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;f5b3145384dbe67650ea3fe783764bd0",
|
"spider": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;8ebaf83ea4ffc0082680d3c8484479f2",
|
||||||
"wallpaper": "http://饭太硬.top/深色壁纸/api.php",
|
"wallpaper": "http://饭太硬.top/深色壁纸/api.php",
|
||||||
"sites": [
|
"sites": [
|
||||||
{
|
|
||||||
"key": "影視",
|
|
||||||
"name": "影視",
|
|
||||||
"type": 3,
|
|
||||||
"api": "csp_YingShi",
|
|
||||||
"searchable": 1,
|
|
||||||
"changeable": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"key": "泥巴",
|
"key": "泥巴",
|
||||||
"name": "泥巴",
|
"name": "泥巴",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue