From c7370f7dde97749ce4e8ce957cb7777b8cfa0e14 Mon Sep 17 00:00:00 2001 From: src48597962 <48597962@qq.com> Date: Sun, 5 May 2024 10:47:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'SrcJyAliPublic.js'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SrcJyAliPublic.js | 101 ++++++++++------------------------------------ 1 file changed, 22 insertions(+), 79 deletions(-) diff --git a/SrcJyAliPublic.js b/SrcJyAliPublic.js index 4733e42..36f5213 100644 --- a/SrcJyAliPublic.js +++ b/SrcJyAliPublic.js @@ -240,12 +240,12 @@ 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#"); names.unshift("原始 画质"); heads.unshift({ 'Referer': 'https://www.aliyundrive.com/' }); @@ -267,70 +267,12 @@ function aliMyPlayUrl(file_id, drive_id) { 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: { @@ -393,7 +335,7 @@ function getOpenToken(authorization) { "scope": "user:base,file:all:read,file:all:write" }, method: 'POST', - timeout: 8000 + timeout: 8000 })); let code = json.redirectUri.split("code=")[1]; data = { "code": code, "grant_type": "authorization_code" } @@ -417,29 +359,29 @@ function getOpenToken(authorization) { 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'){ + + 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){ - alistOpen = alistOpenApi(); + 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 || ""; } +