515 lines
28 KiB
Java
515 lines
28 KiB
Java
package com.github.catvod.spider;
|
|
|
|
import android.content.Context;
|
|
import android.text.TextUtils;
|
|
import android.util.Base64;
|
|
|
|
import com.github.catvod.crawler.Spider;
|
|
import com.github.catvod.crawler.SpiderDebug;
|
|
import com.github.catvod.utils.okhttp.OKCallBack;
|
|
import com.github.catvod.utils.okhttp.OkHttpUtil;
|
|
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
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.net.URLEncoder;
|
|
import java.util.ArrayList;
|
|
import java.util.Comparator;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.TreeMap;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
import okhttp3.Call;
|
|
|
|
|
|
/**
|
|
* 神马影院
|
|
* <p>
|
|
* Author: baddychen
|
|
*/
|
|
public class Smdyy extends Spider {
|
|
private static final String siteUrl = "https://www.smdyy.cc";
|
|
/**
|
|
* 播放源配置
|
|
*/
|
|
private JSONObject playerConfig;
|
|
/**
|
|
* 筛选配置
|
|
*/
|
|
private JSONObject filterConfig;
|
|
private Pattern regexCategory = Pattern.compile("/list/(\\d+).html");
|
|
private Pattern regexVid = Pattern.compile("/kan/(\\d+).html");
|
|
private Pattern regexPlay = Pattern.compile("/play/(\\d+)-(\\d+)-(\\d+).html");
|
|
private Pattern regexPage = Pattern.compile("/show/(\\S+).html");
|
|
|
|
protected String ext = null;
|
|
|
|
@Override
|
|
public void init(Context context) {
|
|
super.init(context);
|
|
try {
|
|
playerConfig = new JSONObject("{\"duoduozy\":{\"show\":\"高清线路\",\"or\":999,\"ps\":\"0\",\"parse\":\"https://player.6080kan.cc/player/play.php?url=\"},\"sohu\":{\"show\":\"优选7\",\"or\":999,\"ps\":\"0\",\"parse\":\"https://player.6080kan.cc/player/play.php?url=\"},\"qq\":{\"show\":\"优选3\",\"or\":999,\"ps\":\"0\",\"parse\":\"https://player.6080kan.cc/player/play.php?url=\"},\"bilibili\":{\"show\":\"bilibili\",\"or\":999,\"ps\":\"0\",\"parse\":\"https://player.6080kan.cc/player/play.php?url=\"},\"youku\":{\"show\":\"优选1\",\"or\":999,\"ps\":\"0\",\"parse\":\"https://player.6080kan.cc/player/play.php?url=\"},\"qiyi\":{\"show\":\"优选2\",\"or\":999,\"ps\":\"0\",\"parse\":\"https://player.6080kan.cc/player/play.php?url=\"},\"letv\":{\"show\":\"优选6\",\"or\":999,\"ps\":\"0\",\"parse\":\"https://player.6080kan.cc/player/play.php?url=\"},\"xigua\":{\"show\":\"西瓜视频\",\"or\":999,\"ps\":\"0\",\"parse\":\"https://player.6080kan.cc/player/play.php?url=\"},\"mgtv\":{\"show\":\"优选4\",\"or\":999,\"ps\":\"0\",\"parse\":\"https://player.6080kan.cc/player/play.php?url=\"},\"tkm3u8\":{\"show\":\"备用\",\"or\":999,\"ps\":\"0\",\"parse\":\"https://player.6080kan.cc/player/play.php?url=\"},\"pptv\":{\"show\":\"优选5\",\"or\":999,\"ps\":\"0\",\"parse\":\"https://player.6080kan.cc/player/play.php?url=\"}}");
|
|
filterConfig = new JSONObject("{\"1\":[{\"key\":\"tid\",\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"1\"},{\"n\":\"动作片\",\"v\":\"6\"},{\"n\":\"喜剧片\",\"v\":\"7\"},{\"n\":\"爱情片\",\"v\":\"8\"},{\"n\":\"科幻片\",\"v\":\"9\"},{\"n\":\"恐怖片\",\"v\":\"10\"},{\"n\":\"剧情片\",\"v\":\"11\"},{\"n\":\"战争片\",\"v\":\"12\"},{\"n\":\"犯罪片\",\"v\":\"20\"},{\"n\":\"惊悚片\",\"v\":\"21\"},{\"n\":\"冒险片\",\"v\":\"22\"},{\"n\":\"悬疑片\",\"v\":\"23\"},{\"n\":\"武侠片\",\"v\":\"24\"},{\"n\":\"奇幻片\",\"v\":\"25\"},{\"n\":\"纪录片\",\"v\":\"26\"},{\"n\":\"动画片\",\"v\":\"27\"}]},{\"key\":\"1\",\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"大陆\",\"v\":\"大陆\"},{\"n\":\"香港\",\"v\":\"香港\"},{\"n\":\"台湾\",\"v\":\"台湾\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"法国\",\"v\":\"法国\"},{\"n\":\"英国\",\"v\":\"英国\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"德国\",\"v\":\"德国\"},{\"n\":\"泰国\",\"v\":\"泰国\"},{\"n\":\"印度\",\"v\":\"印度\"},{\"n\":\"意大利\",\"v\":\"意大利\"},{\"n\":\"西班牙\",\"v\":\"西班牙\"},{\"n\":\"加拿大\",\"v\":\"加拿大\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"11\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2022\",\"v\":\"2022\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"},{\"n\":\"2003\",\"v\":\"2003\"},{\"n\":\"2002\",\"v\":\"2002\"},{\"n\":\"2001\",\"v\":\"2001\"},{\"n\":\"2000\",\"v\":\"2000\"}]},{\"key\":\"4\",\"name\":\"语言\",\"value\":[{\"n\":\"全部\",\"v\":\"\"}]}],\"2\":[{\"key\":\"tid\",\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"2\"},{\"n\":\"国产剧\",\"v\":\"13\"},{\"n\":\"港台剧\",\"v\":\"14\"},{\"n\":\"日韩剧\",\"v\":\"15\"},{\"n\":\"欧美剧\",\"v\":\"16\"},{\"n\":\"泰国剧\",\"v\":\"28\"}]},{\"key\":\"1\",\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"大陆\",\"v\":\"大陆\"},{\"n\":\"香港\",\"v\":\"香港\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"法国\",\"v\":\"法国\"},{\"n\":\"英国\",\"v\":\"英国\"},{\"n\":\"德国\",\"v\":\"德国\"},{\"n\":\"台湾\",\"v\":\"台湾\"},{\"n\":\"泰国\",\"v\":\"泰国\"},{\"n\":\"印度\",\"v\":\"印度\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"11\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2022\",\"v\":\"2022\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"},{\"n\":\"2003\",\"v\":\"2003\"},{\"n\":\"2002\",\"v\":\"2002\"},{\"n\":\"2001\",\"v\":\"2001\"},{\"n\":\"2000\",\"v\":\"2000\"}]},{\"key\":\"4\",\"name\":\"语言\",\"value\":[{\"n\":\"全部\",\"v\":\"\"}]}],\"4\":[{\"key\":\"3\",\"name\":\"剧情\",\"value\":[{\"n\":\"全部\",\"v\":\"3\"},{\"n\":\"情感\",\"v\":\"情感\"},{\"n\":\"科幻\",\"v\":\"科幻\"},{\"n\":\"热血\",\"v\":\"热血\"},{\"n\":\"推理\",\"v\":\"推理\"},{\"n\":\"搞笑\",\"v\":\"搞笑\"},{\"n\":\"冒险\",\"v\":\"冒险\"},{\"n\":\"萝莉\",\"v\":\"萝莉\"},{\"n\":\"校园\",\"v\":\"校园\"},{\"n\":\"动作\",\"v\":\"动作\"},{\"n\":\"机战\",\"v\":\"机战\"},{\"n\":\"运动\",\"v\":\"运动\"},{\"n\":\"战争\",\"v\":\"战争\"},{\"n\":\"少年\",\"v\":\"少年\"},{\"n\":\"少女\",\"v\":\"少女\"},{\"n\":\"社会\",\"v\":\"社会\"},{\"n\":\"原创\",\"v\":\"原创\"},{\"n\":\"亲子\",\"v\":\"亲子\"},{\"n\":\"益智\",\"v\":\"益智\"},{\"n\":\"励志\",\"v\":\"励志\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"1\",\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"内地\",\"v\":\"内地\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"香港\",\"v\":\"香港\"},{\"n\":\"台湾\",\"v\":\"台湾\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"泰国\",\"v\":\"泰国\"},{\"n\":\"英国\",\"v\":\"英国\"},{\"n\":\"新加坡\",\"v\":\"新加坡\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"11\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2022\",\"v\":\"2022\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"},{\"n\":\"2003\",\"v\":\"2003\"},{\"n\":\"2002\",\"v\":\"2002\"},{\"n\":\"2001\",\"v\":\"2001\"},{\"n\":\"2000\",\"v\":\"2000\"}]},{\"key\":\"4\",\"name\":\"语言\",\"value\":[{\"n\":\"全部\",\"v\":\"\"}]}]}");
|
|
} catch (JSONException e) {
|
|
SpiderDebug.log(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 爬虫headers
|
|
*
|
|
* @param url
|
|
* @return
|
|
*/
|
|
protected HashMap<String, String> getHeaders(String url) {
|
|
HashMap<String, String> headers = new HashMap<>();
|
|
headers.put("method", "GET");
|
|
if (!TextUtils.isEmpty(url)) {
|
|
headers.put("Referer", url);
|
|
}
|
|
headers.put("Accept-Encoding", "gzip, deflate, br");
|
|
headers.put("Upgrade-Insecure-Requests", "1");
|
|
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36");
|
|
headers.put("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.9");
|
|
headers.put("Accept-Language", "zh-CN,zh;q=0.9");
|
|
return headers;
|
|
}
|
|
|
|
/**
|
|
* 获取分类数据 + 首页最近更新视频列表数据
|
|
*
|
|
* @param filter 是否开启筛选 关联的是 软件设置中 首页数据源里的筛选开关
|
|
* @return
|
|
*/
|
|
@Override
|
|
public String homeContent(boolean filter) {
|
|
try {
|
|
Document doc = Jsoup.parse(OkHttpUtil.string(siteUrl, getHeaders(siteUrl)));
|
|
// 分类节点
|
|
Elements elements = doc.select("ul.stui-header__menu > li a");
|
|
JSONArray classes = new JSONArray();
|
|
for (Element ele : elements) {
|
|
String name = ele.text();
|
|
boolean show = true;
|
|
if (filter) {
|
|
show = name.equals("电影") ||
|
|
name.equals("电视剧") ||
|
|
name.equals("动漫");
|
|
}
|
|
if (show) {
|
|
Matcher mather = regexCategory.matcher(ele.attr("href"));
|
|
if (!mather.find())
|
|
continue;
|
|
String id = mather.group(1).trim();
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("type_id", id);
|
|
jsonObject.put("type_name", name);
|
|
classes.put(jsonObject);
|
|
}
|
|
}
|
|
JSONObject result = new JSONObject();
|
|
if (filter) {
|
|
result.put("filters", filterConfig);
|
|
}
|
|
result.put("class", classes);
|
|
try {
|
|
Elements list = doc.select("div.stui-pannel div.stui-pannel__bd ul.stui-vodlist li div.stui-vodlist__box");
|
|
JSONArray videos = new JSONArray();
|
|
for (int i = 0; i < list.size(); i++) {
|
|
Element vod = list.get(i);
|
|
Matcher matcher = regexVid.matcher(vod.selectFirst(".stui-vodlist__thumb").attr("href"));
|
|
if (!matcher.find())
|
|
continue;
|
|
String title = vod.selectFirst(".stui-vodlist__thumb").attr("title");
|
|
String cover = vod.selectFirst(".stui-vodlist__thumb").attr("data-original");
|
|
String remark = vod.selectFirst("span.pic-text").text();
|
|
if (!TextUtils.isEmpty(cover) && !cover.startsWith("http")) {
|
|
cover = siteUrl + cover;
|
|
}
|
|
String id = matcher.group(1);
|
|
JSONObject v = new JSONObject();
|
|
v.put("vod_id", id);
|
|
v.put("vod_name", title);
|
|
v.put("vod_pic", cover);
|
|
v.put("vod_remarks", remark);
|
|
videos.put(v);
|
|
}
|
|
result.put("list", videos);
|
|
} catch (Exception e) {
|
|
SpiderDebug.log(e);
|
|
}
|
|
return result.toString();
|
|
} catch (Exception e) {
|
|
SpiderDebug.log(e);
|
|
}
|
|
return "";
|
|
}
|
|
|
|
/**
|
|
* 获取分类信息数据
|
|
*
|
|
* @param tid 分类id
|
|
* @param pg 页数
|
|
* @param filter 同homeContent方法中的filter
|
|
* @param extend 筛选参数{k:v, k1:v1}
|
|
* @return
|
|
*/
|
|
@Override
|
|
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
|
try {
|
|
String[] urlParams = new String[]{"", "", "", "", "", "", "", "", "", "", "", ""};
|
|
urlParams[0] = tid;
|
|
urlParams[8] = pg;
|
|
if (extend != null && extend.size() > 0) {
|
|
for (Iterator<String> it = extend.keySet().iterator(); it.hasNext(); ) {
|
|
String key = it.next();
|
|
String value = extend.get(key);
|
|
if (value.trim().length() == 0)
|
|
continue;
|
|
urlParams[Integer.parseInt(key)] = URLEncoder.encode(value);
|
|
}
|
|
}
|
|
// 获取分类数据的url
|
|
String url = siteUrl + "/show/" + TextUtils.join("-", urlParams) + "/";
|
|
String html = OkHttpUtil.string(url, getHeaders(url));
|
|
Document doc = Jsoup.parse(html);
|
|
JSONObject result = new JSONObject();
|
|
int pageCount = 0;
|
|
int page = -1;
|
|
|
|
Elements pageInfo = doc.select("ul.stui-page__item li");
|
|
if (pageInfo.size() == 0) {
|
|
page = Integer.parseInt(pg);
|
|
pageCount = page;
|
|
} else {
|
|
for (int i = 0; i < pageInfo.size(); i++) {
|
|
Element li = pageInfo.get(i);
|
|
Element a = li.selectFirst("a");
|
|
if (a == null)
|
|
continue;
|
|
if (page == -1 && li.hasClass("active")) {
|
|
Matcher matcher = regexPage.matcher(a.attr("href"));
|
|
if (matcher.find()) {
|
|
page = Integer.parseInt(matcher.group(1).split("-")[8]);
|
|
} else {
|
|
page = 0;
|
|
}
|
|
}
|
|
String wy = doc.select("ul.stui-page__item li a").last().attr("href");
|
|
Matcher matcher = regexPage.matcher(wy);
|
|
if (matcher.find()) {
|
|
pageCount = Integer.parseInt(matcher.group(1).split("-")[8]);
|
|
} else {
|
|
pageCount = 0;
|
|
}
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
JSONArray videos = new JSONArray();
|
|
if (!html.contains("没有找到您想要的结果哦")) {
|
|
Elements list = doc.select("ul.stui-vodlist li div.stui-vodlist__box");
|
|
for (int i = 0; i < list.size(); i++) {
|
|
Element vod = list.get(i);
|
|
String title = vod.selectFirst(".stui-vodlist__thumb").attr("title");
|
|
String cover = vod.selectFirst(".stui-vodlist__thumb").attr("data-original");
|
|
if (!TextUtils.isEmpty(cover) && !cover.startsWith("http")) {
|
|
cover = siteUrl + cover;
|
|
}
|
|
String remark = vod.selectFirst("span.pic-text").text();
|
|
Matcher matcher = regexVid.matcher(vod.selectFirst(".stui-vodlist__thumb").attr("href"));
|
|
if (!matcher.find())
|
|
continue;
|
|
String id = matcher.group(1);
|
|
JSONObject v = new JSONObject();
|
|
v.put("vod_id", id);
|
|
v.put("vod_name", title);
|
|
v.put("vod_pic", cover);
|
|
v.put("vod_remarks", remark);
|
|
videos.put(v);
|
|
}
|
|
}
|
|
result.put("page", page);
|
|
result.put("pagecount", pageCount);
|
|
result.put("limit", 48);
|
|
result.put("total", pageCount <= 1 ? videos.length() : pageCount * 48);
|
|
|
|
result.put("list", videos);
|
|
return result.toString();
|
|
} catch (Exception e) {
|
|
SpiderDebug.log(e);
|
|
}
|
|
return "";
|
|
}
|
|
|
|
|
|
private static String Regex(Pattern pattern, String content) {
|
|
if (pattern == null) {
|
|
return content;
|
|
}
|
|
try {
|
|
Matcher matcher = pattern.matcher(content);
|
|
if (matcher.find()) {
|
|
return matcher.group(1).trim();
|
|
}
|
|
} catch (Exception e) {
|
|
SpiderDebug.log(e);
|
|
}
|
|
return content;
|
|
}
|
|
|
|
/**
|
|
* 视频详情信息
|
|
*
|
|
* @param ids 视频id
|
|
* @return
|
|
*/
|
|
@Override
|
|
public String detailContent(List<String> ids) {
|
|
try {
|
|
// 视频详情url
|
|
String url = siteUrl + "/kan/" + ids.get(0) + ".html";
|
|
Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
|
|
JSONObject result = new JSONObject();
|
|
JSONObject vodList = new JSONObject();
|
|
|
|
// 取基本数据
|
|
String cover = doc.selectFirst("a.pic img").attr("data-original");
|
|
if (!TextUtils.isEmpty(cover) && !cover.startsWith("http")) {
|
|
cover = siteUrl + cover;
|
|
}
|
|
String title = doc.selectFirst("div.stui-content__detail h1.title").text();
|
|
String category = "", area = "", year = "", remark = "", director = "", actor = "", desc = "";
|
|
Elements data = doc.select("p.data");
|
|
desc = doc.selectFirst("span.detail-content").text().trim();
|
|
category = Regex(Pattern.compile("类型:(\\S+)"), data.get(0).text());
|
|
area = Regex(Pattern.compile("地区:(\\S+)"), data.get(0).text());
|
|
year = Regex(Pattern.compile("年份:(\\S+)"), data.get(0).text());
|
|
actor = Regex(Pattern.compile("主演:(\\S+)"), data.get(1).text());
|
|
director = Regex(Pattern.compile("导演:(\\S+)"), data.get(1).text());
|
|
|
|
vodList.put("vod_id", ids.get(0));
|
|
vodList.put("vod_name", title);
|
|
vodList.put("vod_pic", cover);
|
|
vodList.put("type_name", category);
|
|
vodList.put("vod_year", year);
|
|
vodList.put("vod_area", area);
|
|
vodList.put("vod_remarks", remark);
|
|
vodList.put("vod_actor", actor);
|
|
vodList.put("vod_director", director);
|
|
vodList.put("vod_content", desc);
|
|
|
|
Map<String, String> vod_play = new TreeMap<>(new Comparator<String>() {
|
|
@Override
|
|
public int compare(String o1, String o2) {
|
|
try {
|
|
int sort1 = playerConfig.getJSONObject(o1).getInt("or");
|
|
int sort2 = playerConfig.getJSONObject(o2).getInt("or");
|
|
|
|
if (sort1 == sort2) {
|
|
return 1;
|
|
}
|
|
return sort1 - sort2 > 0 ? 1 : -1;
|
|
} catch (JSONException e) {
|
|
SpiderDebug.log(e);
|
|
}
|
|
return 1;
|
|
}
|
|
});
|
|
|
|
// 取播放列表数据
|
|
Elements sources = doc.select("div.stui-vodlist__head");
|
|
//Elements sourceList = doc.select("div.stui-vodlist__head > ul.stui-content__playlist");
|
|
|
|
for (int i = 0; i < sources.size(); i++) {
|
|
Element source = sources.get(i);
|
|
String sourceName = source.selectFirst("h3").text().trim();
|
|
boolean found = false;
|
|
for (Iterator<String> it = playerConfig.keys(); it.hasNext(); ) {
|
|
String flag = it.next();
|
|
if (playerConfig.getJSONObject(flag).getString("show").equals(sourceName)) {
|
|
//sourceName = flag;
|
|
sourceName = playerConfig.getJSONObject(flag).getString("show");
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!found)
|
|
continue;
|
|
String playList = "";
|
|
Elements playListA = source.select("ul.stui-content__playlist > li > a");
|
|
List<String> vodItems = new ArrayList<>();
|
|
|
|
for (int j = 0; j < playListA.size(); j++) {
|
|
Element vod = playListA.get(j);
|
|
Matcher matcher = regexPlay.matcher(vod.attr("href"));
|
|
if (!matcher.find())
|
|
continue;
|
|
String playURL = matcher.group(1) + "-" + matcher.group(2) + "-" + matcher.group(3);
|
|
vodItems.add(vod.text() + "$" + playURL);
|
|
}
|
|
if (vodItems.size() > 0)
|
|
playList = TextUtils.join("#", vodItems);
|
|
|
|
if (playList.length() == 0)
|
|
continue;
|
|
|
|
vod_play.put(sourceName, playList);
|
|
}
|
|
|
|
if (vod_play.size() > 0) {
|
|
String vod_play_from = TextUtils.join("$$$", vod_play.keySet());
|
|
String vod_play_url = TextUtils.join("$$$", vod_play.values());
|
|
vodList.put("vod_play_from", vod_play_from);
|
|
vodList.put("vod_play_url", vod_play_url);
|
|
}
|
|
JSONArray list = new JSONArray();
|
|
list.put(vodList);
|
|
result.put("list", list);
|
|
return result.toString();
|
|
} catch (Exception e) {
|
|
SpiderDebug.log(e);
|
|
}
|
|
return "";
|
|
}
|
|
|
|
/**
|
|
* 获取视频播放信息
|
|
*
|
|
* @param flag 播放源
|
|
* @param id 视频id
|
|
* @param vipFlags 所有可能需要vip解析的源
|
|
* @return
|
|
*/
|
|
|
|
private final Pattern urlt = Pattern.compile("\"url\": *\"([^\"]*)\",");
|
|
private final Pattern token = Pattern.compile("\"token\": *\"([^\"]*)\"");
|
|
private final Pattern vkey = Pattern.compile("\"vkey\": *\"([^\"]*)\",");
|
|
|
|
@Override
|
|
public String playerContent(String flag, String id, List<String> vipFlags) {
|
|
try {
|
|
JSONObject headers = new JSONObject();
|
|
headers.put("Referer", " https://www.smdyy.cc/");
|
|
headers.put("User-Agent", " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36");
|
|
headers.put("Accept", " text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9");
|
|
headers.put("Accept-Language", " zh-CN,zh;q=0.9,en-GB;q=0.8,en-US;q=0.7,en;q=0.6");
|
|
headers.put("Accept-Encoding", " gzip, deflate");
|
|
String url = siteUrl + "/play/" + id + ".html";
|
|
Elements allScript = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url))).select("script");
|
|
JSONObject result = new JSONObject();
|
|
for (int i = 0; i < allScript.size(); i++) {
|
|
String scContent = allScript.get(i).html().trim();
|
|
if (scContent.startsWith("var player_")) {
|
|
JSONObject player = new JSONObject(scContent.substring(scContent.indexOf('{'), scContent.lastIndexOf('}') + 1));
|
|
if (playerConfig.has(player.getString("from"))) {
|
|
JSONObject pCfg = playerConfig.getJSONObject(player.getString("from"));
|
|
//String jxurl = "https://player.tjomet.com/lgyy/?url=" + player.getString("url");
|
|
String jxurl = pCfg.getString("parse") + player.getString("url");
|
|
Document doc = Jsoup.parse(OkHttpUtil.string(jxurl, getHeaders(jxurl)));
|
|
Elements script = doc.select("body>script");
|
|
for (int j = 0; j < script.size(); j++) {
|
|
String Content = script.get(j).html().trim();
|
|
Matcher matcher = urlt.matcher(Content);
|
|
if (!matcher.find()) {
|
|
return "";
|
|
}
|
|
String urlt = matcher.group(1);
|
|
Matcher matcher1 = token.matcher(Content);
|
|
if (!matcher1.find()) {
|
|
return "";
|
|
}
|
|
String token = matcher1.group(1);
|
|
Matcher matcher2 = vkey.matcher(Content);
|
|
if (!matcher2.find()) {
|
|
return "";
|
|
}
|
|
String vkey = matcher2.group(1);
|
|
HashMap hashMap = new HashMap();
|
|
hashMap.put("token", token);
|
|
hashMap.put("url", urlt);
|
|
hashMap.put("vkey", vkey);
|
|
hashMap.put("sign", "smdyycc");
|
|
OkHttpUtil.post(OkHttpUtil.defaultClient(), "https://player.6080kan.cc/player/xinapi.php", hashMap, new OKCallBack.OKCallBackString() {
|
|
@Override
|
|
protected void onFailure(Call call, Exception exc) {
|
|
}
|
|
|
|
public void onResponse(String str) {
|
|
try {
|
|
String url = new String(Base64.decode(new JSONObject(str).getString("url").substring(8).getBytes(), 0));
|
|
result.put("url", url.substring(8, url.length() - 8));
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
});
|
|
result.put("header", headers.toString());
|
|
result.put("parse", 0);
|
|
result.put("playUrl", "");
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return result.toString();
|
|
} catch (Exception e) {
|
|
SpiderDebug.log(e);
|
|
}
|
|
return "";
|
|
}
|
|
|
|
/**
|
|
* 搜索
|
|
*
|
|
* @param key
|
|
* @param quick 是否播放页的快捷搜索
|
|
* @return
|
|
*/
|
|
@Override
|
|
public String searchContent(String key, boolean quick) {
|
|
try {
|
|
if (quick)
|
|
return "";
|
|
long currentTime = System.currentTimeMillis();
|
|
String url = siteUrl + "/index.php/ajax/suggest?mid=1&wd=" + URLEncoder.encode(key) + "&limit=10×tamp=" + currentTime;
|
|
JSONObject searchResult = new JSONObject(OkHttpUtil.string(url, getHeaders(url)));
|
|
JSONObject result = new JSONObject();
|
|
JSONArray videos = new JSONArray();
|
|
if (searchResult.getInt("total") > 0) {
|
|
JSONArray lists = new JSONArray(searchResult.getString("list"));
|
|
for (int i = 0; i < lists.length(); i++) {
|
|
JSONObject vod = lists.getJSONObject(i);
|
|
String id = vod.getString("id");
|
|
String title = vod.getString("name");
|
|
String cover = vod.getString("pic");
|
|
if (!TextUtils.isEmpty(cover) && !cover.startsWith("http")) {
|
|
cover = siteUrl + cover;
|
|
}
|
|
JSONObject v = new JSONObject();
|
|
v.put("vod_id", id);
|
|
v.put("vod_name", title);
|
|
v.put("vod_pic", cover);
|
|
v.put("vod_remarks", "");
|
|
videos.put(v);
|
|
}
|
|
}
|
|
result.put("list", videos);
|
|
return result.toString();
|
|
} catch (Exception e) {
|
|
SpiderDebug.log(e);
|
|
}
|
|
return "";
|
|
}
|
|
}
|