更新 'SrcJyAliPublic.js'

main
src48597962 1 year ago
parent b72615d72b
commit 74267a2acf
  1. 182
      SrcJyAliPublic.js

@ -47,7 +47,6 @@ function aliSharePlayUrl(share_id, file_id, share_pwd) {
try {
share_pwd = share_pwd && share_pwd.length == 4 ? share_pwd : "";
let sharetoken = getShareToken(share_id, share_pwd).share_token;
let authorization = 'Bearer ' + userinfo.access_token;
let deviceId = userinfo.device_id;
let userId = userinfo.user_id;
headers['authorization'] = authorization;
@ -184,7 +183,7 @@ function getSubtitle(share_id, sub_file_id, share_pwd) {
try {
share_pwd = share_pwd && share_pwd.length == 4 ? share_pwd : "";
let sharetoken = getShareToken(share_id, share_pwd).share_token;
headers["authorization"] = userinfo.access_token;
headers["authorization"] = authorization;
headers["x-share-token"] = sharetoken;
let data = { "expire_sec": 600, "file_id": sub_file_id, "share_id": share_id };
let downurl = JSON.parse(request("https://api.aliyundrive.com/v2/file/get_share_link_download_url", { headers: headers, body: data, timeout: 3000 })).download_url;
@ -204,7 +203,6 @@ function getSubtitle(share_id, sub_file_id, share_pwd) {
function aliMyPlayUrl(file_id, drive_id) {
try {
drive_id = drive_id || alidrive_id;
let authorization = 'Bearer ' + userinfo.access_token;
let deviceId = userinfo.device_id;
let userId = userinfo.user_id;
headers['authorization'] = authorization;
@ -253,90 +251,14 @@ function aliOpenPlayUrl(file_id, sharedata, drive_id) {
try {
let nowtime = Date.now();
drive_id = drive_id || alidrive_id;
function getOpenToken(authorization) {
headers['authorization'] = authorization;
headers['x-canary'] = "client=web,app=adrive,version=v4.3.1";
function alistOpenApi(refresh_token) {
let variable;
let data = {};
if (refresh_token) {
data = {
grant_type: "refresh_token",
refresh_token: refresh_token
}
variable = 1;
}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: {
"authorize": 1,
"scope": "user:base,file:all:read,file:all:write"
},
method: 'POST',
timeout: 8000
}));
let code = json.redirectUri.split("code=")[1];
data = { "code": code, "grant_type": "authorization_code" }
variable = 0;
}
let json2 = {};
try {
json2 = JSON.parse(request('https://api-cf.nn.ci/alist/ali_open/code', { body: data, method: 'POST', timeout: 8000 }));
} catch (e) {
json2 = JSON.parse(request('https://api.xhofe.top/alist/ali_open/code', { body: data, method: 'POST', timeout: 8000 }));
}
json2.variable = variable;
return json2;
}
function webdavOpenApi(refresh_token) {
let data = {
grant_type: "refresh_token",
refresh_token: refresh_token
};
let json2 = {};
try {
json2 = JSON.parse(request('https://aliyundrive-oauth.messense.me/oauth/access_token', { body: data, method: 'POST', timeout: 8000 }));
} catch (e) {
}
return json2;
}
let open_access_token;
if(getItem('aliyun_openInt', '1') == '2'){
let alistOpen = webdavOpenApi(aliOpenTokenObj.refresh_token_2);
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);
toast('原画接口2失败,重新登录或切换原画1或转码播放');
}
}else{
let alistOpen = alistOpenApi(aliOpenTokenObj.refresh_token_1);
if(alistOpen.access_token){
open_access_token = alistOpen.access_token;
aliOpenTokenObj.refresh_token_1 = alistOpen.refresh_token || "";
}else if(alistOpen.error && alistOpen.variable){
alistOpen = alistOpenApi();
open_access_token = alistOpen.access_token;
aliOpenTokenObj.refresh_token_1 = alistOpen.refresh_token || "";
}
}
if(open_access_token){
aliconfig.opentoken = aliOpenTokenObj;
writeFile(alicfgfile, JSON.stringify(aliconfig));
putMyVar('aliopentoken', open_access_token);
putMyVar('opentokenChecktime', nowtime + 'time');
}
return open_access_token || "";
}
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': obj.authorization,
'authorization': authorization,
'x-canary': 'client=web,app=share,version=v2.3.1',
'x-share-token': obj.sharetoken
},
@ -369,7 +291,7 @@ function aliOpenPlayUrl(file_id, sharedata, drive_id) {
headers: {
'User-Agent': PC_UA,
'Referer': 'https://www.aliyundrive.com/',
'authorization': obj.authorization,
'authorization': authorization,
'x-canary': 'client=web,app=share,version=v2.3.1',
'x-share-token': obj.sharetoken
},
@ -389,12 +311,10 @@ function aliOpenPlayUrl(file_id, sharedata, drive_id) {
method: 'POST'
});
}
let authorization = 'Bearer ' + userinfo.access_token;
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 "";
@ -402,14 +322,7 @@ function aliOpenPlayUrl(file_id, sharedata, drive_id) {
}
let url = '';
try {
let opentoken;
let oldtime = parseInt(getMyVar('opentokenChecktime', '0').replace('time', ''));
let aliopentoken = getMyVar('aliopentoken');
if (aliopentoken && nowtime < (oldtime + 2 * 60 * 60 * 1000)) {
opentoken = aliopentoken;
} else {
opentoken = getOpenToken(authorization);
}
let opentoken = getOpenToken(authorization);
headers['authorization'] = 'Bearer ' + opentoken;
let data3 = { "drive_id": drive_id, "file_id": newfile_id || file_id }
let json3 = JSON.parse(request('https://open.aliyundrive.com/adrive/v1.0/openFile/getDownloadUrl', { headers: headers, body: data3, method: 'POST', timeout: 8000 }));
@ -427,3 +340,88 @@ function aliOpenPlayUrl(file_id, sharedata, drive_id) {
}
return "";
}
function getOpenToken(authorization) {
let open_access_token;
let oldtime = parseInt(getMyVar('opentokenChecktime', '0').replace('time', ''));
let aliopentoken = getMyVar('aliopentoken');
if (aliopentoken && nowtime < (oldtime + 2 * 60 * 60 * 1000)) {
open_access_token = aliopentoken;
} else {
headers['authorization'] = authorization;
headers['x-canary'] = "client=web,app=adrive,version=v4.3.1";
function alistOpenApi(refresh_token) {
let variable;
let data = {};
if (refresh_token) {
data = {
grant_type: "refresh_token",
refresh_token: refresh_token
}
variable = 1;
}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: {
"authorize": 1,
"scope": "user:base,file:all:read,file:all:write"
},
method: 'POST',
timeout: 8000
}));
let code = json.redirectUri.split("code=")[1];
data = { "code": code, "grant_type": "authorization_code" }
variable = 0;
}
let json2 = {};
try {
json2 = JSON.parse(request('https://api-cf.nn.ci/alist/ali_open/code', { body: data, method: 'POST', timeout: 8000 }));
} catch (e) {
json2 = JSON.parse(request('https://api.xhofe.top/alist/ali_open/code', { body: data, method: 'POST', timeout: 8000 }));
}
json2.variable = variable;
return json2;
}
function webdavOpenApi(refresh_token) {
let data = {
grant_type: "refresh_token",
refresh_token: refresh_token
};
let json2 = {};
try {
json2 = JSON.parse(request('https://aliyundrive-oauth.messense.me/oauth/access_token', { body: data, method: 'POST', timeout: 8000 }));
} catch (e) {
}
return json2;
}
if(getItem('aliyun_openInt', '1') == '2'){
let alistOpen = webdavOpenApi(aliOpenTokenObj.refresh_token_2);
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);
toast('原画接口2失败,重新登录或切换原画1或转码播放');
}
}else{
let alistOpen = alistOpenApi(aliOpenTokenObj.refresh_token_1);
if(alistOpen.access_token){
open_access_token = alistOpen.access_token;
aliOpenTokenObj.refresh_token_1 = alistOpen.refresh_token || "";
}else if(alistOpen.error && alistOpen.variable){
alistOpen = alistOpenApi();
open_access_token = alistOpen.access_token;
aliOpenTokenObj.refresh_token_1 = alistOpen.refresh_token || "";
}
}
if(open_access_token){
aliconfig.opentoken = aliOpenTokenObj;
writeFile(alicfgfile, JSON.stringify(aliconfig));
putMyVar('aliopentoken', open_access_token);
putMyVar('opentokenChecktime', nowtime + 'time');
}
}
return open_access_token || "";
}
Loading…
Cancel
Save