update CAT

This commit is contained in:
qist committed 2024-05-29 18:58:23 +08:00
1 parent e50ce44b09
commit 15e7210863
31 files changed
+3022 -325

No files matched your search

+10 -3
View File
@@ -103,7 +103,9 @@ function aliExpection(data_str) {
} else if (data_str.indexOf("BadRequest") > -1) {
return {code: 402, content: data_str}
} else if (data_str.indexOf("NotFound.File") > -1 || data_str.indexOf("ForbiddenFileInTheRecycleBin") > -1) {
return {code: 403, content: data_str}
return {code: 403, content: data_str}
} else if (data_str.indexOf("user not allowed access drive") > -1){
return {code: 404, content: data_str}
} else if (data_str.indexOf("ForbiddenNoPermission.File") > -1) {
return {code: 500, content: data_str}
} else if (data_str.indexOf("InvalidParameter.ToParentFileId") > -1) {
@@ -112,6 +114,8 @@ function aliExpection(data_str) {
return {code: 502, content: data_str}
} else if (data_str.indexOf("The resource drive has exceeded the limit. File size exceeded drive capacity") > -1) {
return {code: 503, content: data_str}
}else if (data_str.indexOf("The resource drive has exceeded the limit. File size exceeded drive capacity") > -1) {
return {code: 503, content: data_str}
}
return {code: 200, content: data_str}
}
@@ -160,7 +164,7 @@ async function oauthFunc(url, params, retry) {
let open_header = getHeaderOpen();
let response = await postJson(url, params, open_header);
response = aliExpection(response.content)
if (retry && (response.code === 400 || response.code === 401 || response.code === 429 || response.code === 402 || response.code === 403)) {
if (retry && (response.code === 400 || response.code === 401 || response.code === 429 || response.code === 402 || response.code === 403 || response.code === 404)) {
if (response.code === 400) {
await JadeLog.error("阿里授权失败,失败原因为:授权Token无效,准备重新授权,失败详情:" + response.content)
await activateRefreshOpenToken()
@@ -174,7 +178,10 @@ async function oauthFunc(url, params, retry) {
await JadeLog.error("阿里授权失败,失败原因为:没有找到缓存文件,失败详情:" + response.content)
await cleanRecord()
return "retry"
} else if (response.code === 429) {
}else if (response.code === 404) {
await JadeLog.error("阿里授权失败,失败原因为:用户没有权限" + response.content)
return await oauthFunc(url, params, true)
}else if (response.code === 429) {
await JadeLog.error(`正在请求需要阿里授权的url:${url},请求过于频繁,稍后重试,10分钟后再重试`)
Utils.sleep(10 * 60)
return await oauthFunc(url, params, true)
+2 -1
View File
@@ -13,7 +13,7 @@
*/
import {initAli,detailContentAli,playContentAli, aliPlayFormatList,aliName} from "./ali.js"
import { initQuark,detailContentQuark,playContentQuark,quarkPlayFormatList,quarkName,getQuarkHeaders} from "./quark.js"
import { initQuark,detailContentQuark,playContentQuark,getQuarkPlayFormatList,quarkName,getQuarkHeaders} from "./quark.js"
import * as Utils from "./utils.js";
import {_} from "../lib/cat.js";
@@ -38,6 +38,7 @@ async function detailContent(share_url_list,type_name="电影"){
}
let aliItems = await detailContentAli(ali_share_url_list)
let quarkItems = await detailContentQuark(quark_share_url_list)
let quarkPlayFormatList = getQuarkPlayFormatList();
await getVod(aliPlayFormatList,aliName,playVod,aliItems.video_items,aliItems.sub_items,type_name)
await getVod(quarkPlayFormatList,quarkName,playVod,quarkItems.video_items,quarkItems.sub_items,type_name)
+7 -4
View File
@@ -16,7 +16,6 @@ import {JadeLogging} from "./log.js";
import {Quark} from "./quark_api.js"
const quarkName = "夸克云盘"
const JadeLog = new JadeLogging(quarkName)
const quarkPlayFormatList = ["普画"]
const quark = new Quark()
async function initQuark(cookie) {
quark.initQuark(cookie)
@@ -40,6 +39,10 @@ async function detailContentQuark(share_url_list, type_name = "电影") {
}
}
function getQuarkPlayFormatList(){
return quark.getPlayFormatList()
}
async function playContentQuark(flag, id, flags){
let id_list = id.split("++")
@@ -47,8 +50,8 @@ async function playContentQuark(flag, id, flags){
let playUrl = ""
if (flag.indexOf("原画") > -1){
playUrl = (await quark.getDownload(shareId, stoken, fileId, fileToken,true)).download_url
}else if (flag.indexOf("普画") > -1){
playUrl = (await quark.getLiveTranscoding(shareId, stoken, fileId, fileToken,true)).slice(-1)[0]["video_info"].url
}else{
playUrl = await quark.getLiveTranscoding(shareId, stoken, fileId, fileToken,flag)
}
return playUrl
}
@@ -59,5 +62,5 @@ function getQuarkHeaders(){
return headers
}
export {initQuark,detailContentQuark,playContentQuark,quarkPlayFormatList,quarkName,getQuarkHeaders}
export {initQuark,detailContentQuark,playContentQuark,getQuarkPlayFormatList,quarkName,getQuarkHeaders}
+42 -11
View File
@@ -26,16 +26,13 @@ class Quark{
this.saveFileIdCaches = {}
this.saveDirId = null
this.saveDirName = 'TV';
this.isVip = false;
}
async initQuark(cookie) {
this.ckey = Crypto.enc.Hex.stringify(Crypto.MD5(cookie)).toString();
let localCfg = await local.get("quark", "cookie");
if (!_.isEmpty(localCfg)){
this.cookie = JSON.parse(localCfg)[this.ckey]
}else{
this.cookie = cookie
}
this.cookie = cookie
this.isVip = await this.getVip()
}
getHeaders(){
@@ -61,9 +58,6 @@ class Quark{
if (puus) {
if (this.cookie.match(/__puus=([^;]+)/)[1] != puus[1]) {
this.cookie = this.cookie.replace(/__puus=[^;]+/, `__puus=${puus[1]}`);
let cookieDic = {}
cookieDic[this.ckey] = this.cookie
await local.set("quark",this.cookie, JSON.stringify(cookieDic));
}
}
}
@@ -85,6 +79,33 @@ class Quark{
}
return null;
}
async getVip(){
const listData = await this.api(`member?pr=ucpro&fr=pc&uc_param_str=&fetch_subscribe=true&_ch=home&fetch_identity=true`, null,null, 'get');
if (listData.data.member_type==="EXP_SVIP"){
return true
}else{
return false
}
}
getPlayFormatList(){
if(this.isVip){
return ["4K","超清","高清","普画"]
}else{
return ["普画"]
}
}
getPlayFormtQuarkList(){
if(this.isVip){
return ["4k","2k","super","high","normal","low"]
}{
return ["low"]
}
}
async getShareToken(shareData) {
if (!this.shareTokenCache[shareData.shareId]) {
delete this.shareTokenCache[shareData.shareId];
@@ -246,7 +267,7 @@ class Quark{
}
async getLiveTranscoding(shareId, stoken, fileId, fileToken) {
async getLiveTranscoding(shareId, stoken, fileId, fileToken,flag) {
if (!this.saveFileIdCaches[fileId]) {
const saveFileId = await this.save(shareId, stoken, fileId, fileToken, true);
if (!saveFileId) return null;
@@ -257,8 +278,18 @@ class Quark{
resolutions: 'normal,low,high,super,2k,4k',
supports: 'fmp4',
});
if (transcoding.data && transcoding.data.video_list) {
return transcoding.data.video_list;
let flag_id = flag.split("-").slice(-1)[0]
let index = Utils.findAllIndexes(this.getPlayFormatList(),flag_id);
let quarkFormat = this.getPlayFormtQuarkList()[index]
for (const video of transcoding.data.video_list){
if (video.resolution === quarkFormat){
return video.video_info.url
}
}
return transcoding.data.video_list[index].video_info.url
}
return null;
}
+9 -1
View File
@@ -334,6 +334,13 @@ function lcs(str1, str2) {
offset: thisSubsBegin,
};
}
function findAllIndexes(arr, value) {
const indexes = arr.map((item, index) => index).filter(index => arr[index] === value);
return indexes;
}
let patternAli = /(https:\/\/www\.aliyundrive\.com\/s\/[^"]+|https:\/\/www\.alipan\.com\/s\/[^"]+)/
let patternQuark = /(https:\/\/pan\.quark\.cn\/s\/[^"]+)/
@@ -373,5 +380,6 @@ export {
formatContent,
formatUrl,
encode,
lcs
lcs,
findAllIndexes
};