更新 'SrcJyAliPublic.js'

main
src48597962 10 months ago
parent d0bc452c87
commit c7370f7dde
  1. 89
      SrcJyAliPublic.js

@ -240,10 +240,10 @@ function aliMyPlayUrl(file_id, drive_id) {
if (getItem('aliyun_playMode', '智能') == "智能" || getItem('aliyun_playMode') == "原画") {
let file_url = aliOpenPlayUrl(file_id, undefined, drive_id);
if (file_url) {
if(getItem('yundisk_updateRecord')=="1"){
if (getItem('yundisk_updateRecord') == "1") {
let opentoken = getOpenToken(authorization);
headers['authorization'] = 'Bearer ' + opentoken;
fetch('https://openapi.aliyundrive.com/adrive/v1.0/openFile/video/updateRecord',{headers: headers, body: {"duration":"0","drive_id":drive_id,"file_id":file_id,"play_cursor":"0"}, method: 'POST'});
fetch('https://openapi.aliyundrive.com/adrive/v1.0/openFile/video/updateRecord', { headers: headers, body: { "duration": "0", "drive_id": drive_id, "file_id": file_id, "play_cursor": "0" }, method: 'POST' });
}
urls.unshift(file_url + "#isVideo=true##pre#");
@ -268,69 +268,11 @@ function aliOpenPlayUrl(file_id, sharedata, drive_id, preview) {
try {
drive_id = drive_id || alidrive_id;
function fcopy(obj) {
try {
let json = JSON.parse(fetch('https://api.aliyundrive.com/adrive/v2/batch', {
headers: {
'User-Agent': PC_UA,
'Referer': 'https://www.aliyundrive.com/',
'authorization': authorization,
'x-canary': 'client=web,app=share,version=v2.3.1',
'x-share-token': obj.sharetoken
},
body: {
"requests": [{
"body": {
"file_id": obj.file_id,
"share_id": obj.share_id,
"auto_rename": true,
"to_parent_file_id": "root",
"to_drive_id": obj.drive_id
},
"headers": { "Content-Type": "application/json" }, "id": "0", "method": "POST", "url": "/file/copy"
}],
"resource": "file"
},
method: 'POST'
})).responses[0].body;
if (/size/.test(json.message)) {
log('云盘没有空间,无法操作转存');
}
return json.file_id;
} catch (e) {
log("原画copy转存异常>" + e.message);
return "";
}
};
function fdel(obj) {
fetch('https://api.aliyundrive.com/adrive/v2/batch', {
headers: {
'User-Agent': PC_UA,
'Referer': 'https://www.aliyundrive.com/',
'authorization': authorization,
'x-canary': 'client=web,app=share,version=v2.3.1',
'x-share-token': obj.sharetoken
},
body: {
"requests": [{
"body": {
"drive_id": obj.drive_id,
"file_id": obj.file_id
},
"headers": { "Content-Type": "application/json" },
"id": obj.file_id,
"method": "POST",
"url": "/file/delete"
}],
"resource": "file"
},
method: 'POST'
});
}
let newfile_id;
if (sharedata) {
sharedata.file_id = file_id;
sharedata.drive_id = drive_id;
sharedata.authorization = authorization;
newfile_id = fcopy(sharedata);
if (!newfile_id) {
return "";
@ -342,9 +284,9 @@ function aliOpenPlayUrl(file_id, sharedata, drive_id, preview) {
headers['authorization'] = 'Bearer ' + opentoken;
let data3 = { "drive_id": drive_id, "file_id": newfile_id || file_id };
let apiurl = 'https://open.aliyundrive.com/adrive/v1.0/openFile/getDownloadUrl';
if(preview){
if (preview) {
//转码播放
data3 = {"file_id":newfile_id || file_id,"drive_id":drive_id,"category":"live_transcoding","template_id":"","get_subtitle_info":true,"url_expire_sec":14400,"with_play_cursor":true};
data3 = { "file_id": newfile_id || file_id, "drive_id": drive_id, "category": "live_transcoding", "template_id": "", "get_subtitle_info": true, "url_expire_sec": 14400, "with_play_cursor": true };
apiurl = 'https://open.aliyundrive.com/adrive/v1.0/openFile/getVideoPreviewPlayInfo';
}
getJson = JSON.parse(request(apiurl, { headers: headers, body: data3, method: 'POST', timeout: 8000 }));
@ -355,10 +297,10 @@ function aliOpenPlayUrl(file_id, sharedata, drive_id, preview) {
sharedata.file_id = newfile_id;
fdel(sharedata);
}
if(preview){
if (preview) {
//转码播放
return getJson.video_preview_play_info.live_transcoding_task_list;
}else{
} else {
return getJson.url;
}
} catch (e) {
@ -385,7 +327,7 @@ function getOpenToken(authorization) {
refresh_token: refresh_token
}
variable = 1;
}else{
} else {
let json = JSON.parse(request('https://open.aliyundrive.com/oauth/users/authorize?client_id=76917ccccd4441c39457a04f6084fb2f&redirect_uri=https://alist.nn.ci/tool/aliyundrive/callback&scope=user:base,file:all:read,file:all:write&state=', {
headers: headers,
body: {
@ -422,24 +364,24 @@ function getOpenToken(authorization) {
return json2;
}
if(getItem('aliyun_openInt', '1') == '2'){
if (getItem('aliyun_openInt', '1') == '2') {
let alistOpen = webdavOpenApi(aliOpenTokenObj.refresh_token_2);
if(alistOpen.access_token){
if (alistOpen.access_token) {
open_access_token = alistOpen.access_token;
aliOpenTokenObj.refresh_token_2 = alistOpen.refresh_token || "";
}else if(alistOpen.error){
log('webdav开放接口获取token失败>'+alistOpen.error);
} else if (alistOpen.error) {
log('webdav开放接口获取token失败>' + alistOpen.error);
toast('原画接口2失败,重新登录或切换原画1或转码播放');
}
}else{
} else {
let alistOpen = alistOpenApi(aliOpenTokenObj.refresh_token_1);
if(alistOpen.error && alistOpen.variable){
if (alistOpen.error && alistOpen.variable) {
alistOpen = alistOpenApi();
}
open_access_token = alistOpen.access_token;
aliOpenTokenObj.refresh_token_1 = alistOpen.refresh_token || "";
}
if(open_access_token){
if (open_access_token) {
aliconfig.opentoken = aliOpenTokenObj;
writeFile(alicfgfile, JSON.stringify(aliconfig));
putMyVar('aliopentoken', open_access_token);
@ -448,3 +390,4 @@ function getOpenToken(authorization) {
}
return open_access_token || "";
}

Loading…
Cancel
Save