Clean
This commit is contained in:
parent
7f06546931
commit
e5ca5567f1
|
|
@ -10,6 +10,8 @@ public class Filter {
|
||||||
private String key;
|
private String key;
|
||||||
@SerializedName("name")
|
@SerializedName("name")
|
||||||
private String name;
|
private String name;
|
||||||
|
@SerializedName("init")
|
||||||
|
private String init;
|
||||||
@SerializedName("value")
|
@SerializedName("value")
|
||||||
private List<Value> value;
|
private List<Value> value;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import android.widget.Button;
|
||||||
import com.github.catvod.R;
|
import com.github.catvod.R;
|
||||||
import com.github.catvod.crawler.Spider;
|
import com.github.catvod.crawler.Spider;
|
||||||
import com.github.catvod.spider.Init;
|
import com.github.catvod.spider.Init;
|
||||||
import com.github.catvod.spider.NiNi;
|
import com.github.catvod.spider.Ysj;
|
||||||
import com.orhanobut.logger.AndroidLogAdapter;
|
import com.orhanobut.logger.AndroidLogAdapter;
|
||||||
import com.orhanobut.logger.Logger;
|
import com.orhanobut.logger.Logger;
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class MainActivity extends Activity {
|
||||||
private void initSpider() {
|
private void initSpider() {
|
||||||
try {
|
try {
|
||||||
Init.init(getApplicationContext());
|
Init.init(getApplicationContext());
|
||||||
spider = new NiNi();
|
spider = new Ysj();
|
||||||
spider.init(this, "");
|
spider.init(this, "");
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
||||||
|
|
@ -1,349 +0,0 @@
|
||||||
package com.github.catvod.spider;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
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.crawler.SpiderDebug;
|
|
||||||
import com.github.catvod.net.OkHttp;
|
|
||||||
import com.github.catvod.utils.Util;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.security.Key;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
|
||||||
import javax.crypto.SecretKeyFactory;
|
|
||||||
import javax.crypto.spec.DESKeySpec;
|
|
||||||
|
|
||||||
public class NiNi extends Spider {
|
|
||||||
|
|
||||||
private static final String desktopUrl = "https://api.nivodz.com/index/desktop/WEB/3.4";
|
|
||||||
private static final String rankingUrl = "https://api.nivodz.com/index/ranking/list/WEB/3.2";
|
|
||||||
private static final String filterUrl = "https://api.nivodz.com/show/filter/condition/WEB/3.2";
|
|
||||||
private static final String searchUrl = "https://api.nivodz.com/show/search/WEB/3.2";
|
|
||||||
private static final String categoryUrl = "https://api.nivodz.com/show/filter/WEB/3.2";
|
|
||||||
private static final String detailUrl = "https://api.nivodz.com/show/detail/WEB/3.2";
|
|
||||||
private static final String playUrl = "https://api.nivodz.com/show/play/info/WEB/3.3";
|
|
||||||
private static final String des_key = "diao.com";
|
|
||||||
private boolean adult;
|
|
||||||
|
|
||||||
private HashMap<String, String> getHeaders() {
|
|
||||||
HashMap<String, String> headers = new HashMap<>();
|
|
||||||
headers.put("User-Agent", Util.CHROME);
|
|
||||||
headers.put("Referer", "https://m.nbys.tv/");
|
|
||||||
return headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Filter getFilter(String name, String key, JSONArray target, String n, String v) throws JSONException {
|
|
||||||
List<Filter.Value> values = new ArrayList<>();
|
|
||||||
if (!key.equals("by")) values.add(new Filter.Value("全部", ""));
|
|
||||||
for (int j = 0; j < target.length(); j++) values.add(new Filter.Value(target.getJSONObject(j).get(n).toString(), target.getJSONObject(j).get(v).toString()));
|
|
||||||
return new Filter(key, name, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkExtend(HashMap<String, String> extend, String key, String value) {
|
|
||||||
if (extend.get(key) == null || extend.get(key).equals("")) extend.put(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(Context context, String extend) {
|
|
||||||
adult = !TextUtils.isEmpty(extend);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String homeContent(boolean filter) throws Exception {
|
|
||||||
List<Class> classes = new ArrayList<>();
|
|
||||||
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
|
||||||
JSONObject object = new JSONObject(get(filterUrl));
|
|
||||||
for (int i = 0; i < object.getJSONArray("channels").length(); i++) {
|
|
||||||
String typeId = object.getJSONArray("channels").getJSONObject(i).get("channelId").toString();
|
|
||||||
String typeName = object.getJSONArray("channels").getJSONObject(i).get("channelName").toString();
|
|
||||||
if (!adult && typeName.contains("午夜")) continue;
|
|
||||||
classes.add(adult && typeName.contains("午夜") ? 0 : classes.size(), new Class(typeId, typeName));
|
|
||||||
List<Filter> array = new ArrayList<>();
|
|
||||||
array.add(getFilter("排序", "by", object.getJSONObject("sortsMap").getJSONArray(typeId), "title", "id"));
|
|
||||||
array.add(getFilter("語言", "lang", object.getJSONArray("langs"), "langName", "langId"));
|
|
||||||
array.add(getFilter("地區", "area", object.getJSONArray("regions"), "regionName", "regionId"));
|
|
||||||
array.add(getFilter("類型", "class", object.getJSONObject("typesMap").getJSONArray(typeId), "showTypeName", "showTypeId"));
|
|
||||||
array.add(getFilter("年份", "year", object.getJSONArray("yearRanges"), "name", "code"));
|
|
||||||
filters.put(typeId, array);
|
|
||||||
}
|
|
||||||
return Result.string(classes, filters);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getAdultHome() throws Exception {
|
|
||||||
Map<String, String> params = new TreeMap<>();
|
|
||||||
params.put("channel_id", "7");
|
|
||||||
params.put("start", "0");
|
|
||||||
params.put("more", "1");
|
|
||||||
JSONObject object = new JSONObject(post(desktopUrl, params));
|
|
||||||
JSONArray array = object.getJSONArray("list");
|
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
for (int i = 0; i < array.length(); i++) {
|
|
||||||
JSONArray rows = array.getJSONObject(i).getJSONArray("rows");
|
|
||||||
for (int j = 0; j < rows.length(); j++) {
|
|
||||||
JSONArray cells = rows.getJSONObject(j).getJSONArray("cells");
|
|
||||||
for (int k = 0; k < cells.length(); k++) {
|
|
||||||
JSONObject item = cells.getJSONObject(k).getJSONObject("show");
|
|
||||||
String id = item.getString("showIdCode");
|
|
||||||
String name = item.getString("showTitle");
|
|
||||||
String pic = item.getString("showImg");
|
|
||||||
list.add(new Vod(id, name, getPic(pic), getRemarks(item)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Result.string(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String homeVideoContent() throws Exception {
|
|
||||||
if (adult) return getAdultHome();
|
|
||||||
JSONObject object = new JSONObject(get(rankingUrl));
|
|
||||||
JSONArray array = object.getJSONArray("list");
|
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
for (int i = 0; i < array.length(); i++) {
|
|
||||||
JSONArray dataItem = array.getJSONArray(i);
|
|
||||||
for (int j = 0; j < dataItem.length(); j++) {
|
|
||||||
JSONObject item = dataItem.getJSONObject(j);
|
|
||||||
String id = item.getString("showIdCode");
|
|
||||||
String name = item.getString("showTitle");
|
|
||||||
String pic = item.getString("showImg");
|
|
||||||
list.add(new Vod(id, name, getPic(pic), getRemarks(item)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Result.string(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
|
||||||
int page = Integer.parseInt(pg) - 1;
|
|
||||||
if (tid.endsWith("/{pg}")) return searchContent(tid.split("/")[0], page);
|
|
||||||
checkExtend(extend, "by", "3");
|
|
||||||
checkExtend(extend, "area", "0");
|
|
||||||
checkExtend(extend, "lang", "0");
|
|
||||||
checkExtend(extend, "year", "");
|
|
||||||
checkExtend(extend, "class", "0");
|
|
||||||
Map<String, String> params = new TreeMap<>();
|
|
||||||
params.put("sort_by", extend.get("by"));
|
|
||||||
params.put("channel_id", tid);
|
|
||||||
params.put("show_type_id", extend.get("class"));
|
|
||||||
params.put("region_id", extend.get("area"));
|
|
||||||
params.put("lang_id", extend.get("lang"));
|
|
||||||
params.put("year_range", extend.get("year"));
|
|
||||||
params.put("start", String.valueOf(page * 20));
|
|
||||||
JSONObject object = new JSONObject(post(categoryUrl, params));
|
|
||||||
JSONArray array = object.getJSONArray("list");
|
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
boolean land = tid.equals("7") || tid.equals("16");
|
|
||||||
for (int i = 0; i < array.length(); i++) {
|
|
||||||
JSONObject item = array.getJSONObject(i);
|
|
||||||
String id = item.getString("showIdCode");
|
|
||||||
String name = item.getString("showTitle");
|
|
||||||
String pic = item.getString("showImg");
|
|
||||||
if (land) list.add(new Vod(id, name, getPic(pic), getRemarks(item), Vod.Style.rect(1.33f)));
|
|
||||||
else list.add(new Vod(id, name, getPic(pic), getRemarks(item)));
|
|
||||||
}
|
|
||||||
return Result.string(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String detailContent(List<String> ids) throws Exception {
|
|
||||||
Map<String, String> params = new TreeMap<>();
|
|
||||||
params.put("show_id_code", ids.get(0));
|
|
||||||
JSONObject object = new JSONObject(post(detailUrl, params));
|
|
||||||
JSONObject entity = object.getJSONObject("entity");
|
|
||||||
JSONArray plays = entity.getJSONArray("plays");
|
|
||||||
String id = entity.optString("showIdCode");
|
|
||||||
List<String> vodItems = new ArrayList<>();
|
|
||||||
for (int j = 0; j < plays.length(); j++) {
|
|
||||||
JSONObject item = plays.getJSONObject(j);
|
|
||||||
String episodeName = item.getString("episodeName");
|
|
||||||
episodeName = TextUtils.isEmpty(episodeName) ? "播放" : episodeName;
|
|
||||||
vodItems.add(episodeName + "$" + id + "_" + item.getString("playIdCode") + "_" + episodeName);
|
|
||||||
}
|
|
||||||
Vod vod = new Vod();
|
|
||||||
vod.setVodId(id);
|
|
||||||
vod.setVodName(entity.optString("showTitle"));
|
|
||||||
vod.setVodPic(getPic(entity.optString("showImg")));
|
|
||||||
vod.setVodContent(entity.optString("showDesc"));
|
|
||||||
vod.setVodDirector(convert(entity.optString("director")));
|
|
||||||
vod.setVodActor(convert(entity.optString("actors")));
|
|
||||||
vod.setVodYear(entity.optString("postYear"));
|
|
||||||
vod.setVodArea(entity.optString("regionName"));
|
|
||||||
vod.setTypeName((entity.optString("channelName")));
|
|
||||||
vod.setVodPlayUrl(TextUtils.join("#", vodItems));
|
|
||||||
vod.setVodRemarks(getRemarks(entity));
|
|
||||||
vod.setVodPlayFrom("泥巴");
|
|
||||||
return Result.string(vod);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
|
||||||
String[] ids = id.split("_");
|
|
||||||
Map<String, String> params = new TreeMap<>();
|
|
||||||
params.put("show_id_code", ids[0]);
|
|
||||||
params.put("play_id_code", ids[1]);
|
|
||||||
params.put("episode_id", ids[2]);
|
|
||||||
JSONObject object = new JSONObject(post(playUrl, params));
|
|
||||||
String url = object.getJSONObject("entity").getJSONArray("plays").getJSONObject(0).optString("playUrl");
|
|
||||||
return Result.get().url(url).header(getHeaders()).string();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String searchContent(String key, boolean quick) throws Exception {
|
|
||||||
return searchContent(key, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String searchContent(String key, boolean quick, String pg) throws Exception {
|
|
||||||
return searchContent(key, Integer.parseInt(pg) - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String searchContent(String key, int pg) throws Exception {
|
|
||||||
Map<String, String> params = new TreeMap<>();
|
|
||||||
params.put("keyword", key);
|
|
||||||
params.put("start", String.valueOf(pg * 20));
|
|
||||||
params.put("cat_id", adult ? "2" : "1");
|
|
||||||
params.put("keyword_type", "0");
|
|
||||||
JSONObject object = new JSONObject(post(searchUrl, params));
|
|
||||||
JSONArray array = object.getJSONArray("list");
|
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
for (int i = 0; i < array.length(); i++) {
|
|
||||||
JSONObject item = array.getJSONObject(i);
|
|
||||||
String id = item.getString("showIdCode");
|
|
||||||
String name = item.getString("showTitle");
|
|
||||||
String pic = item.getString("showImg");
|
|
||||||
list.add(new Vod(id, name, getPic(pic), getRemarks(item)));
|
|
||||||
}
|
|
||||||
return Result.string(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String genUrl(String url, Map<String, String> bodys) {
|
|
||||||
String randomStr = "AABBCC";
|
|
||||||
String oidTime = String.valueOf(new Date().getTime() - 10 * 60 * 1000);
|
|
||||||
String oid = encode(oidTime + "_" + randomStr);
|
|
||||||
Map<String, String> params = new TreeMap<>();
|
|
||||||
params.put("_ts", String.valueOf(new Date().getTime()));
|
|
||||||
params.put("app_version", "1.0");
|
|
||||||
params.put("platform", "3");
|
|
||||||
params.put("market_id", "web_nivod");
|
|
||||||
params.put("device_code", "web");
|
|
||||||
params.put("versioncode", "1");
|
|
||||||
params.put("oid", oid);
|
|
||||||
StringBuilder sign_query = new StringBuilder("__QUERY::");
|
|
||||||
for (Map.Entry<String, String> entry : params.entrySet()) {
|
|
||||||
if (entry.getValue().equals("")) continue;
|
|
||||||
sign_query.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
|
|
||||||
}
|
|
||||||
StringBuilder sign_body = new StringBuilder("__BODY::");
|
|
||||||
for (Map.Entry<String, String> entry : bodys.entrySet()) {
|
|
||||||
if (entry.getValue().equals("")) continue;
|
|
||||||
sign_body.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
|
|
||||||
}
|
|
||||||
String _SECRET_PREFIX = "__KEY::";
|
|
||||||
String secretKey = "2x_Give_it_a_shot";
|
|
||||||
String has = Util.MD5(sign_query + sign_body.toString() + _SECRET_PREFIX + secretKey, "UTF-8");
|
|
||||||
url += "?_ts=" + params.get("_ts") + "&app_version=" + params.get("app_version") + "&platform=" + params.get("platform") + "&market_id=" + params.get("market_id") + "&device_code=" + params.get("device_code") + "&versioncode=" + params.get("versioncode") + "&oid=" + params.get("oid") + "&sign=" + has;
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getPic(String pic) {
|
|
||||||
return pic.replace(".nivod4.", ".nivod.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getRemarks(JSONObject item) {
|
|
||||||
String remark = item.optString("episodesTxt");
|
|
||||||
remark = TextUtils.isEmpty(remark) || remark.equals("null") ? "" : remark;
|
|
||||||
return remark;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String convert(String text) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (String s : text.split(",")) if (!TextUtils.isEmpty(s)) sb.append(String.format("[a=cr:{\"id\":\"%s\",\"name\":\"%s\"}/]%s[/a]", s + "/{pg}", s, s)).append(",");
|
|
||||||
return Util.substring(sb.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private String get(String url) {
|
|
||||||
return decode(OkHttp.string(genUrl(url, new HashMap<>()), getHeaders()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String post(String url, Map<String, String> params) {
|
|
||||||
return decode(OkHttp.post(genUrl(url, params), params, getHeaders()).getBody());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("GetInstance")
|
|
||||||
private Cipher getCipher(int mode) {
|
|
||||||
try {
|
|
||||||
DESKeySpec dks = new DESKeySpec(des_key.getBytes());
|
|
||||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
|
|
||||||
Key secretKey = keyFactory.generateSecret(dks);
|
|
||||||
Cipher cipher = Cipher.getInstance("DES/ECB/PKCS7Padding");
|
|
||||||
cipher.init(mode, secretKey);
|
|
||||||
return cipher;
|
|
||||||
} catch (Exception e) {
|
|
||||||
SpiderDebug.log(e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String encode(String data) {
|
|
||||||
try {
|
|
||||||
if (data == null || data.isEmpty()) return "";
|
|
||||||
Cipher cipher = getCipher(Cipher.ENCRYPT_MODE);
|
|
||||||
if (cipher == null) return "";
|
|
||||||
byte[] byteHex = cipher.doFinal(data.getBytes("UTF-8"));
|
|
||||||
return byteToHexString(byteHex);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String decode(String data) {
|
|
||||||
try {
|
|
||||||
if (data == null || data.isEmpty()) return "";
|
|
||||||
byte[] b = hex2byte(data);
|
|
||||||
Cipher cipher = getCipher(Cipher.DECRYPT_MODE);
|
|
||||||
if (cipher == null) return "";
|
|
||||||
return new String(cipher.doFinal(b), "UTF-8");
|
|
||||||
} catch (Exception e) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String byteToHexString(byte[] bytes) {
|
|
||||||
StringBuilder sb = new StringBuilder(bytes.length);
|
|
||||||
String sTemp;
|
|
||||||
for (byte aByte : bytes) {
|
|
||||||
sTemp = Integer.toHexString(0xFF & aByte);
|
|
||||||
if (sTemp.length() < 2) sb.append(0);
|
|
||||||
sb.append(sTemp.toUpperCase());
|
|
||||||
}
|
|
||||||
return sb.toString().toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] hex2byte(String hex) throws IllegalArgumentException {
|
|
||||||
char[] arr = hex.toCharArray();
|
|
||||||
byte[] b = new byte[hex.length() / 2];
|
|
||||||
for (int i = 0, j = 0, l = hex.length(); i < l; i++, j++) {
|
|
||||||
String swap = String.valueOf(arr[i++]) + arr[i];
|
|
||||||
int byteInt = Integer.parseInt(swap, 16) & 0xFF;
|
|
||||||
b[j] = Integer.valueOf(byteInt).byteValue();
|
|
||||||
}
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,171 +0,0 @@
|
||||||
package com.github.catvod.spider;
|
|
||||||
|
|
||||||
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.Util;
|
|
||||||
|
|
||||||
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.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Ying extends Spider {
|
|
||||||
|
|
||||||
private static final String siteUrl = "https://www.iyhdmm.com";
|
|
||||||
private static final String listUrl = siteUrl + "/list/";
|
|
||||||
private static final String showUrl = siteUrl + "/showp/";
|
|
||||||
private static final String filterUrl = siteUrl + "/tpsf/js/catalog.js";
|
|
||||||
|
|
||||||
private HashMap<String, String> getHeaders() {
|
|
||||||
HashMap<String, String> headers = new HashMap<>();
|
|
||||||
headers.put("User-Agent", Util.CHROME);
|
|
||||||
return headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Filter getFilter(String[] texts) {
|
|
||||||
List<Filter.Value> values = new ArrayList<>();
|
|
||||||
for (int i = 2; i < texts.length; i++) {
|
|
||||||
if (!texts[i].isEmpty()) values.add(new Filter.Value(texts[i].trim()));
|
|
||||||
}
|
|
||||||
return new Filter(texts[0].trim(), texts[1].trim(), values);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addClasses(List<Class> classes, String[] texts) {
|
|
||||||
for (int i = 2; i < texts.length; i++) {
|
|
||||||
if (!texts[i].isEmpty()) classes.add(new Class(texts[i].trim()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkExtend(StringBuilder sb, HashMap<String, String> extend, String column) {
|
|
||||||
if (!extend.containsKey(column) || extend.get(column).equals("全部") || extend.get(column).equals("更新时间")) return;
|
|
||||||
sb.append("&").append(column).append("=").append(extend.get(column));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String homeContent(boolean filter) {
|
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
List<Class> classes = new ArrayList<>();
|
|
||||||
List<Filter> array = new ArrayList<>();
|
|
||||||
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
|
||||||
Document doc1 = Jsoup.parse(OkHttp.string(filterUrl, getHeaders()));
|
|
||||||
String[] split = doc1.text().split("_labels = ");
|
|
||||||
for (int i = 0; i < split.length; i++) {
|
|
||||||
if (split[i].startsWith("[")) {
|
|
||||||
split[i] = split[i].substring(0, split[i].indexOf(";")).replace("[", "").replace("]", "").replace("\"", "");
|
|
||||||
if (split[i].startsWith("region")) addClasses(classes, split[i].split(","));
|
|
||||||
else array.add(getFilter(split[i].split(",")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (Class type : classes) filters.put(type.getTypeId(), array);
|
|
||||||
Document doc2 = Jsoup.parse(OkHttp.string(listUrl, getHeaders()));
|
|
||||||
for (Element element : doc2.select("div.lpic > ul > li")) {
|
|
||||||
String id = element.select("a").attr("href").split("/")[2];
|
|
||||||
String name = element.select("h2").text();
|
|
||||||
String pic = element.select("a > img").attr("src");
|
|
||||||
String remarks = element.select("span > font").text();
|
|
||||||
remarks = remarks.contains(":") ? remarks.split(" ")[1] : remarks;
|
|
||||||
list.add(new Vod(id, name, pic, remarks));
|
|
||||||
}
|
|
||||||
return Result.string(classes, list, filters);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) {
|
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("?pagesize=24&pageindex=").append(Integer.parseInt(pg) - 1);
|
|
||||||
if (!tid.equals("全部")) sb.append("®ion=").append(tid);
|
|
||||||
checkExtend(sb, extend, "genre");
|
|
||||||
checkExtend(sb, extend, "letter");
|
|
||||||
checkExtend(sb, extend, "year");
|
|
||||||
checkExtend(sb, extend, "season");
|
|
||||||
checkExtend(sb, extend, "status");
|
|
||||||
checkExtend(sb, extend, "label");
|
|
||||||
checkExtend(sb, extend, "resource");
|
|
||||||
checkExtend(sb, extend, "order");
|
|
||||||
Document doc = Jsoup.parse(OkHttp.string(listUrl.concat(sb.toString()), getHeaders()));
|
|
||||||
for (Element element : doc.select("div.lpic > ul > li")) {
|
|
||||||
String id = element.select("a").attr("href").split("/")[2];
|
|
||||||
String name = element.select("h2").text();
|
|
||||||
String pic = element.select("a > img").attr("src");
|
|
||||||
String remarks = element.select("span > font").text();
|
|
||||||
remarks = remarks.contains(":") ? remarks.split(" ")[1] : remarks;
|
|
||||||
list.add(new Vod(id, name, pic, remarks));
|
|
||||||
}
|
|
||||||
return Result.string(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String detailContent(List<String> ids) {
|
|
||||||
Document doc = Jsoup.parse(OkHttp.string(showUrl.concat(ids.get(0)), getHeaders()));
|
|
||||||
String name = doc.select("div.rate > h1").text();
|
|
||||||
String pic = doc.select("div.thumb > img").attr("src");
|
|
||||||
String content = doc.select("div.info").text();
|
|
||||||
Elements element = doc.select("div.sinfo > span > a");
|
|
||||||
|
|
||||||
Vod vod = new Vod();
|
|
||||||
vod.setVodId(ids.get(0));
|
|
||||||
vod.setVodName(name);
|
|
||||||
vod.setVodPic(pic);
|
|
||||||
vod.setVodContent(content);
|
|
||||||
vod.setVodArea(element.get(1).text());
|
|
||||||
vod.setVodYear(element.get(0).text());
|
|
||||||
vod.setTypeName(element.get(2).text());
|
|
||||||
|
|
||||||
Map<String, String> sites = new LinkedHashMap<>();
|
|
||||||
Elements sources = doc.select("ul.menu0 > li");
|
|
||||||
Elements sourceList = doc.select("div.main0 > div");
|
|
||||||
for (int i = 0; i < sources.size(); i++) {
|
|
||||||
Element source = sources.get(i);
|
|
||||||
String sourceName = source.text();
|
|
||||||
Elements playList = sourceList.get(i).select("a");
|
|
||||||
List<String> vodItems = new ArrayList<>();
|
|
||||||
for (int j = 0; j < playList.size(); j++) {
|
|
||||||
Element e = playList.get(j);
|
|
||||||
vodItems.add(e.text() + "$" + e.attr("href"));
|
|
||||||
}
|
|
||||||
if (vodItems.size() > 0) {
|
|
||||||
sites.put(sourceName, TextUtils.join("#", vodItems));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sites.size() > 0) {
|
|
||||||
vod.setVodPlayFrom(TextUtils.join("$$$", sites.keySet()));
|
|
||||||
vod.setVodPlayUrl(TextUtils.join("$$$", sites.values()));
|
|
||||||
}
|
|
||||||
return Result.string(vod);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String searchContent(String key, boolean quick) {
|
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
String target = siteUrl + "/s_all?ex=1&kw=" + URLEncoder.encode(key);
|
|
||||||
Document doc = Jsoup.parse(OkHttp.string(target, getHeaders()));
|
|
||||||
for (Element element : doc.select("div.lpic > ul > li")) {
|
|
||||||
String id = element.select("a").attr("href").split("/")[2];
|
|
||||||
String name = element.select("h2").text();
|
|
||||||
String pic = element.select("a > img").attr("src");
|
|
||||||
String remarks = element.select("span > font").text();
|
|
||||||
remarks = remarks.contains(":") ? remarks.split(" ")[1] : remarks;
|
|
||||||
list.add(new Vod(id, name, pic, remarks));
|
|
||||||
}
|
|
||||||
return Result.string(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
|
||||||
return Result.get().url(siteUrl + id).parse().header(getHeaders()).string();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -23,11 +23,11 @@ import java.util.Map;
|
||||||
|
|
||||||
public class Ysj extends Spider {
|
public class Ysj extends Spider {
|
||||||
|
|
||||||
private static final String siteUrl = "https://www.lldm.net";
|
private static final String siteUrl = "https://www.dmmiku.com";
|
||||||
private static final String cateUrl = "https://www.lldm.net/index.php/vod/show";
|
private static final String cateUrl = "https://www.dmmiku.com/index.php/vod/show";
|
||||||
private static final String homeUrl = "https://www.lldm.net/index.php/vod/show/id/20.html";
|
private static final String homeUrl = "https://www.dmmiku.com/index.php/vod/show/id/20.html";
|
||||||
private static final String detailUrl = "https://www.lldm.net/index.php/vod/detail/id/";
|
private static final String detailUrl = "https://www.dmmiku.com/index.php/vod/detail/id/";
|
||||||
private static final String searchUrl = "https://www.lldm.net/index.php/vod/search.html";
|
private static final String searchUrl = "https://www.dmmiku.com/index.php/vod/search.html";
|
||||||
private static final String playUrl = "/index.php/vod/play/id/";
|
private static final String playUrl = "/index.php/vod/play/id/";
|
||||||
|
|
||||||
private HashMap<String, String> getHeaders() {
|
private HashMap<String, String> getHeaders() {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
b65fbd46a646519fea2b594f2faf4138
|
72e81d4bc7b9066aeb031998746f0e52
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue