Clean code
This commit is contained in:
parent
761c5ffcfc
commit
bb06faea9c
|
|
@ -24,7 +24,7 @@ import com.github.catvod.bean.ali.Drive;
|
||||||
import com.github.catvod.bean.ali.Item;
|
import com.github.catvod.bean.ali.Item;
|
||||||
import com.github.catvod.bean.ali.OAuth;
|
import com.github.catvod.bean.ali.OAuth;
|
||||||
import com.github.catvod.bean.ali.Preview;
|
import com.github.catvod.bean.ali.Preview;
|
||||||
import com.github.catvod.bean.ali.Res;
|
import com.github.catvod.bean.ali.Resp;
|
||||||
import com.github.catvod.bean.ali.Share;
|
import com.github.catvod.bean.ali.Share;
|
||||||
import com.github.catvod.bean.ali.User;
|
import com.github.catvod.bean.ali.User;
|
||||||
import com.github.catvod.crawler.SpiderDebug;
|
import com.github.catvod.crawler.SpiderDebug;
|
||||||
|
|
@ -401,8 +401,8 @@ public class AliYun {
|
||||||
SpiderDebug.log("Copy..." + fileId);
|
SpiderDebug.log("Copy..." + fileId);
|
||||||
String json = "{\"requests\":[{\"body\":{\"file_id\":\"%s\",\"share_id\":\"%s\",\"auto_rename\":true,\"to_parent_file_id\":\"root\",\"to_drive_id\":\"%s\"},\"headers\":{\"Content-Type\":\"application/json\"},\"id\":\"0\",\"method\":\"POST\",\"url\":\"/file/copy\"}],\"resource\":\"file\"}";
|
String json = "{\"requests\":[{\"body\":{\"file_id\":\"%s\",\"share_id\":\"%s\",\"auto_rename\":true,\"to_parent_file_id\":\"root\",\"to_drive_id\":\"%s\"},\"headers\":{\"Content-Type\":\"application/json\"},\"id\":\"0\",\"method\":\"POST\",\"url\":\"/file/copy\"}],\"resource\":\"file\"}";
|
||||||
json = String.format(json, fileId, shareId, drive.getDriveId());
|
json = String.format(json, fileId, shareId, drive.getDriveId());
|
||||||
Res res = Res.objectFrom(auth("adrive/v2/batch", json, true));
|
Resp resp = Resp.objectFrom(auth("adrive/v2/batch", json, true));
|
||||||
return res.getResponse().getBody().getFileId();
|
return resp.getResponse().getBody().getFileId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteAll() {
|
private void deleteAll() {
|
||||||
|
|
@ -417,8 +417,8 @@ public class AliYun {
|
||||||
SpiderDebug.log("Delete..." + fileId);
|
SpiderDebug.log("Delete..." + fileId);
|
||||||
String json = "{\"requests\":[{\"body\":{\"drive_id\":\"%s\",\"file_id\":\"%s\"},\"headers\":{\"Content-Type\":\"application/json\"},\"id\":\"%s\",\"method\":\"POST\",\"url\":\"/file/delete\"}],\"resource\":\"file\"}";
|
String json = "{\"requests\":[{\"body\":{\"drive_id\":\"%s\",\"file_id\":\"%s\"},\"headers\":{\"Content-Type\":\"application/json\"},\"id\":\"%s\",\"method\":\"POST\",\"url\":\"/file/delete\"}],\"resource\":\"file\"}";
|
||||||
json = String.format(json, drive.getDriveId(), fileId, fileId);
|
json = String.format(json, drive.getDriveId(), fileId, fileId);
|
||||||
Res res = Res.objectFrom(auth("adrive/v2/batch", json, true));
|
Resp resp = Resp.objectFrom(auth("adrive/v2/batch", json, true));
|
||||||
return res.getResponse().getStatus() == 404;
|
return resp.getResponse().getStatus() == 404;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] proxySub(Map<String, String> params) throws Exception {
|
public Object[] proxySub(Map<String, String> params) throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,10 @@ public class Result {
|
||||||
return Result.get().classes(classes).filters(filters).string();
|
return Result.get().classes(classes).filters(filters).string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String string(List<Class> classes, JsonElement filters) {
|
||||||
|
return Result.get().classes(classes).filters(filters).string();
|
||||||
|
}
|
||||||
|
|
||||||
public static String string(List<Class> classes, JSONObject filters) {
|
public static String string(List<Class> classes, JSONObject filters) {
|
||||||
return Result.get().classes(classes).filters(filters).string();
|
return Result.get().classes(classes).filters(filters).string();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ import com.google.gson.annotations.SerializedName;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Res {
|
public class Resp {
|
||||||
|
|
||||||
@SerializedName("responses")
|
@SerializedName("responses")
|
||||||
private List<Res> responses;
|
private List<Resp> responses;
|
||||||
@SerializedName("body")
|
@SerializedName("body")
|
||||||
private Body body;
|
private Body body;
|
||||||
@SerializedName("id")
|
@SerializedName("id")
|
||||||
|
|
@ -19,16 +19,16 @@ public class Res {
|
||||||
@SerializedName("status")
|
@SerializedName("status")
|
||||||
private int status;
|
private int status;
|
||||||
|
|
||||||
public static Res objectFrom(String str) {
|
public static Resp objectFrom(String str) {
|
||||||
return new Gson().fromJson(str, Res.class);
|
return new Gson().fromJson(str, Resp.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Res> getResponses() {
|
public List<Resp> getResponses() {
|
||||||
return responses == null ? Collections.emptyList() : responses;
|
return responses == null ? Collections.emptyList() : responses;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Res getResponse() {
|
public Resp getResponse() {
|
||||||
return getResponses().isEmpty() ? new Res() : getResponses().get(0);
|
return getResponses().isEmpty() ? new Resp() : getResponses().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Body getBody() {
|
public Body getBody() {
|
||||||
|
|
@ -0,0 +1,125 @@
|
||||||
|
package com.github.catvod.bean.jianpian;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.github.catvod.bean.Vod;
|
||||||
|
import com.github.catvod.utils.Utils;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Data {
|
||||||
|
|
||||||
|
@SerializedName(value = "jump_id", alternate = "id")
|
||||||
|
private String vodId;
|
||||||
|
@SerializedName(value = "thumbnail", alternate = "path")
|
||||||
|
private String vodPic;
|
||||||
|
@SerializedName(value = "title")
|
||||||
|
private String vodName;
|
||||||
|
@SerializedName(value = "mask")
|
||||||
|
private String vodRemark;
|
||||||
|
@SerializedName("description")
|
||||||
|
private String description;
|
||||||
|
@SerializedName(value = "playlist")
|
||||||
|
private Value playlist;
|
||||||
|
@SerializedName("year")
|
||||||
|
private Value year;
|
||||||
|
@SerializedName("area")
|
||||||
|
private Value area;
|
||||||
|
@SerializedName("types")
|
||||||
|
private List<Value> types;
|
||||||
|
@SerializedName("actors")
|
||||||
|
private List<Value> actors;
|
||||||
|
@SerializedName("directors")
|
||||||
|
private List<Value> directors;
|
||||||
|
@SerializedName("btbo_downlist")
|
||||||
|
private List<BtboDown> btboDownlist;
|
||||||
|
|
||||||
|
public String getVodId() {
|
||||||
|
return TextUtils.isEmpty(vodId) ? "" : vodId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVodPic() {
|
||||||
|
return TextUtils.isEmpty(vodPic) ? "" : vodPic + "@Referer=www.jianpianapp.com@User-Agent=jianpian-version362";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVodName() {
|
||||||
|
return TextUtils.isEmpty(vodName) ? "" : vodName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVodRemark() {
|
||||||
|
return TextUtils.isEmpty(vodRemark) ? getPlaylist() : vodRemark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return TextUtils.isEmpty(description) ? "" : description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlaylist() {
|
||||||
|
return playlist == null ? "" : playlist.getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getYear() {
|
||||||
|
return year == null ? "" : year.getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArea() {
|
||||||
|
return area == null ? "" : area.getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypes() {
|
||||||
|
if (types == null) return "";
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Value value : types) sb.append(value.getTitle()).append(" ");
|
||||||
|
return Utils.substring(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActors() {
|
||||||
|
if (actors == null) return "";
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Value value : actors) sb.append(value.getLink()).append(" ");
|
||||||
|
return Utils.substring(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDirectors() {
|
||||||
|
if (directors == null) return "";
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Value value : directors) sb.append(value.getLink()).append(" ");
|
||||||
|
return Utils.substring(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBtboDownlist() {
|
||||||
|
if (btboDownlist == null) return "";
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (BtboDown value : btboDownlist) sb.append(value.getVal()).append("#");
|
||||||
|
return Utils.substring(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vod vod() {
|
||||||
|
return new Vod(getVodId(), getVodName(), getVodPic(), getVodRemark());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Value {
|
||||||
|
|
||||||
|
@SerializedName(value = "title", alternate = "name")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return TextUtils.isEmpty(title) ? "" : title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLink() {
|
||||||
|
return String.format("[a=cr:{\"id\":\"%s\",\"name\":\"%s\"}]%s[/a]", getTitle() + "/{pg}", getTitle(), getTitle());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BtboDown {
|
||||||
|
|
||||||
|
@SerializedName("val")
|
||||||
|
private String val;
|
||||||
|
|
||||||
|
public String getVal() {
|
||||||
|
return TextUtils.isEmpty(val) ? "" : val.replaceAll("ftp", "tvbox-xg:ftp");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.github.catvod.bean.jianpian;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
public class Detail {
|
||||||
|
|
||||||
|
@SerializedName("data")
|
||||||
|
private Data data;
|
||||||
|
|
||||||
|
public static Detail objectFrom(String str) {
|
||||||
|
return new Gson().fromJson(str, Detail.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Data getData() {
|
||||||
|
return data == null ? new Data() : data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.github.catvod.bean.jianpian;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Resp {
|
||||||
|
|
||||||
|
@SerializedName("data")
|
||||||
|
private List<Data> data;
|
||||||
|
|
||||||
|
public static Resp objectFrom(String str) {
|
||||||
|
return new Gson().fromJson(str, Resp.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Data> getData() {
|
||||||
|
return data == null ? Collections.emptyList() : data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
package com.github.catvod.bean.paper;
|
|
||||||
|
|
||||||
import com.github.catvod.bean.Vod;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Data {
|
|
||||||
|
|
||||||
@SerializedName("key")
|
|
||||||
private String key;
|
|
||||||
@SerializedName("cat")
|
|
||||||
private String cat;
|
|
||||||
@SerializedName("title")
|
|
||||||
private String title;
|
|
||||||
@SerializedName("date")
|
|
||||||
private String date;
|
|
||||||
|
|
||||||
public static List<Data> arrayFrom(String str) {
|
|
||||||
Type listType = new TypeToken<List<Data>>() {}.getType();
|
|
||||||
return new Gson().fromJson(str, listType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCat() {
|
|
||||||
return cat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDate() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vod getVod() {
|
|
||||||
return new Vod("https://www.aliyundrive.com/s/" + getKey(), getTitle(), "https://www.lgstatic.com/i/image2/M01/15/7E/CgoB5lysLXCADg6ZAABapAHUnQM321.jpg", getDate());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +1,19 @@
|
||||||
package com.github.catvod.spider;
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.github.catvod.bean.Class;
|
||||||
|
import com.github.catvod.bean.Result;
|
||||||
|
import com.github.catvod.bean.Vod;
|
||||||
|
import com.github.catvod.bean.jianpian.Data;
|
||||||
|
import com.github.catvod.bean.jianpian.Detail;
|
||||||
|
import com.github.catvod.bean.jianpian.Resp;
|
||||||
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.google.gson.JsonParser;
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -16,7 +23,9 @@ import java.util.Map;
|
||||||
* Qile
|
* Qile
|
||||||
*/
|
*/
|
||||||
public class Jianpian extends Spider {
|
public class Jianpian extends Spider {
|
||||||
|
|
||||||
private final String siteUrl = "http://api2.rinhome.com";
|
private final String siteUrl = "http://api2.rinhome.com";
|
||||||
|
private String extend;
|
||||||
|
|
||||||
private Map<String, String> getHeader() {
|
private Map<String, String> getHeader() {
|
||||||
Map<String, String> headers = new HashMap<>();
|
Map<String, String> headers = new HashMap<>();
|
||||||
|
|
@ -26,155 +35,78 @@ public class Jianpian extends Spider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String homeContent(boolean filter) throws Exception {
|
public void init(Context context, String extend) throws Exception {
|
||||||
JSONArray classes = new JSONArray();
|
this.extend = extend;
|
||||||
List<String> typeIds = Arrays.asList("0", "1", "2", "3", "4");
|
|
||||||
List<String> typeNames = Arrays.asList("全部", "电影", "电视剧", "动漫", "综艺");
|
|
||||||
for (int i = 0; i < typeIds.size(); i++) {
|
|
||||||
JSONObject obj = new JSONObject()
|
|
||||||
.put("type_id", typeIds.get(i))
|
|
||||||
.put("type_name", typeNames.get(i));
|
|
||||||
classes.put(obj);
|
|
||||||
}
|
|
||||||
// filter 二级筛选
|
|
||||||
String f = "{\"0\": [{\"key\": \"year\", \"name\": \"年份\", \"value\": [{\"n\": \"全部\", \"v\": \"0\"}, {\"n\": \"2023\", \"v\": \"153\"}, {\"n\": \"2022\", \"v\": \"101\"}, {\"n\": \"2021\", \"v\": \"118\"}, {\"n\": \"2020\", \"v\": \"16\"}, {\"n\": \"2019\", \"v\": \"7\"}, {\"n\": \"2018\", \"v\": \"2\"}, {\"n\": \"2017\", \"v\": \"3\"}, {\"n\": \"2016\", \"v\": \"22\"}]}, {\"key\": \"by\", \"name\": \"排序\", \"value\": [{\"n\": \"热门\", \"v\": \"hot\"}, {\"n\": \"更新\", \"v\": \"updata\"}, {\"n\": \"评分\", \"v\": \"rating\"}]}],\"1\": [{\"key\": \"year\", \"name\": \"年份\", \"value\": [{\"n\": \"全部\", \"v\": \"0\"}, {\"n\": \"2023\", \"v\": \"153\"}, {\"n\": \"2022\", \"v\": \"101\"}, {\"n\": \"2021\", \"v\": \"118\"}, {\"n\": \"2020\", \"v\": \"16\"}, {\"n\": \"2019\", \"v\": \"7\"}, {\"n\": \"2018\", \"v\": \"2\"}, {\"n\": \"2017\", \"v\": \"3\"}, {\"n\": \"2016\", \"v\": \"22\"}]}, {\"key\": \"by\", \"name\": \"排序\", \"value\": [{\"n\": \"热门\", \"v\": \"hot\"}, {\"n\": \"更新\", \"v\": \"updata\"}, {\"n\": \"评分\", \"v\": \"rating\"}]}], \"2\": [{\"key\": \"year\", \"name\": \"年份\", \"value\": [{\"n\": \"全部\", \"v\": \"0\"}, {\"n\": \"2023\", \"v\": \"153\"}, {\"n\": \"2022\", \"v\": \"101\"}, {\"n\": \"2021\", \"v\": \"118\"}, {\"n\": \"2020\", \"v\": \"16\"}, {\"n\": \"2019\", \"v\": \"7\"}, {\"n\": \"2018\", \"v\": \"2\"}, {\"n\": \"2017\", \"v\": \"3\"}, {\"n\": \"2016\", \"v\": \"22\"}]}, {\"key\": \"by\", \"name\": \"排序\", \"value\": [{\"n\": \"热门\", \"v\": \"hot\"}, {\"n\": \"更新\", \"v\": \"updata\"}, {\"n\": \"评分\", \"v\": \"rating\"}]}],\"3\": [{\"key\": \"year\", \"name\": \"年份\", \"value\": [{\"n\": \"全部\", \"v\": \"0\"}, {\"n\": \"2023\", \"v\": \"153\"}, {\"n\": \"2022\", \"v\": \"101\"}, {\"n\": \"2021\", \"v\": \"118\"}, {\"n\": \"2020\", \"v\": \"16\"}, {\"n\": \"2019\", \"v\": \"7\"}, {\"n\": \"2018\", \"v\": \"2\"}, {\"n\": \"2017\", \"v\": \"3\"}, {\"n\": \"2016\", \"v\": \"22\"}]}, {\"key\": \"by\", \"name\": \"排序\", \"value\": [{\"n\": \"热门\", \"v\": \"hot\"}, {\"n\": \"更新\", \"v\": \"updata\"}, {\"n\": \"评分\", \"v\": \"rating\"}]}],\"4\": [{\"key\": \"year\", \"name\": \"年份\", \"value\": [{\"n\": \"全部\", \"v\": \"0\"}, {\"n\": \"2023\", \"v\": \"153\"}, {\"n\": \"2022\", \"v\": \"101\"}, {\"n\": \"2021\", \"v\": \"118\"}, {\"n\": \"2020\", \"v\": \"16\"}, {\"n\": \"2019\", \"v\": \"7\"}, {\"n\": \"2018\", \"v\": \"2\"}, {\"n\": \"2017\", \"v\": \"3\"}, {\"n\": \"2016\", \"v\": \"22\"}]}, {\"key\": \"by\", \"name\": \"排序\", \"value\": [{\"n\": \"热门\", \"v\": \"hot\"}, {\"n\": \"更新\", \"v\": \"updata\"}, {\"n\": \"评分\", \"v\": \"rating\"}]}]}";
|
|
||||||
JSONObject filterConfig = new JSONObject(f);
|
|
||||||
JSONObject result = new JSONObject()
|
|
||||||
.put("class", classes)
|
|
||||||
.put("filters", filterConfig);
|
|
||||||
return result.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String homeVideoContent() throws Exception {
|
public String homeContent(boolean filter) throws Exception {
|
||||||
|
List<Class> classes = new ArrayList<>();
|
||||||
|
List<String> typeIds = Arrays.asList("0", "1", "2", "3", "4");
|
||||||
|
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, JsonParser.parseString(OkHttp.string(extend)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String homeVideoContent() {
|
||||||
|
List<Vod> list = new ArrayList<>();
|
||||||
String url = siteUrl + "/api/slide/list?code=unknown9039b6856c3a3306&pos_id=888&channel=wandoujia";
|
String url = siteUrl + "/api/slide/list?code=unknown9039b6856c3a3306&pos_id=888&channel=wandoujia";
|
||||||
String content = OkHttp.string(url, getHeader());
|
Resp resp = Resp.objectFrom(OkHttp.string(url, getHeader()));
|
||||||
JSONObject jsonObject = new JSONObject(content);
|
for (Data data : resp.getData()) list.add(data.vod());
|
||||||
JSONArray videoArray = jsonObject.getJSONArray("data");
|
return Result.string(list);
|
||||||
JSONArray videos = new JSONArray();
|
|
||||||
for (int i = 0; i < videoArray.length(); i++) {
|
|
||||||
JSONObject blockObj = videoArray.getJSONObject(i);
|
|
||||||
videos.put(new JSONObject()
|
|
||||||
.put("vod_id", blockObj.getInt("jump_id"))
|
|
||||||
.put("vod_name", blockObj.getString("title"))
|
|
||||||
.put("vod_pic", blockObj.getString("thumbnail") + "@Referer=www.jianpianapp.com@User-Agent=jianpian-version362")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
JSONObject result = new JSONObject()
|
|
||||||
.put("list", videos);
|
|
||||||
return result.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||||
// 筛选处理
|
List<Vod> list = new ArrayList<>();
|
||||||
HashMap<String, String> ext = new HashMap<>();
|
HashMap<String, String> ext = new HashMap<>();
|
||||||
if (extend != null && extend.size() > 0) {
|
if (extend != null && extend.size() > 0) ext.putAll(extend);
|
||||||
ext.putAll(extend);
|
|
||||||
}
|
|
||||||
String cateId = ext.get("cateId") == null ? tid : ext.get("cateId");
|
String cateId = ext.get("cateId") == null ? tid : ext.get("cateId");
|
||||||
String year = ext.get("year") == null ? "0" : ext.get("year");
|
String year = ext.get("year") == null ? "0" : ext.get("year");
|
||||||
String by = ext.get("by") == null ? "hot" : ext.get("by");
|
String by = ext.get("by") == null ? "hot" : ext.get("by");
|
||||||
String url = siteUrl + String.format("/api/crumb/list?area=0&category_id=%s&page=%s&type=0&limit=24&sort=%s&year=%s", cateId, pg, by, year);
|
String url = siteUrl + String.format("/api/crumb/list?area=0&category_id=%s&page=%s&type=0&limit=24&sort=%s&year=%s", cateId, pg, by, year);
|
||||||
String content = OkHttp.string(url, getHeader());
|
Resp resp = Resp.objectFrom(OkHttp.string(url, getHeader()));
|
||||||
JSONObject jsonObject = new JSONObject(content);
|
for (Data data : resp.getData()) list.add(data.vod());
|
||||||
JSONArray dataArray = jsonObject.getJSONArray("data");
|
return Result.string(list);
|
||||||
JSONArray videos = new JSONArray();
|
|
||||||
for (int i = 0; i < dataArray.length(); i++) {
|
|
||||||
JSONObject vObj = dataArray.getJSONObject(i);
|
|
||||||
JSONObject v = new JSONObject();
|
|
||||||
JSONObject playlistObj = vObj.getJSONObject("playlist");
|
|
||||||
v.put("vod_id", vObj.getInt("id"));
|
|
||||||
v.put("vod_name", vObj.getString("title"));
|
|
||||||
v.put("vod_pic", vObj.getString("path") + "@Referer=www.jianpianapp.com@User-Agent=jianpian-version362");
|
|
||||||
v.put("vod_remarks", playlistObj.getString("title"));
|
|
||||||
videos.put(v);
|
|
||||||
}
|
|
||||||
JSONObject result = new JSONObject()
|
|
||||||
.put("page", Integer.parseInt(pg))
|
|
||||||
.put("pagecount", Integer.MAX_VALUE)
|
|
||||||
.put("limit", 24)
|
|
||||||
.put("total", Integer.MAX_VALUE)
|
|
||||||
.put("list", videos);
|
|
||||||
return result.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String detailContent(List<String> ids) throws Exception {
|
public String detailContent(List<String> ids) throws Exception {
|
||||||
String url = siteUrl + "/api/node/detail?channel=wandoujia&token=&id=" + ids.get(0);
|
String url = siteUrl + "/api/node/detail?channel=wandoujia&token=&id=" + ids.get(0);
|
||||||
String content = OkHttp.string(url, getHeader());
|
Data data = Detail.objectFrom(OkHttp.string(url, getHeader())).getData();
|
||||||
JSONObject dataObject = new JSONObject(content);
|
Vod vod = data.vod();
|
||||||
JSONObject vObj = dataObject.getJSONObject("data");
|
vod.setVodYear(data.getYear());
|
||||||
JSONObject result = new JSONObject();
|
vod.setVodArea(data.getArea());
|
||||||
JSONArray list = new JSONArray();
|
vod.setTypeName(data.getTypes());
|
||||||
JSONObject vodAtom = new JSONObject();
|
vod.setVodActor(data.getActors());
|
||||||
vodAtom.put("vod_id", vObj.getInt("id"));
|
vod.setVodDirector(data.getDirectors());
|
||||||
vodAtom.put("vod_name", vObj.getString("title"));
|
vod.setVodContent(data.getDescription());
|
||||||
vodAtom.put("vod_pic", vObj.getString("thumbnail") + "@Referer=www.jianpianapp.com@User-Agent=jianpian-version362");
|
vod.setVodPlayUrl(data.getBtboDownlist());
|
||||||
vodAtom.put("type_name", vObj.getJSONArray("types").getJSONObject(0).getString("name"));
|
vod.setVodPlayFrom("荐片");
|
||||||
vodAtom.put("vod_year", vObj.getJSONObject("year").getString("title"));
|
return Result.string(vod);
|
||||||
vodAtom.put("vod_area", vObj.getJSONObject("area").getString("title"));
|
|
||||||
vodAtom.put("vod_remarks", vObj.getString("mask"));
|
|
||||||
vodAtom.put("vod_director", vObj.getJSONArray("directors").getJSONObject(0).getString("name"));
|
|
||||||
vodAtom.put("vod_content", vObj.getString("description").trim());
|
|
||||||
|
|
||||||
JSONArray actorsArray = vObj.getJSONArray("actors");
|
|
||||||
StringBuilder vod_actor = new StringBuilder();
|
|
||||||
for (int i = 0; i < actorsArray.length(); i++) {
|
|
||||||
JSONObject actorObj = actorsArray.getJSONObject(i);
|
|
||||||
String actorName = actorObj.getString("name");
|
|
||||||
if (i > 0) {
|
|
||||||
vod_actor.append(" ");
|
|
||||||
}
|
|
||||||
vod_actor.append(actorName);
|
|
||||||
}
|
|
||||||
vodAtom.put("vod_actor", vod_actor.toString());
|
|
||||||
|
|
||||||
JSONArray dataArray = vObj.getJSONArray("btbo_downlist");
|
|
||||||
StringBuilder vod_play_url = new StringBuilder();
|
|
||||||
for (int i = 0; i < dataArray.length(); i++) {
|
|
||||||
JSONObject listObj = dataArray.getJSONObject(i);
|
|
||||||
String vod_play_urls = listObj.getString("val").replaceAll("ftp", "tvbox-xg:ftp");
|
|
||||||
if (i > 0) {
|
|
||||||
vod_play_url.append("#");
|
|
||||||
}
|
|
||||||
vod_play_url.append(vod_play_urls);
|
|
||||||
}
|
|
||||||
vodAtom.put("vod_play_url", vod_play_url.toString());
|
|
||||||
vodAtom.put("vod_play_from", "边下边播");
|
|
||||||
list.put(vodAtom);
|
|
||||||
result.put("list", list);
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String searchContent(String key, boolean quick) throws Exception {
|
|
||||||
String url = siteUrl + "/api/video/search?page=1&key=" + URLEncoder.encode(key);
|
|
||||||
String content = OkHttp.string(url, getHeader());
|
|
||||||
JSONObject jsonObject = new JSONObject(content);
|
|
||||||
JSONArray dataArray = jsonObject.getJSONArray("data");
|
|
||||||
JSONArray videos = new JSONArray();
|
|
||||||
for (int i = 0; i < dataArray.length(); i++) {
|
|
||||||
JSONObject vObj = dataArray.getJSONObject(i);
|
|
||||||
JSONObject v = new JSONObject();
|
|
||||||
v.put("vod_id", vObj.getInt("id"));
|
|
||||||
v.put("vod_name", vObj.getString("title"));
|
|
||||||
v.put("vod_pic", vObj.getString("thumbnail") + "@Referer=www.jianpianapp.com@User-Agent=jianpian-version362");
|
|
||||||
v.put("vod_remarks", vObj.getString("mask"));
|
|
||||||
videos.put(v);
|
|
||||||
}
|
|
||||||
JSONObject result = new JSONObject();
|
|
||||||
result.put("list", videos);
|
|
||||||
return result.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||||
JSONObject result = new JSONObject()
|
return Result.get().url(id).header(getHeader()).string();
|
||||||
.put("parse", 0)
|
}
|
||||||
.put("header", getHeader())
|
|
||||||
.put("playUrl", "")
|
@Override
|
||||||
.put("url", id);
|
public String searchContent(String key, boolean quick) throws Exception {
|
||||||
return result.toString();
|
return searchContent(key, "1");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String searchContent(String key, boolean quick, String pg) throws Exception {
|
||||||
|
return searchContent(key, pg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String searchContent(String key, String pg) throws Exception {
|
||||||
|
List<Vod> list = new ArrayList<>();
|
||||||
|
String url = siteUrl + "/api/video/search?page=" + pg + "&key=" + URLEncoder.encode(key);
|
||||||
|
Resp resp = Resp.objectFrom(OkHttp.string(url, getHeader()));
|
||||||
|
for (Data data : resp.getData()) list.add(data.vod());
|
||||||
|
return Result.string(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue