Really support ali live_transcoding_task_list
This commit is contained in:
parent
b200a126df
commit
cadc56d9a3
|
|
@ -17,7 +17,12 @@ import com.github.catvod.BuildConfig;
|
||||||
import com.github.catvod.bean.Result;
|
import com.github.catvod.bean.Result;
|
||||||
import com.github.catvod.bean.Sub;
|
import com.github.catvod.bean.Sub;
|
||||||
import com.github.catvod.bean.Vod;
|
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.crawler.SpiderDebug;
|
||||||
import com.github.catvod.net.OkHttp;
|
import com.github.catvod.net.OkHttp;
|
||||||
import com.github.catvod.net.OkResult;
|
import com.github.catvod.net.OkResult;
|
||||||
|
|
@ -412,7 +417,7 @@ public class API {
|
||||||
private String getPreviewContent(String[] ids) {
|
private String getPreviewContent(String[] ids) {
|
||||||
try {
|
try {
|
||||||
JSONObject playInfo = getVideoPreviewPlayInfo(ids[0]);
|
JSONObject playInfo = getVideoPreviewPlayInfo(ids[0]);
|
||||||
String url = getPreviewUrl(playInfo);
|
List<String> url = getPreviewUrl(playInfo);
|
||||||
List<Sub> subs = getSubs(ids);
|
List<Sub> subs = getSubs(ids);
|
||||||
subs.addAll(getSubs(playInfo));
|
subs.addAll(getSubs(playInfo));
|
||||||
return Result.get().url(url).m3u8().subs(subs).header(getHeader()).string();
|
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 {
|
private List<String> getPreviewUrl(JSONObject playInfo) throws Exception {
|
||||||
if (!playInfo.has("live_transcoding_task_list")) return "";
|
if (!playInfo.has("live_transcoding_task_list")) return Collections.emptyList();
|
||||||
JSONArray taskList = playInfo.getJSONArray("live_transcoding_task_list");
|
JSONArray taskList = playInfo.getJSONArray("live_transcoding_task_list");
|
||||||
List<String> templates = Arrays.asList("UHD", "QHD", "FHD", "HD", "SD", "LD");
|
List<String> url = new ArrayList<>();
|
||||||
for (String template : templates) {
|
for (int i = taskList.length() - 1; i >= 0; i--) {
|
||||||
for (int i = 0; i < taskList.length(); ++i) {
|
|
||||||
JSONObject task = taskList.getJSONObject(i);
|
JSONObject task = taskList.getJSONObject(i);
|
||||||
if (task.getString("template_id").equals(template)) {
|
if (!task.optString("status").equals("finished")) continue;
|
||||||
return task.getString("url");
|
url.add(task.optString("template_id"));
|
||||||
|
url.add(task.optString("url"));
|
||||||
}
|
}
|
||||||
}
|
return url;
|
||||||
}
|
|
||||||
return taskList.getJSONObject(0).getString("url");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Sub> getSubs(JSONObject playInfo) throws Exception {
|
private List<Sub> getSubs(JSONObject playInfo) throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class Result {
|
||||||
@SerializedName("format")
|
@SerializedName("format")
|
||||||
private String format;
|
private String format;
|
||||||
@SerializedName("url")
|
@SerializedName("url")
|
||||||
private String url;
|
private Object url;
|
||||||
@SerializedName("subs")
|
@SerializedName("subs")
|
||||||
private List<Sub> subs;
|
private List<Sub> subs;
|
||||||
@SerializedName("parse")
|
@SerializedName("parse")
|
||||||
|
|
@ -131,6 +131,11 @@ public class Result {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Result url(List<String> url) {
|
||||||
|
this.url = url;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Result format(String format) {
|
public Result format(String format) {
|
||||||
this.format = format;
|
this.format = format;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue