Clean code
This commit is contained in:
parent
e9a8bb9f90
commit
5ce8752c28
|
|
@ -8,125 +8,90 @@ import com.github.catvod.bean.Result;
|
||||||
import com.github.catvod.bean.Vod;
|
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.net.OkHttp;
|
||||||
|
import com.github.catvod.utils.Util;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
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 org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author leospring
|
* @author leospring
|
||||||
* 星牙短剧
|
* 星牙短剧
|
||||||
*/
|
*/
|
||||||
public class AppXY extends Spider {
|
public class AppXY extends Spider {
|
||||||
private static String auth = "";
|
|
||||||
|
private String auth;
|
||||||
|
|
||||||
private Map<String, String> getHeader() {
|
private Map<String, String> getHeader() {
|
||||||
Map<String, String> hashMap = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
hashMap.put("User-Agent", "okhttp/4.10.0");
|
map.put("User-Agent", "okhttp/4.10.0");
|
||||||
if (!TextUtils.isEmpty(auth)) {
|
if (!TextUtils.isEmpty(auth)) map.put("Authorization", auth);
|
||||||
hashMap.put("Authorization", auth);
|
return map;
|
||||||
}
|
|
||||||
return hashMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
@Override
|
||||||
List<Vod> videos = new ArrayList<>();
|
public void init(Context context, String extend) throws Exception {
|
||||||
try {
|
String s = System.currentTimeMillis() + "";
|
||||||
String class2Id = extend.get("class2_id");
|
Map<String, String> map = new HashMap<>();
|
||||||
if(class2Id == null) class2Id = "0";
|
map.put("device", Util.MD5(s));
|
||||||
JSONArray jsonArray = new JSONObject(OkHttp.string(("https://app.whjzjx.cn/cloud/v2/theater/home_page?theater_class_id=" + tid + "&class2_ids=" + class2Id + "&type=1&page_num=" + pg + "&page_size=24"), getHeader())).optJSONObject("data").optJSONArray("list");
|
map.put("install_first_open", "true");
|
||||||
for(int v = 0; v < jsonArray.length(); ++v) {
|
map.put("first_install_time", s);
|
||||||
JSONObject jSONObject0 = jsonArray.optJSONObject(v).optJSONObject("theater");
|
map.put("last_update_time", s);
|
||||||
videos.add(new Vod(jSONObject0.optString("id"), jSONObject0.optString("title"), jSONObject0.optString("cover_url"), jSONObject0.optString("total") + "集"));
|
auth = new JSONObject(OkHttp.post("https://app.whjzjx.cn/v1/account/login", map, getHeader()).getBody()).optJSONObject("data").optString("token");
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
}
|
|
||||||
return Result.string(videos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String detailContent(List<String> ids) throws Exception {
|
@Override
|
||||||
Vod vod = new Vod();
|
public String homeContent(boolean filter) throws Exception {
|
||||||
try {
|
|
||||||
JSONObject json = new JSONObject(OkHttp.string(("https://app.whjzjx.cn/v2/theater_parent/detail?theater_parent_id=" + ids.get(0)), getHeader())).optJSONObject("data");
|
|
||||||
vod.setVodId(ids.get(0));
|
|
||||||
vod.setVodName(json.optString("title"));
|
|
||||||
vod.setVodPic(json.optString("cover_url"));
|
|
||||||
vod.setTypeName(json.optJSONArray("desc_tags").toString());
|
|
||||||
vod.setVodContent(json.optString("introduction"));
|
|
||||||
ArrayList<String> playUrls = new ArrayList<>();
|
|
||||||
ArrayList<String> playFroms = new ArrayList<>();
|
|
||||||
playFroms.add("leospring");
|
|
||||||
JSONArray jsonArray = json.optJSONArray("theaters");
|
|
||||||
ArrayList<String> urlNames = new ArrayList<>();
|
|
||||||
for(int v = 0; v < jsonArray.length(); ++v) {
|
|
||||||
JSONObject item = jsonArray.optJSONObject(v);
|
|
||||||
urlNames.add(item.optString("num") + "$" + item.optString("son_video_url"));
|
|
||||||
}
|
|
||||||
|
|
||||||
playUrls.add(TextUtils.join("#", urlNames));
|
|
||||||
vod.setVodPlayFrom(TextUtils.join("$$$", playFroms));
|
|
||||||
vod.setVodPlayUrl(TextUtils.join("$$$", playUrls));
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result.string(vod);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String homeContent(boolean z) throws Exception {
|
|
||||||
ArrayList<Class> classes = new ArrayList<>();
|
ArrayList<Class> classes = new ArrayList<>();
|
||||||
try {
|
JSONArray array = new JSONObject(OkHttp.string("https://app.whjzjx.cn/cloud/v2/theater/classes", getHeader())).optJSONObject("data").optJSONArray("list");
|
||||||
JSONArray jSONArray0 = new JSONObject(OkHttp.string("https://app.whjzjx.cn/cloud/v2/theater/classes", getHeader())).optJSONObject("data").optJSONArray("list");
|
for (int i = 0; i < array.length(); ++i) {
|
||||||
for(int v = 0; v < jSONArray0.length(); ++v) {
|
JSONObject object = array.optJSONObject(i);
|
||||||
JSONObject jSONObject0 = jSONArray0.optJSONObject(v);
|
if (!object.optString("show_type").contains("Bookstore")) {
|
||||||
if(!jSONObject0.optString("show_type").contains("Bookstore")) {
|
classes.add(new Class(object.optString("id"), object.optString("class_name")));
|
||||||
classes.add(new Class(jSONObject0.optString("id"), jSONObject0.optString("class_name"), null));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch(Exception unused_ex) {
|
|
||||||
}
|
|
||||||
return Result.string(classes, new ArrayList<>());
|
return Result.string(classes, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(Context context0, String s) throws Exception {
|
@Override
|
||||||
this.login();
|
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||||
|
List<Vod> videos = new ArrayList<>();
|
||||||
|
String class2Id = extend.get("class2_id");
|
||||||
|
if (class2Id == null) class2Id = "0";
|
||||||
|
JSONArray array = new JSONObject(OkHttp.string(("https://app.whjzjx.cn/cloud/v2/theater/home_page?theater_class_id=" + tid + "&class2_ids=" + class2Id + "&type=1&page_num=" + pg + "&page_size=24"), getHeader())).optJSONObject("data").optJSONArray("list");
|
||||||
|
for (int v = 0; v < array.length(); ++v) {
|
||||||
|
JSONObject object = array.optJSONObject(v).optJSONObject("theater");
|
||||||
|
videos.add(new Vod(object.optString("id"), object.optString("title"), object.optString("cover_url"), object.optString("total") + "集"));
|
||||||
|
}
|
||||||
|
return Result.string(videos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean login() {
|
@Override
|
||||||
try {
|
public String detailContent(List<String> ids) throws Exception {
|
||||||
String s = System.currentTimeMillis() + "";
|
Vod vod = new Vod();
|
||||||
Map<String, String> map = new HashMap<>();
|
JSONObject object = new JSONObject(OkHttp.string(("https://app.whjzjx.cn/v2/theater_parent/detail?theater_parent_id=" + ids.get(0)), getHeader())).optJSONObject("data");
|
||||||
map.put("device", getDeviceId(s));
|
vod.setVodId(ids.get(0));
|
||||||
map.put("install_first_open", "true");
|
vod.setVodName(object.optString("title"));
|
||||||
map.put("first_install_time", s);
|
vod.setVodPic(object.optString("cover_url"));
|
||||||
map.put("last_update_time", s);
|
vod.setTypeName(object.optJSONArray("desc_tags").toString());
|
||||||
String s1 = new JSONObject(OkHttp.post("https://app.whjzjx.cn/v1/account/login", map, getHeader()).getBody()).optJSONObject("data").optString("token");
|
vod.setVodContent(object.optString("introduction"));
|
||||||
auth = s1;
|
ArrayList<String> playUrls = new ArrayList<>();
|
||||||
return !TextUtils.isEmpty(s1);
|
ArrayList<String> playFrom = new ArrayList<>();
|
||||||
}
|
playFrom.add("leospring");
|
||||||
catch(Exception e) {
|
JSONArray array = object.optJSONArray("theaters");
|
||||||
return false;
|
ArrayList<String> urlNames = new ArrayList<>();
|
||||||
}
|
for (int i = 0; i < array.length(); ++i) {
|
||||||
}
|
object = array.optJSONObject(i);
|
||||||
|
urlNames.add(object.optString("num") + "$" + object.optString("son_video_url"));
|
||||||
public static String getDeviceId(String s) {
|
|
||||||
try {
|
|
||||||
StringBuilder sb = new StringBuilder(new BigInteger(1, MessageDigest.getInstance("MD5").digest(s.getBytes("UTF-8"))).toString(16));
|
|
||||||
while(sb.length() < 0x20) {
|
|
||||||
sb.insert(0, "0");
|
|
||||||
}
|
|
||||||
return sb.toString().toLowerCase();
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
playUrls.add(TextUtils.join("#", urlNames));
|
||||||
|
vod.setVodPlayFrom(TextUtils.join("$$$", playFrom));
|
||||||
|
vod.setVodPlayUrl(TextUtils.join("$$$", playUrls));
|
||||||
|
return Result.string(vod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -137,14 +102,11 @@ public class AppXY 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<>();
|
||||||
new JSONObject().put("text", key);
|
JSONArray array = new JSONObject(OkHttp.post("https://app.whjzjx.cn/v3/search", new JSONObject().put("text", key).toString(), getHeader()).getBody()).optJSONObject("data").optJSONObject("theater").optJSONArray("search_data");
|
||||||
JSONArray jsonArray = new JSONObject(OkHttp.post("https://app.whjzjx.cn/v3/search", new JSONObject().put("text", key).toString(), getHeader()).getBody()).optJSONObject("data").optJSONObject("theater").optJSONArray("search_data");
|
for (int i = 0; i < array.length(); ++i) {
|
||||||
for(int v = 0; v < jsonArray.length(); ++v) {
|
JSONObject object = array.optJSONObject(i);
|
||||||
JSONObject jSONObject0 = jsonArray.optJSONObject(v);
|
list.add(new Vod(object.optString("id"), object.optString("title"), object.optString("cover_url"), object.optString("score_str")));
|
||||||
list.add(new Vod(jSONObject0.optString("id"), jSONObject0.optString("title"), jSONObject0.optString("cover_url"), jSONObject0.optString("score_str")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.string(list);
|
return Result.string(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
101bd3f495cfb4cb4b3603d85d1647ea
|
eab090fc69cefc04e98e917efcd4b2db
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue