update CAT

This commit is contained in:
qist
2024-05-22 10:56:27 +08:00
parent 8a7360760f
commit ab6af24701
32 changed files with 1064 additions and 466 deletions
+14 -55
View File
@@ -306,8 +306,7 @@ async function refreshOpenToken() {
}
}
async function getFileByShare(share_token, share_url, video_item_list, sub_item_list) {
await JadeLog.info(`正在获取播放链接,分享链接为:${share_url}`)
async function getFileByShare(index,share_token, share_url, video_item_list, sub_item_list) {
let params = {};
params.share_id = shareId;
let file_id = share_url.split("folder/").slice(-1)[0]
@@ -317,27 +316,15 @@ async function getFileByShare(share_token, share_url, video_item_list, sub_item_
let response_str = await post("adrive/v3/share_link/get_share_by_anonymous", params),
response_json = JSON.parse(response_str), item_file_id = getParentFileId(file_id, response_json),
item = new Item(item_file_id);
await listFiles(item, video_item_list, sub_item_list, share_token);
await listFiles(index,item, video_item_list, sub_item_list, share_token);
}
async function getVod(video_item_list, sub_item_list, type_name) {
let play_foramt_list = ["原画", "超清", "高清", "标清"], episode_list = [], episode_str_list = [];
for (const video_item of video_item_list) {
episode_list.push(video_item.getDisplayName(type_name) + "$" + video_item.getFileId() + "+" + video_item.shareId + "+" + video_item.shareToken + findSubs(video_item.getName(), sub_item_list));
}
for (let index = 0; index < play_foramt_list.length; index++) {
episode_str_list.push(episode_list.join("#"));
}
return {
vod_play_url: episode_str_list.join("$$$"), vod_play_from: play_foramt_list.map(item => item).join("$$$"),
};
async function listFiles(index,item, video_item_list, sub_item_list, share_token) {
return await listFilesMarker(index,item, video_item_list, sub_item_list, "", share_token);
}
async function listFiles(item, video_item_list, sub_item_list, share_token) {
return await listFilesMarker(item, video_item_list, sub_item_list, "", share_token);
}
async function listFilesMarker(item, video_item_list, sub_item_list, netxt_markers, share_token) {
async function listFilesMarker(index,item, video_item_list, sub_item_list, netxt_markers, share_token) {
let new_item = {}, file_list = [];
new_item.limit = 200;
new_item.share_id = shareId;
@@ -345,10 +332,11 @@ async function listFilesMarker(item, video_item_list, sub_item_list, netxt_marke
new_item.parent_file_id = item.getFileId();
new_item.order_by = "name";
new_item.order_direction = "ASC";
new_item.share_index = index
if (netxt_markers.length > 0) {
new_item.marker = netxt_markers;
}
let items = Item.objectFrom(await shareFunc("adrive/v2/file/list_by_share", new_item), shareToken);
let items = Item.objectFrom(await shareFunc("adrive/v2/file/list_by_share", new_item), shareToken,index);
for (const r_item of items.getItems()) {
if (r_item.getType() === "folder") {
file_list.push(r_item);
@@ -385,9 +373,9 @@ async function listFilesMarker(item, video_item_list, sub_item_list, netxt_marke
}
}
}
items.getNextMarker().length > 0 && (await listFilesMarker(item, video_item_list, sub_item_list, items.getNextMarker()));
items.getNextMarker().length > 0 && (await listFilesMarker(index,item, video_item_list, sub_item_list, items.getNextMarker()));
for (const file of file_list) {
await listFiles(file, video_item_list, sub_item_list);
await listFiles(index,file, video_item_list, sub_item_list);
}
}
@@ -413,31 +401,6 @@ function getParentFileId(file_id, items) {
return "";
}
//字幕匹配
function pair(name, item_list, sub_item_list) {
for (const item of item_list) {
const sub_name = Utils.removeExt(item.getName()).toLowerCase();
if (name.indexOf(sub_name) > -1 || sub_name.indexOf(name) > -1) {
sub_item_list.push(item);
}
}
}
//找出所有字幕
function findSubs(name, item_list) {
let sub_item_list = [];
pair(Utils.removeExt(name).toLowerCase(), item_list, sub_item_list);
if (sub_item_list.length === 0) {
for (const item of item_list) {
sub_item_list.push(item);
}
}
let sub_str = "";
for (const item of sub_item_list) {
sub_str += "+" + Utils.removeExt(item.getName()) + "@@@" + item.getExt() + "@@@" + item.getFileId();
}
return sub_str;
}
async function getSubs(sub_list, share_id) {
let sub_url_list = [];
@@ -517,9 +480,7 @@ async function playerContent(file_id, share_id, share_token) {
// let sub_list = await getSubs(file_id_list,share_id);
await JadeLog.info("获取原画的播放地址和字幕下载链接成功", true)
await JadeLog.info(`下载地址为:${download_url}`)
return JSON.stringify({
parse: 0, url: download_url, header: getHeader(), format: "application/octet-stream", subs: []
});
return download_url;
} catch (e) {
await JadeLog.error("获取原画的播放地址和字幕下载链接失败:失败原因为:" + e);
}
@@ -540,9 +501,7 @@ async function playerContentByFlag(file_id, flag, share_id, shareToken) {
await JadeLog.info("获取转码后的播放地址和字幕下载链接成功", true)
await JadeLog.info(`下载地址为:${video_preview_url}`)
return JSON.stringify({
parse: 0, url: video_preview_url, header: getHeader(), format: "application/x-mpegURL", subs: []
});
return video_preview_url;
} catch (e) {
await JadeLog.error(`获取转码后的播放地址和字幕下载链接失败,失败原因为:${e}`)
}
@@ -560,7 +519,7 @@ function getPreviewUrl(video_preview_play_info, flag) {
return live_transcoding_task.url;
}
}
return live_transcoding_task_list[0].url;
return live_transcoding_task_list.slice(-1)[0].url;
}
function getSubsByPlayInfo(video_preview_play_info) {
@@ -707,5 +666,5 @@ async function setToken(token) {
}
export {
initSome, setToken, clearFile, setShareId, getFileByShare, getVod, playerContent, playerContentByFlag, getTempFileId
initSome, setToken, clearFile, setShareId, getFileByShare, playerContent, playerContentByFlag, getTempFileId
};