Merge branch 'main' of https://github.com/FongMi/CatVodSpider
This commit is contained in:
commit
4650058343
|
|
@ -17,7 +17,12 @@ import com.github.catvod.BuildConfig;
|
|||
import com.github.catvod.bean.Result;
|
||||
import com.github.catvod.bean.Sub;
|
||||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.bean.ali.*;
|
||||
import com.github.catvod.bean.ali.Code;
|
||||
import com.github.catvod.bean.ali.Data;
|
||||
import com.github.catvod.bean.ali.Drive;
|
||||
import com.github.catvod.bean.ali.Item;
|
||||
import com.github.catvod.bean.ali.OAuth;
|
||||
import com.github.catvod.bean.ali.User;
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.net.OkResult;
|
||||
|
|
@ -412,7 +417,7 @@ public class API {
|
|||
private String getPreviewContent(String[] ids) {
|
||||
try {
|
||||
JSONObject playInfo = getVideoPreviewPlayInfo(ids[0]);
|
||||
String url = getPreviewUrl(playInfo);
|
||||
List<String> url = getPreviewUrl(playInfo);
|
||||
List<Sub> subs = getSubs(ids);
|
||||
subs.addAll(getSubs(playInfo));
|
||||
return Result.get().url(url).m3u8().subs(subs).header(getHeader()).string();
|
||||
|
|
@ -422,19 +427,17 @@ public class API {
|
|||
}
|
||||
}
|
||||
|
||||
private String getPreviewUrl(JSONObject playInfo) throws Exception {
|
||||
if (!playInfo.has("live_transcoding_task_list")) return "";
|
||||
private List<String> getPreviewUrl(JSONObject playInfo) throws Exception {
|
||||
if (!playInfo.has("live_transcoding_task_list")) return Collections.emptyList();
|
||||
JSONArray taskList = playInfo.getJSONArray("live_transcoding_task_list");
|
||||
List<String> templates = Arrays.asList("UHD", "QHD", "FHD", "HD", "SD", "LD");
|
||||
for (String template : templates) {
|
||||
for (int i = 0; i < taskList.length(); ++i) {
|
||||
JSONObject task = taskList.getJSONObject(i);
|
||||
if (task.getString("template_id").equals(template)) {
|
||||
return task.getString("url");
|
||||
}
|
||||
}
|
||||
List<String> url = new ArrayList<>();
|
||||
for (int i = taskList.length() - 1; i >= 0; i--) {
|
||||
JSONObject task = taskList.getJSONObject(i);
|
||||
if (!task.optString("status").equals("finished")) continue;
|
||||
url.add(task.optString("template_id"));
|
||||
url.add(task.optString("url"));
|
||||
}
|
||||
return taskList.getJSONObject(0).getString("url");
|
||||
return url;
|
||||
}
|
||||
|
||||
private List<Sub> getSubs(JSONObject playInfo) throws Exception {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class Result {
|
|||
@SerializedName("format")
|
||||
private String format;
|
||||
@SerializedName("url")
|
||||
private String url;
|
||||
private Object url;
|
||||
@SerializedName("subs")
|
||||
private List<Sub> subs;
|
||||
@SerializedName("parse")
|
||||
|
|
@ -131,6 +131,11 @@ public class Result {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Result url(List<String> url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Result format(String format) {
|
||||
this.format = format;
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ public class Bili extends Spider {
|
|||
private JsonObject extend;
|
||||
private String cookie;
|
||||
private boolean login;
|
||||
private boolean vip;
|
||||
|
||||
private Map<String, String> getHeader(String cookie) {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
|
|
@ -163,22 +162,22 @@ public class Bili extends Spider {
|
|||
vod.setVodContent(detail.getDesc());
|
||||
vod.setVodRemarks(detail.getDuration() / 60 + "分鐘");
|
||||
|
||||
Map<String, String> vod_play = new LinkedHashMap<>();
|
||||
ArrayList<String> playList = new ArrayList<>();
|
||||
for (Page page : detail.getPages()) playList.add(page.getPart() + "$" + aid + "+" + page.getCid());
|
||||
vod_play.put("B站", TextUtils.join("#", playList));
|
||||
LinkedHashMap<String, String> flag = new LinkedHashMap<>();
|
||||
ArrayList<String> episode = new ArrayList<>();
|
||||
for (Page page : detail.getPages()) episode.add(page.getPart() + "$" + aid + "+" + page.getCid());
|
||||
flag.put("B站", TextUtils.join("#", episode));
|
||||
|
||||
episode = new ArrayList<>();
|
||||
api = "https://api.bilibili.com/x/web-interface/archive/related?bvid=" + id;
|
||||
JSONArray related = new JSONObject(OkHttp.string(api, getMember())).optJSONArray("data");
|
||||
playList = new ArrayList<>();
|
||||
for (int i = 0; i < related.length(); i++) {
|
||||
JSONObject relatedData = related.getJSONObject(i);
|
||||
playList.add(relatedData.getString("title") + "$" + relatedData.optLong("aid") + "+" + relatedData.optLong("cid"));
|
||||
JSONArray array = new JSONObject(OkHttp.string(api, getMember())).optJSONArray("data");
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
JSONObject object = array.getJSONObject(i);
|
||||
episode.add(object.getString("title") + "$" + object.optLong("aid") + "+" + object.optLong("cid"));
|
||||
}
|
||||
vod_play.put("相关推荐", TextUtils.join("#", playList));
|
||||
flag.put("相关推荐", TextUtils.join("#", episode));
|
||||
|
||||
vod.setVodPlayFrom(TextUtils.join("$$$", vod_play.keySet()));
|
||||
vod.setVodPlayUrl(TextUtils.join("$$$", vod_play.values()));
|
||||
vod.setVodPlayFrom(TextUtils.join("$$$", flag.keySet()));
|
||||
vod.setVodPlayUrl(TextUtils.join("$$$", flag.values()));
|
||||
return Result.string(vod);
|
||||
}
|
||||
|
||||
|
|
@ -258,7 +257,6 @@ public class Bili extends Spider {
|
|||
private void checkLogin() {
|
||||
String json = OkHttp.string("https://api.bilibili.com/x/web-interface/nav", getMember());
|
||||
Data data = Resp.objectFrom(json).getData();
|
||||
vip = data.getVipType() > 0;
|
||||
login = data.isLogin();
|
||||
getQRCode();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue