diff --git a/SrcJyAliPublic.js b/SrcJyAliPublic.js index 681c809..3f8d384 100644 --- a/SrcJyAliPublic.js +++ b/SrcJyAliPublic.js @@ -192,40 +192,6 @@ function getSubtitle(share_id,sub_file_id,share_pwd){ } function aliMyPlayUrl(file_id) { - function aliMyOpenPlayUrl(file_id) { - try { - function getopentoken(token) { - let authorization = 'Bearer ' + token; - headers['authorization'] = authorization; - headers['x-canary'] = "client=web,app=adrive,version=v4.3.1"; - let data = {"authorize":"1","scope":"user:base,file:all:read,file:all:write"} - 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: data, method: 'POST', timeout: 3000 })); - let code = json.redirectUri.split("code=")[1]; - let data2 = {"code":code,"grant_type":"authorization_code"} - let json2 = JSON.parse(request('https://api.nn.ci/alist/ali_open/code', { body: data2, method: 'POST', timeout: 3000 })); - return json2.access_token || ""; - } - let opentoken; - let nowtime = Date.now(); - let oldtime = parseInt(getMyVar('opentokenChecktime', '0').replace('time', '')); - let aliopentoken = getMyVar('aliopentoken'); - if (aliopentoken && nowtime < (oldtime + 1 * 60 * 60 * 1000)) { - opentoken = aliopentoken; - } else { - opentoken = getopentoken(userinfo.access_token); - putMyVar('aliopeninfo', opentoken); - putMyVar('opentokenChecktime', nowtime + 'time'); - } - let drive_id = userinfo.default_drive_id; - headers['authorization'] = 'Bearer ' + opentoken; - let data3 = {"drive_id":drive_id,"file_id":file_id} - let json3 = JSON.parse(request('https://open.aliyundrive.com/adrive/v1.0/openFile/getDownloadUrl', { headers: headers, body: data3, method: 'POST', timeout: 3000 })); - return json3.url || ""; - } catch (e) { - log('获取我的云盘开放原始播放地址失败>' + e.message); - } - return ""; - } try { let authorization = 'Bearer ' + userinfo.access_token; let deviceId = userinfo.device_id; @@ -254,7 +220,7 @@ function aliMyPlayUrl(file_id) { } else { log('未获取阿里转码播放地址,建议重进软件再试一次') } - let file_url = aliMyOpenPlayUrl(file_id); + let file_url = aliOpenPlayUrl(file_id); if(file_url){ urls.unshift(file_url+ "#isVideo=true##pre#"); names.unshift("原始 画质"); @@ -271,4 +237,38 @@ function aliMyPlayUrl(file_id) { log('获取我的云盘播放地址失败>' + e.message); return { message: '获取我的云盘播放地址失败>' + e.message }; } +} +function aliOpenPlayUrl(file_id) { + try { + function getopentoken(token) { + let authorization = 'Bearer ' + token; + headers['authorization'] = authorization; + headers['x-canary'] = "client=web,app=adrive,version=v4.3.1"; + let data = {"authorize":"1","scope":"user:base,file:all:read,file:all:write"} + let json = JSON.parse(request('https://open.aliyundrive.com/oauth/users/authorize?client_id=76917ccccd4441c39457a04f6084fb2f&redirect_uri=https://api-cf.nn.ci/tool/aliyundrive/callback&scope=user:base,file:all:read,file:all:write&state=', { headers: headers, body: data, method: 'POST', timeout: 3000 })); + let code = json.redirectUri.split("code=")[1]; + let data2 = {"code":code,"grant_type":"authorization_code"} + let json2 = JSON.parse(request('https://api-cf.nn.ci/alist/ali_open/code', { body: data2, method: 'POST', timeout: 3000 })); + return json2.access_token || ""; + } + let opentoken; + let nowtime = Date.now(); + let oldtime = parseInt(getMyVar('opentokenChecktime', '0').replace('time', '')); + let aliopentoken = getMyVar('aliopentoken'); + if (aliopentoken && nowtime < (oldtime + 1 * 60 * 60 * 1000)) { + opentoken = aliopentoken; + } else { + opentoken = getopentoken(userinfo.access_token); + putMyVar('aliopeninfo', opentoken); + putMyVar('opentokenChecktime', nowtime + 'time'); + } + let drive_id = userinfo.default_drive_id; + headers['authorization'] = 'Bearer ' + opentoken; + let data3 = {"drive_id":drive_id,"file_id":file_id} + let json3 = JSON.parse(request('https://open.aliyundrive.com/adrive/v1.0/openFile/getDownloadUrl', { headers: headers, body: data3, method: 'POST', timeout: 3000 })); + return json3.url || ""; + } catch (e) { + log('获取我的云盘开放原始播放地址失败>' + e.message); + } + return ""; } \ No newline at end of file