|
|
|
@ -1,12 +1,158 @@ |
|
|
|
|
function getAliUrl(share_id, file_id, alitoken) { |
|
|
|
|
let alistfile = "hiker://files/rules/Src/Juying/Alist.json"; |
|
|
|
|
try{ |
|
|
|
|
var alistData= JSON.parse(fetch(alistfile)); |
|
|
|
|
}catch(e){ |
|
|
|
|
var alistData = {}; |
|
|
|
|
} |
|
|
|
|
let datalist = alistData.drives || []; |
|
|
|
|
let alistconfig = alistData.config || {}; |
|
|
|
|
let fileFilter = alistconfig['fileFilter']==0?0:1; |
|
|
|
|
let audiovisual = alistconfig.contain?alistconfig.contain.replace(/\./,""):'mp4|avi|mkv|rmvb|flv|mov|ts|mp3|m4a|wma|flac';//影音文件
|
|
|
|
|
let contain = new RegExp(audiovisual,"i");//设置可显示的影音文件后缀
|
|
|
|
|
let music = new RegExp("mp3|m4a|wma|flac","i");//进入音乐播放器
|
|
|
|
|
let image = new RegExp("jpg|png|gif|bmp|ico|svg","i");//进入图片查看
|
|
|
|
|
const transcoding = {UHD: "4K 超清",QHD: "2K 超清",FHD: "1080 全高清",HD: "720 高清",SD: "540 标清",LD: "360 流畅"}; |
|
|
|
|
|
|
|
|
|
function SortList(v1, v2) { |
|
|
|
|
var a = v1.name; |
|
|
|
|
var b = v2.name; |
|
|
|
|
var reg = /[0-9]+/g; |
|
|
|
|
var lista = a.match(reg); |
|
|
|
|
var listb = b.match(reg); |
|
|
|
|
if (!lista || !listb) { |
|
|
|
|
return a.localeCompare(b); |
|
|
|
|
} |
|
|
|
|
for (var i = 0, minLen = Math.min(lista.length, listb.length); i < minLen; i++) { |
|
|
|
|
//数字所在位置序号
|
|
|
|
|
var indexa = a.indexOf(lista[i]); |
|
|
|
|
var indexb = b.indexOf(listb[i]); |
|
|
|
|
//数字前面的前缀
|
|
|
|
|
var prefixa = a.substring(0, indexa); |
|
|
|
|
var prefixb = a.substring(0, indexb); |
|
|
|
|
//数字的string
|
|
|
|
|
var stra = lista[i]; |
|
|
|
|
var strb = listb[i]; |
|
|
|
|
//数字的值
|
|
|
|
|
var numa = parseInt(stra); |
|
|
|
|
var numb = parseInt(strb); |
|
|
|
|
//如果数字的序号不等或前缀不等,属于前缀不同的情况,直接比较
|
|
|
|
|
if (indexa != indexb || prefixa != prefixb) { |
|
|
|
|
return a.localeCompare(b); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
//数字的string全等
|
|
|
|
|
if (stra === strb) { |
|
|
|
|
//如果是最后一个数字,比较数字的后缀
|
|
|
|
|
if (i == minLen - 1) { |
|
|
|
|
return a.substring(indexa).localeCompare(b.substring(indexb)); |
|
|
|
|
} |
|
|
|
|
//如果不是最后一个数字,则循环跳转到下一个数字,并去掉前面相同的部分
|
|
|
|
|
else { |
|
|
|
|
a = a.substring(indexa + stra.length); |
|
|
|
|
b = b.substring(indexa + stra.length); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//如果数字的string不全等,但值相等
|
|
|
|
|
else if (numa == numb) { |
|
|
|
|
//直接比较数字前缀0的个数,多的更小
|
|
|
|
|
return strb.lastIndexOf(numb + '') - stra.lastIndexOf(numa + ''); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
//如果数字不等,直接比较数字大小
|
|
|
|
|
return numa - numb; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function aliSharePlayUrl(share_id,file_id,alitoken,share_pwd){ |
|
|
|
|
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 |
|
|
|
|
} |
|
|
|
|
share_pwd = share_pwd&&share_pwd.length==4?share_pwd:""; |
|
|
|
|
let sharetoken = JSON.parse(request('https://api.aliyundrive.com/v2/share_link/get_share_token', { body: { "share_pwd": 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 nowtime = Date.now(); |
|
|
|
|
let oldtime = parseInt(getMyVar('userinfoChecktime','0').replace('time','')); |
|
|
|
|
let userinfo; |
|
|
|
|
let aliuserinfo = storage0.getMyVar('aliuserinfo'); |
|
|
|
|
if (aliuserinfo && aliuserinfo.user_id && nowtime < (oldtime+2*60*60*1000)) { |
|
|
|
|
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); |
|
|
|
|
putMyVar('userinfoChecktime', nowtime+'time'); |
|
|
|
|
} |
|
|
|
|
let authorization = 'Bearer ' + userinfo.access_token; |
|
|
|
|
let deviceId = userinfo.device_id; |
|
|
|
|
let userId = userinfo.user_id; |
|
|
|
|
let signature; |
|
|
|
|
let public_key; |
|
|
|
|
let getaliecc = JSON.parse(request('http://124.221.241.174:87/api', { body: 'did=' + deviceId + '&uid=' + userId + '&token=' + md5(getNowTime()), method: 'POST', timeout: 3000 })); |
|
|
|
|
if (getaliecc.code == 200) { |
|
|
|
|
signature = getaliecc.sign; |
|
|
|
|
public_key = getaliecc.key; |
|
|
|
|
} |
|
|
|
|
/* |
|
|
|
|
let a = justTestSign('5dde4e1bdf9e4966b387ba58f4b3fdc3',deviceId,userId); |
|
|
|
|
signature = a.split('##')[0]; |
|
|
|
|
public_key = a.split('##')[1]; |
|
|
|
|
*/ |
|
|
|
|
headers['authorization'] = authorization; |
|
|
|
|
headers['x-device-id'] = deviceId; |
|
|
|
|
headers['x-signature'] = signature; |
|
|
|
|
let data = { |
|
|
|
|
"deviceName": "Edge浏览器", |
|
|
|
|
"modelName": "Windows网页版", |
|
|
|
|
"pubKey": public_key, |
|
|
|
|
} |
|
|
|
|
let aliyunUrl = []; |
|
|
|
|
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'] = userId; |
|
|
|
|
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 })); |
|
|
|
|
aliyunUrl = json.video_preview_play_info.live_transcoding_task_list; |
|
|
|
|
aliyunUrl.reverse(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return aliyunUrl; |
|
|
|
|
}catch(e){ |
|
|
|
|
log('根据共享链接获取播放地址失败,挂载的阿里分享应有密码>'+e.message); |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getAliUrl(share_id, file_id, alitoken,share_pwd) { |
|
|
|
|
try { |
|
|
|
|
let urls = []; |
|
|
|
|
let names = []; |
|
|
|
|
let heads = []; |
|
|
|
|
let u = startProxyServer($.toString((aliSharePlayUrl,file_id,share_id,alitoken) => { |
|
|
|
|
let u = startProxyServer($.toString((aliSharePlayUrl,share_id,file_id,alitoken,share_pwd) => { |
|
|
|
|
function geturl(fileid,line){ |
|
|
|
|
//预加载时会变file_id,所以ts过期更新时还取原来的id
|
|
|
|
|
let playUrlList = aliSharePlayUrl(share_id, fileid, alitoken) || []; |
|
|
|
|
let playUrlList = aliSharePlayUrl(share_id,fileid,alitoken,share_pwd) || []; |
|
|
|
|
let aliurl; |
|
|
|
|
playUrlList.forEach((item) => { |
|
|
|
|
if(item.template_id == line){ |
|
|
|
@ -73,9 +219,9 @@ function getAliUrl(share_id, file_id, alitoken) { |
|
|
|
|
let ff = geturl(file_id,line); |
|
|
|
|
return ff; |
|
|
|
|
} |
|
|
|
|
},aliSharePlayUrl,file_id,share_id,alitoken)); |
|
|
|
|
},aliSharePlayUrl,share_id,file_id,alitoken,share_pwd)); |
|
|
|
|
|
|
|
|
|
let playUrlList = aliSharePlayUrl(share_id, file_id, alitoken) || []; |
|
|
|
|
let playUrlList = aliSharePlayUrl(share_id,file_id,alitoken,share_pwd) || []; |
|
|
|
|
if(playUrlList.length>0){ |
|
|
|
|
playUrlList.forEach((item) => { |
|
|
|
|
urls.push(u + "?url=" + base64Encode(item.url+"|"+item.template_id) + "#.m3u8#pre#"); |
|
|
|
@ -97,81 +243,28 @@ function getAliUrl(share_id, file_id, alitoken) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function aliSharePlayUrl(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 nowtime = Date.now(); |
|
|
|
|
let oldtime = parseInt(getMyVar('userinfoChecktime','0').replace('time','')); |
|
|
|
|
let userinfo; |
|
|
|
|
let aliuserinfo = storage0.getMyVar('aliuserinfo'); |
|
|
|
|
if (aliuserinfo && aliuserinfo.user_id && nowtime < (oldtime+1*60*60*1000)) { |
|
|
|
|
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); |
|
|
|
|
putMyVar('userinfoChecktime', nowtime+'time'); |
|
|
|
|
} |
|
|
|
|
let authorization = 'Bearer ' + userinfo.access_token; |
|
|
|
|
let deviceId = userinfo.device_id; |
|
|
|
|
let userId = userinfo.user_id; |
|
|
|
|
let signature; |
|
|
|
|
let public_key; |
|
|
|
|
let getaliecc = JSON.parse(request('http://124.221.241.174:87/api', { body: 'did=' + deviceId + '&uid=' + userId + '&token=' + md5(getNowTime()), method: 'POST', timeout: 3000 })); |
|
|
|
|
if (getaliecc.code == 200) { |
|
|
|
|
signature = getaliecc.sign; |
|
|
|
|
public_key = getaliecc.key; |
|
|
|
|
} |
|
|
|
|
/* |
|
|
|
|
let a = justTestSign('5dde4e1bdf9e4966b387ba58f4b3fdc3',deviceId,userId); |
|
|
|
|
signature = a.split('##')[0]; |
|
|
|
|
public_key = a.split('##')[1]; |
|
|
|
|
*/ |
|
|
|
|
headers['authorization'] = authorization; |
|
|
|
|
headers['x-device-id'] = deviceId; |
|
|
|
|
headers['x-signature'] = signature; |
|
|
|
|
let data = { |
|
|
|
|
"deviceName": "Edge浏览器", |
|
|
|
|
"modelName": "Windows网页版", |
|
|
|
|
"pubKey": public_key, |
|
|
|
|
} |
|
|
|
|
let aliyunUrl = []; |
|
|
|
|
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'] = userId; |
|
|
|
|
data = { |
|
|
|
|
"category": "live_transcoding", |
|
|
|
|
"file_id": file_id, |
|
|
|
|
"get_preview_url": true, |
|
|
|
|
"share_id": share_id, |
|
|
|
|
"template_id": "", |
|
|
|
|
"get_subtitle_info": true |
|
|
|
|
function getSubtitle(share_id,sub_file_id,share_pwd){ |
|
|
|
|
try{ |
|
|
|
|
share_pwd = share_pwd&&share_pwd.length==4?share_pwd:""; |
|
|
|
|
let sharetoken = JSON.parse(request('https://api.aliyundrive.com/v2/share_link/get_share_token', { body: { "share_pwd": share_pwd, "share_id": share_id }, method: 'POST', timeout: 3000 })).share_token; |
|
|
|
|
let userinfo = storage0.getMyVar('aliuserinfo'); |
|
|
|
|
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", |
|
|
|
|
"authorization": userinfo.access_token, |
|
|
|
|
"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; |
|
|
|
|
let substr = fetch(downurl, {headers:{"referer": "https://www.aliyundrive.com/"},timeout:3000}); |
|
|
|
|
if(substr){ |
|
|
|
|
writeFile("hiker://files/cache/src/subtitles.srt",substr); |
|
|
|
|
return getPath("hiker://files/cache/src/subtitles.srt"); |
|
|
|
|
} |
|
|
|
|
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 })); |
|
|
|
|
aliyunUrl = json.video_preview_play_info.live_transcoding_task_list; |
|
|
|
|
aliyunUrl.reverse(); |
|
|
|
|
} |
|
|
|
|
}catch(e){ |
|
|
|
|
log('获取字幕失败>'+e.message); |
|
|
|
|
} |
|
|
|
|
return aliyunUrl; |
|
|
|
|
}catch(e){ |
|
|
|
|
log('根据共享链接获取播放地址失败,挂载的阿里分享应有密码>'+e.message); |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
} |