Clean code
This commit is contained in:
parent
f48e1d2a0c
commit
5cf47666bd
|
|
@ -48,6 +48,7 @@ public class Data {
|
||||||
public JsonElement getResult() {
|
public JsonElement getResult() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonElement getList() {
|
public JsonElement getList() {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import com.github.catvod.utils.QRCode;
|
||||||
import com.github.catvod.utils.Utils;
|
import com.github.catvod.utils.Utils;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
|
@ -109,15 +110,9 @@ public class Bili extends Spider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String homeContent(boolean filter) throws Exception {
|
public String homeContent(boolean filter) throws Exception {
|
||||||
|
if (extend.has("json")) return OkHttp.string(extend.get("json").getAsString());
|
||||||
List<Class> classes = new ArrayList<>();
|
List<Class> classes = new ArrayList<>();
|
||||||
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
||||||
JSONObject jSONObject = new JSONObject();
|
|
||||||
if (extend.has("json")) {
|
|
||||||
JSONObject json = new JSONObject(OkHttp.string(extend.get("json").getAsString()));
|
|
||||||
jSONObject.put("class", json.getJSONArray("classes"));
|
|
||||||
jSONObject.put("filters", json.getJSONObject("filter"));
|
|
||||||
return jSONObject.toString();
|
|
||||||
}
|
|
||||||
String[] types = extend.get("type").getAsString().split("#");
|
String[] types = extend.get("type").getAsString().split("#");
|
||||||
for (String type : types) {
|
for (String type : types) {
|
||||||
classes.add(new Class(type));
|
classes.add(new Class(type));
|
||||||
|
|
@ -187,7 +182,6 @@ public class Bili extends Spider {
|
||||||
}
|
}
|
||||||
vod_play.put("相关推荐", TextUtils.join("#", playList));
|
vod_play.put("相关推荐", TextUtils.join("#", playList));
|
||||||
|
|
||||||
|
|
||||||
vod.setVodPlayFrom(TextUtils.join("$$$", vod_play.keySet()));
|
vod.setVodPlayFrom(TextUtils.join("$$$", vod_play.keySet()));
|
||||||
vod.setVodPlayUrl(TextUtils.join("$$$", vod_play.values()));
|
vod.setVodPlayUrl(TextUtils.join("$$$", vod_play.values()));
|
||||||
return Result.string(vod);
|
return Result.string(vod);
|
||||||
|
|
@ -259,35 +253,11 @@ public class Bili extends Spider {
|
||||||
String id = media.getId() + "_" + media.getCodecId();
|
String id = media.getId() + "_" + media.getCodecId();
|
||||||
String type = media.getMimeType().split("/")[0];
|
String type = media.getMimeType().split("/")[0];
|
||||||
String baseUrl = media.getBaseUrl().replace("&", "&");
|
String baseUrl = media.getBaseUrl().replace("&", "&");
|
||||||
return String.format(Locale.getDefault(),
|
return String.format(Locale.getDefault(), "<AdaptationSet>\n" + "<ContentComponent contentType=\"%s\"/>\n" + "<Representation id=\"%s\" bandwidth=\"%s\" codecs=\"%s\" mimeType=\"%s\" %s startWithSAP=\"%s\">\n" + "<BaseURL>%s</BaseURL>\n" + "<SegmentBase indexRange=\"%s\">\n" + "<Initialization range=\"%s\"/>\n" + "</SegmentBase>\n" + "</Representation>\n" + "</AdaptationSet>", type, id, media.getBandWidth(), media.getCodecs(), media.getMimeType(), params, media.getStartWithSap(), baseUrl, media.getSegmentBase().getIndexRange(), media.getSegmentBase().getInitialization());
|
||||||
"<AdaptationSet>\n" +
|
|
||||||
"<ContentComponent contentType=\"%s\"/>\n" +
|
|
||||||
"<Representation id=\"%s\" bandwidth=\"%s\" codecs=\"%s\" mimeType=\"%s\" %s startWithSAP=\"%s\">\n" +
|
|
||||||
"<BaseURL>%s</BaseURL>\n" +
|
|
||||||
"<SegmentBase indexRange=\"%s\">\n" +
|
|
||||||
"<Initialization range=\"%s\"/>\n" +
|
|
||||||
"</SegmentBase>\n" +
|
|
||||||
"</Representation>\n" +
|
|
||||||
"</AdaptationSet>",
|
|
||||||
type,
|
|
||||||
id, media.getBandWidth(), media.getCodecs(), media.getMimeType(), params, media.getStartWithSap(),
|
|
||||||
baseUrl,
|
|
||||||
media.getSegmentBase().getIndexRange(),
|
|
||||||
media.getSegmentBase().getInitialization());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMpd(Dash dash, String videoList, String audioList) {
|
private String getMpd(Dash dash, String videoList, String audioList) {
|
||||||
return String.format(Locale.getDefault(),
|
return String.format(Locale.getDefault(), "<MPD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:mpeg:dash:schema:mpd:2011\" xsi:schemaLocation=\"urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd\" type=\"static\" mediaPresentationDuration=\"PT%sS\" minBufferTime=\"PT%sS\" profiles=\"urn:mpeg:dash:profile:isoff-on-demand:2011\">\n" + "<Period duration=\"PT%sS\" start=\"PT0S\">\n" + "%s\n" + "%s\n" + "</Period>\n" + "</MPD>", dash.getDuration(), dash.getMinBufferTime(), dash.getDuration(), videoList, audioList);
|
||||||
"<MPD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:mpeg:dash:schema:mpd:2011\" xsi:schemaLocation=\"urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd\" type=\"static\" mediaPresentationDuration=\"PT%sS\" minBufferTime=\"PT%sS\" profiles=\"urn:mpeg:dash:profile:isoff-on-demand:2011\">\n" +
|
|
||||||
"<Period duration=\"PT%sS\" start=\"PT0S\">\n" +
|
|
||||||
"%s\n" +
|
|
||||||
"%s\n" +
|
|
||||||
"</Period>\n" +
|
|
||||||
"</MPD>",
|
|
||||||
dash.getDuration(), dash.getMinBufferTime(),
|
|
||||||
dash.getDuration(),
|
|
||||||
videoList,
|
|
||||||
audioList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkLogin() {
|
private void checkLogin() {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
1de1a94d0429f343a35986ef5e9145d6
|
1763b7d2459b598d1ccb6a10b0e81b73
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue