From 148a9563dde8d129f53bc539fd6e2187573695e4 Mon Sep 17 00:00:00 2001 From: src48597962 <48597962@qq.com> Date: Wed, 8 Mar 2023 09:44:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'SrcJyAlist.js'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SrcJyAlist.js | 188 +++++++++++++++++++++++++------------------------- 1 file changed, 95 insertions(+), 93 deletions(-) diff --git a/SrcJyAlist.js b/SrcJyAlist.js index 3507a665..f8f1aa84 100644 --- a/SrcJyAlist.js +++ b/SrcJyAlist.js @@ -373,100 +373,20 @@ function alistUrl(alistapi,path,sign,subtitle,provider) { } if(provider=="AliyundriveShare"){ - function getAliUrl(share_id,file_id,alitoken){ - try{ - function getNowTime() { - const yy = new Date().getFullYear() - const MM = (new Date().getMonth() + 1) < 10 ? '0' + (new Date().getMonth() + 1) : (new Date().getMonth() + 1) - const dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate() - const HH = new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours() - const mm = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes() - return yy + '' + dd + '' + HH + '' + MM + '' + mm - } - - let sharetoken = JSON.parse(request('https://api.aliyundrive.com/v2/share_link/get_share_token',{body:{"share_pwd":"","share_id":share_id},method:'POST',timeout:3000})).share_token; - let headers = { - 'content-type':'application/json;charset=UTF-8', - "origin": "https://www.aliyundrive.com", - "referer": "https://www.aliyundrive.com/", - "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.41", - "x-canary": "client=web,app=adrive,version=v3.1.0" - }; - let userinfo; - let aliuserinfo = storage0.getMyVar('aliuserinfo'); - if(aliuserinfo&&aliuserinfo.user_id){ - userinfo = aliuserinfo; - }else{ - userinfo = JSON.parse(request('https://auth.aliyundrive.com/v2/account/token',{headers:headers,body:{"refresh_token":alitoken,"grant_type":"refresh_token"},method:'POST',timeout:3000})); - storage0.putMyVar('aliuserinfo',userinfo); - } - let authorization = 'Bearer '+userinfo.access_token; - let userId = userinfo.user_id; - let deviceId = userinfo.device_id; - let getaliecc = JSON.parse(request('http://124.221.241.174:87/api',{body:'did='+deviceId+'&uid='+userId+'&token='+md5(getNowTime()),method:'POST',timeout:3000})); - let signature; - let public_key; - if(getaliecc.code==200){ - signature = getaliecc.sign; - public_key = getaliecc.key; - } - headers['authorization'] = authorization; - headers['x-device-id'] = deviceId; - headers['x-signature'] = signature; - let data = { - "deviceName": "Edge浏览器", - "modelName": "Windows网页版", - "pubKey": public_key, - } - if(signature&&public_key){ - let req = JSON.parse(request("https://api.aliyundrive.com/users/v1/users/device/create_session",{headers:headers,body:data,timeout:3000})); - if(req.success){ - headers['x-share-token'] = sharetoken; - headers['fileid'] = userinfo.user_id; - data = { - "category":"live_transcoding", - "file_id":file_id, - "get_preview_url":true, - "share_id":share_id, - "template_id":"", - "get_subtitle_info":true - } - let json = JSON.parse(request('https://api.aliyundrive.com/v2/file/get_share_link_video_preview_play_info',{headers:headers,body:data,method:'POST',timeout:3000})); - let playurl = json.video_preview_play_info.live_transcoding_task_list; - playurl.reverse(); - let urls = []; - let names = []; - let heads = []; - playurl.forEach(item => { - let rurl = JSON.parse(request(item.url,{headers:{'Referer':'https://www.aliyundrive.com/'},onlyHeaders:true,redirect:false,timeout:3000})).headers.location[0]; - urls.push(rurl+"#isVideo=true##pre#"); - names.push(transcoding[item.template_id]?transcoding[item.template_id]:item.template_height); - heads.push({'Referer':'https://www.aliyundrive.com/'}); - }) - return { - urls: urls, - names: names, - headers: heads - }; - } + try{ + let redirect = JSON.parse(request(url,{onlyHeaders:true,redirect:false,timeout:3000})); + let rurl = redirect.headers.location[0]; + let share_id = rurl.split('&sl=')[1].split('&')[0]; + let file_id = rurl.split('&f=')[1].split('&')[0]; + let alitoken = alistconfig.alitoken; + let play = getAliUrl(share_id,file_id,alitoken); + if(play.urls){ + if(subtitle){ + play['subtitle'] = subtitle; } - }catch(e){ - log('获取共享链接播放地址失败>'+e.message); - return {}; + return JSON.stringify(play); } - } - let redirect = JSON.parse(request(url,{onlyHeaders:true,redirect:false,timeout:3000})); - let rurl = redirect.headers.location[0]; - let share_id = rurl.split('&sl=')[1].split('&')[0]; - let file_id = rurl.split('&f=')[1].split('&')[0]; - let alitoken = alistconfig.alitoken; - let play = getAliUrl(share_id,file_id,alitoken); - if(play.urls){ - if(subtitle){ - play['subtitle'] = subtitle; - } - return JSON.stringify(play); - } + }catch(e){} } url = url + (music.test(suffix)?"#isMusic=true#":"#isVideo=true#") + (url.indexOf('baidu.com')>-1?';{User-Agent@Lavf/57.83.100}':url.indexOf('mypikpak.com')>-1?';{dns@https://dns.alidns.com/dns-query}':''); if(!subtitle){ @@ -928,4 +848,86 @@ function alistSet() { }) setResult(d); -} \ No newline at end of file +} +function getAliUrl(share_id,file_id,alitoken){ + try{ + function getNowTime() { + const yy = new Date().getFullYear() + const MM = (new Date().getMonth() + 1) < 10 ? '0' + (new Date().getMonth() + 1) : (new Date().getMonth() + 1) + const dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate() + const HH = new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours() + const mm = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes() + return yy + '' + dd + '' + HH + '' + MM + '' + mm + } + + let sharetoken = JSON.parse(request('https://api.aliyundrive.com/v2/share_link/get_share_token',{body:{"share_pwd":"","share_id":share_id},method:'POST',timeout:3000})).share_token; + let headers = { + 'content-type':'application/json;charset=UTF-8', + "origin": "https://www.aliyundrive.com", + "referer": "https://www.aliyundrive.com/", + "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.41", + "x-canary": "client=web,app=adrive,version=v3.1.0" + }; + let userinfo; + let aliuserinfo = storage0.getMyVar('aliuserinfo'); + if(aliuserinfo&&aliuserinfo.user_id){ + userinfo = aliuserinfo; + }else{ + userinfo = JSON.parse(request('https://auth.aliyundrive.com/v2/account/token',{headers:headers,body:{"refresh_token":alitoken,"grant_type":"refresh_token"},method:'POST',timeout:3000})); + storage0.putMyVar('aliuserinfo',userinfo); + } + let authorization = 'Bearer '+userinfo.access_token; + let userId = userinfo.user_id; + let deviceId = userinfo.device_id; + let getaliecc = JSON.parse(request('http://124.221.241.174:87/api',{body:'did='+deviceId+'&uid='+userId+'&token='+md5(getNowTime()),method:'POST',timeout:3000})); + let signature; + let public_key; + if(getaliecc.code==200){ + signature = getaliecc.sign; + public_key = getaliecc.key; + } + headers['authorization'] = authorization; + headers['x-device-id'] = deviceId; + headers['x-signature'] = signature; + let data = { + "deviceName": "Edge浏览器", + "modelName": "Windows网页版", + "pubKey": public_key, + } + if(signature&&public_key){ + let req = JSON.parse(request("https://api.aliyundrive.com/users/v1/users/device/create_session",{headers:headers,body:data,timeout:3000})); + if(req.success){ + headers['x-share-token'] = sharetoken; + headers['fileid'] = userinfo.user_id; + data = { + "category":"live_transcoding", + "file_id":file_id, + "get_preview_url":true, + "share_id":share_id, + "template_id":"", + "get_subtitle_info":true + } + let json = JSON.parse(request('https://api.aliyundrive.com/v2/file/get_share_link_video_preview_play_info',{headers:headers,body:data,method:'POST',timeout:3000})); + let playurl = json.video_preview_play_info.live_transcoding_task_list; + playurl.reverse(); + let urls = []; + let names = []; + let heads = []; + playurl.forEach(item => { + let rurl = JSON.parse(request(item.url,{headers:{'Referer':'https://www.aliyundrive.com/'},onlyHeaders:true,redirect:false,timeout:3000})).headers.location[0]; + urls.push(rurl+"#isVideo=true##pre#"); + names.push(transcoding[item.template_id]?transcoding[item.template_id]:item.template_height); + heads.push({'Referer':'https://www.aliyundrive.com/'}); + }) + return { + urls: urls, + names: names, + headers: heads + }; + } + } + }catch(e){ + log('获取共享链接播放地址失败>'+e.message); + return {}; + } + } \ No newline at end of file