Clean code

This commit is contained in:
FongMi 2023-10-16 15:05:16 +08:00
parent cae3e20af7
commit 033032e783
3 changed files with 35 additions and 20 deletions

View File

@ -6,6 +6,7 @@ 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 {
@ -33,7 +34,7 @@ public class Data {
@SerializedName("directors") @SerializedName("directors")
private List<Value> directors; private List<Value> directors;
@SerializedName("btbo_downlist") @SerializedName("btbo_downlist")
private List<Value> btboDownlist; private List<BtboDown> btboDownlist;
public String getJumpId() { public String getJumpId() {
return TextUtils.isEmpty(jumpId) ? "" : jumpId; return TextUtils.isEmpty(jumpId) ? "" : jumpId;
@ -56,60 +57,74 @@ public class Data {
} }
public String getPlaylist() { public String getPlaylist() {
return playlist == null ? "" : playlist.getValue(); return playlist == null ? "" : playlist.getTitle();
} }
public String getYear() { public String getYear() {
return year == null ? "" : year.getValue(); return year == null ? "" : year.getTitle();
} }
public String getArea() { public String getArea() {
return area == null ? "" : area.getValue(); return area == null ? "" : area.getTitle();
} }
public String getTypes() { public String getTypes() {
return types == null ? "" : getValues(types, false, " "); return types == null ? "" : getValues(types, false);
} }
public String getActors() { public String getActors() {
return actors == null ? "" : getValues(actors, true, " "); return actors == null ? "" : getValues(actors, true);
} }
public String getDirectors() { public String getDirectors() {
return directors == null ? "" : getValues(directors, true, " "); return directors == null ? "" : getValues(directors, true);
} }
public String getPlayUrl() { public List<BtboDown> getBtboDownlist() {
return btboDownlist == null ? "" : getValues(btboDownlist, false, "#"); return btboDownlist == null ? Collections.emptyList() : btboDownlist;
} }
public Vod vod() { public Vod vod() {
return new Vod(getJumpId(), getTitle(), getThumbnail(), getMask()); return new Vod(getJumpId(), getTitle(), getThumbnail(), getMask());
} }
public String getValues(List<Value> items, boolean link, String join) { public String getValues(List<Value> items, boolean link) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (Value value : items) sb.append(value.getValue(link)).append(join); for (Value value : items) sb.append(value.getValue(link)).append(" ");
return Utils.substring(sb.toString());
}
public String getPlayUrl() {
StringBuilder sb = new StringBuilder();
for (BtboDown value : getBtboDownlist()) sb.append(value.getVal()).append("#");
return Utils.substring(sb.toString()); return Utils.substring(sb.toString());
} }
public static class Value { public static class Value {
@SerializedName(value = "val", alternate = {"name", "title"}) @SerializedName(value = "title", alternate = "name")
private String value; private String title;
private String getValue() { private String getTitle() {
if (TextUtils.isEmpty(value)) return ""; return TextUtils.isEmpty(title) ? "" : title;
if (value.startsWith("ftp://")) return "tvbox-xg:" + value;
return value;
} }
private String getLink() { private String getLink() {
return String.format("[a=cr:{\"id\":\"%s\",\"name\":\"%s\"}/]%s[/a]", getValue() + "/{pg}", getValue(), getValue()); return String.format("[a=cr:{\"id\":\"%s\",\"name\":\"%s\"}/]%s[/a]", getTitle() + "/{pg}", getTitle(), getTitle());
} }
public String getValue(boolean link) { public String getValue(boolean link) {
return link ? getLink() : getValue(); return link ? getLink() : getTitle();
}
}
public static class BtboDown {
@SerializedName("val")
private String val;
public String getVal() {
return TextUtils.isEmpty(val) ? "" : val.replaceAll("ftp", "tvbox-xg:ftp");
} }
} }
} }

Binary file not shown.

View File

@ -1 +1 @@
6e09ca5f0d30c65076c316b3260deafd 0ab694ef35e6ea075b7a85287cd17931