Clean code
This commit is contained in:
parent
bb06faea9c
commit
4f34fb8414
|
|
@ -211,6 +211,6 @@ public class Result {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new Gson().toJson(this);
|
return new Gson().newBuilder().disableHtmlEscaping().create().toJson(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,21 +6,22 @@ import com.github.catvod.bean.Vod;
|
||||||
import com.github.catvod.utils.Utils;
|
import com.github.catvod.utils.Utils;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Data {
|
public class Data {
|
||||||
|
|
||||||
@SerializedName(value = "jump_id", alternate = "id")
|
@SerializedName(value = "jump_id", alternate = "id")
|
||||||
private String vodId;
|
private String jumpId;
|
||||||
@SerializedName(value = "thumbnail", alternate = "path")
|
@SerializedName(value = "thumbnail", alternate = "path")
|
||||||
private String vodPic;
|
private String thumbnail;
|
||||||
@SerializedName(value = "title")
|
@SerializedName("title")
|
||||||
private String vodName;
|
private String title;
|
||||||
@SerializedName(value = "mask")
|
@SerializedName("mask")
|
||||||
private String vodRemark;
|
private String mask;
|
||||||
@SerializedName("description")
|
@SerializedName("description")
|
||||||
private String description;
|
private String description;
|
||||||
@SerializedName(value = "playlist")
|
@SerializedName("playlist")
|
||||||
private Value playlist;
|
private Value playlist;
|
||||||
@SerializedName("year")
|
@SerializedName("year")
|
||||||
private Value year;
|
private Value year;
|
||||||
|
|
@ -35,20 +36,20 @@ public class Data {
|
||||||
@SerializedName("btbo_downlist")
|
@SerializedName("btbo_downlist")
|
||||||
private List<BtboDown> btboDownlist;
|
private List<BtboDown> btboDownlist;
|
||||||
|
|
||||||
public String getVodId() {
|
public String getJumpId() {
|
||||||
return TextUtils.isEmpty(vodId) ? "" : vodId;
|
return TextUtils.isEmpty(jumpId) ? "" : jumpId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVodPic() {
|
public String getThumbnail() {
|
||||||
return TextUtils.isEmpty(vodPic) ? "" : vodPic + "@Referer=www.jianpianapp.com@User-Agent=jianpian-version362";
|
return TextUtils.isEmpty(thumbnail) ? "" : thumbnail + "@Referer=www.jianpianapp.com@User-Agent=jianpian-version362";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVodName() {
|
public String getTitle() {
|
||||||
return TextUtils.isEmpty(vodName) ? "" : vodName;
|
return TextUtils.isEmpty(title) ? "" : title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVodRemark() {
|
public String getMask() {
|
||||||
return TextUtils.isEmpty(vodRemark) ? getPlaylist() : vodRemark;
|
return TextUtils.isEmpty(mask) ? getPlaylist() : mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
|
@ -68,35 +69,35 @@ public class Data {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypes() {
|
public String getTypes() {
|
||||||
if (types == null) return "";
|
return types == null ? "" : getValues(types);
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (Value value : types) sb.append(value.getTitle()).append(" ");
|
|
||||||
return Utils.substring(sb.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getActors() {
|
public String getActors() {
|
||||||
if (actors == null) return "";
|
return actors == null ? "" : getValues(actors);
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (Value value : actors) sb.append(value.getLink()).append(" ");
|
|
||||||
return Utils.substring(sb.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDirectors() {
|
public String getDirectors() {
|
||||||
if (directors == null) return "";
|
return directors == null ? "" : getValues(directors);
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (Value value : directors) sb.append(value.getLink()).append(" ");
|
|
||||||
return Utils.substring(sb.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBtboDownlist() {
|
public List<BtboDown> getBtboDownlist() {
|
||||||
if (btboDownlist == null) return "";
|
return btboDownlist == null ? Collections.emptyList() : btboDownlist;
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (BtboDown value : btboDownlist) sb.append(value.getVal()).append("#");
|
|
||||||
return Utils.substring(sb.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vod vod() {
|
public Vod vod() {
|
||||||
return new Vod(getVodId(), getVodName(), getVodPic(), getVodRemark());
|
return new Vod(getJumpId(), getTitle(), getThumbnail(), getMask());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlayUrl() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (BtboDown value : getBtboDownlist()) sb.append(value.getVal()).append("#");
|
||||||
|
return Utils.substring(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValues(List<Value> items) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Value value : items) sb.append(value.getLink()).append(" ");
|
||||||
|
return Utils.substring(sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Value {
|
public static class Value {
|
||||||
|
|
@ -109,7 +110,7 @@ public class Data {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLink() {
|
public String getLink() {
|
||||||
return String.format("[a=cr:{\"id\":\"%s\",\"name\":\"%s\"}]%s[/a]", getTitle() + "/{pg}", getTitle(), getTitle());
|
return String.format("[a=cr:{\"id\":\"%s\",\"name\":\"%s\"}/]%s[/a]", getTitle() + "/{pg}", getTitle(), getTitle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,16 +59,21 @@ public class Jianpian extends Spider {
|
||||||
|
|
||||||
@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<>();
|
if (tid.endsWith("/{pg}")) {
|
||||||
HashMap<String, String> ext = new HashMap<>();
|
String[] splits = tid.split("/");
|
||||||
if (extend != null && extend.size() > 0) ext.putAll(extend);
|
return searchContent(splits[0], pg);
|
||||||
String cateId = ext.get("cateId") == null ? tid : ext.get("cateId");
|
} else {
|
||||||
String year = ext.get("year") == null ? "0" : ext.get("year");
|
List<Vod> list = new ArrayList<>();
|
||||||
String by = ext.get("by") == null ? "hot" : ext.get("by");
|
HashMap<String, String> ext = new HashMap<>();
|
||||||
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);
|
if (extend != null && extend.size() > 0) ext.putAll(extend);
|
||||||
Resp resp = Resp.objectFrom(OkHttp.string(url, getHeader()));
|
String cateId = ext.get("cateId") == null ? tid : ext.get("cateId");
|
||||||
for (Data data : resp.getData()) list.add(data.vod());
|
String year = ext.get("year") == null ? "0" : ext.get("year");
|
||||||
return Result.string(list);
|
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);
|
||||||
|
Resp resp = Resp.objectFrom(OkHttp.string(url, getHeader()));
|
||||||
|
for (Data data : resp.getData()) list.add(data.vod());
|
||||||
|
return Result.string(list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -76,14 +81,14 @@ public class Jianpian extends Spider {
|
||||||
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);
|
||||||
Data data = Detail.objectFrom(OkHttp.string(url, getHeader())).getData();
|
Data data = Detail.objectFrom(OkHttp.string(url, getHeader())).getData();
|
||||||
Vod vod = data.vod();
|
Vod vod = data.vod();
|
||||||
|
vod.setVodPlayFrom("Jianpian");
|
||||||
vod.setVodYear(data.getYear());
|
vod.setVodYear(data.getYear());
|
||||||
vod.setVodArea(data.getArea());
|
vod.setVodArea(data.getArea());
|
||||||
vod.setTypeName(data.getTypes());
|
vod.setTypeName(data.getTypes());
|
||||||
vod.setVodActor(data.getActors());
|
vod.setVodActor(data.getActors());
|
||||||
|
vod.setVodPlayUrl(data.getPlayUrl());
|
||||||
vod.setVodDirector(data.getDirectors());
|
vod.setVodDirector(data.getDirectors());
|
||||||
vod.setVodContent(data.getDescription());
|
vod.setVodContent(data.getDescription());
|
||||||
vod.setVodPlayUrl(data.getBtboDownlist());
|
|
||||||
vod.setVodPlayFrom("荐片");
|
|
||||||
return Result.string(vod);
|
return Result.string(vod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
badfd75846df45e8cf06b53654312ccf
|
3373bc113deec1bad88de323923dbe4f
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue