更新 'SrcJyAlist.js'

master
src48597962 2 years ago
parent 78f2f9c8d8
commit 2c1ded036e
  1. 62
      SrcJyAlist.js

@ -449,7 +449,9 @@ function alistUrl(alistapi,path,sign,subtitle,provider) {
} }
} }
function alistSearch(alistapi,key) { function alistSearch(alistapi,input) {
let dirlist = [];
let filelist = [];
try{ try{
let headers = {'content-type':'application/json;charset=UTF-8'}; let headers = {'content-type':'application/json;charset=UTF-8'};
if(alistapi.token){ if(alistapi.token){
@ -457,51 +459,49 @@ function alistSearch(alistapi,key) {
} }
let json = JSON.parse(fetch(alistapi.server + "/api/fs/search", {headers:headers,body:{"per_page":100,"page":1,"parent":"/","keywords":key},method:'POST',timeout:10000})); let json = JSON.parse(fetch(alistapi.server + "/api/fs/search", {headers:headers,body:{"per_page":100,"page":1,"parent":"/","keywords":key},method:'POST',timeout:10000}));
if(json.code==200){ if(json.code==200){
let dirlist = getlist(json.data.content,1); dirlist = getlist(json.data.content,1);
addItemBefore('listloading', arrayAdd(dirlist,1,alistapi)); filelist = getlist(json.data.content,0,alistapi.nofilter?0:fileFilter);
let filelist = getlist(json.data.content,0,alistapi.nofilter?0:fileFilter);
filelist = filelist.filter(f => {
return !dirlist.some(d => d.parent+"/"+d.name==f.parent);
})
addItemBefore('listloading', arrayAdd(filelist,0,alistapi,json.data.provider));
if(dirlist.length==0&&filelist.length==0){
addItemBefore('listloading', {
title: alistapi.name+" 未搜索到 “"+key+"”",
url: "hiker://empty",
col_type: "text_center_1",
extra: {
cls: "loadlist"
}
});
}
}else if(json.code==500){ }else if(json.code==500){
toast(alistapi.name+' 搜索出错了,此网盘不支持搜索'); toast(alistapi.name+' 搜索出错了,此网盘不支持搜索');
}else if(json.code==401){ }else if(json.code==401){
toast('登录令牌token失效,需要重新获取'); toast(alistapi.name+' 登录令牌token失效,需要重新获取');
} }
}catch(e){ }catch(e){
log(alistapi.name+' 内置搜索出错>'+e.message); log(alistapi.name+' 内置搜索出错,偿试小雅搜索>'+e.message);
try{ try{
let html = fetch(alistapi.server+'/search?box='+key+'&url=&type=video'); let html = fetch(alistapi.server+'/search?box='+key+'&url=&type=video');
let list = pdfa(html,'body&&div&&a'); let list = pdfa(html,'body&&div&&a');
let dirlist = [];
list.forEach(item => { list.forEach(item => {
let txt = pdfh(item,"a&&href"); let txt = pdfh(item,"a&&href");
dirlist.push( let isfile = txt.substring(txt.lastIndexOf('.')+1);
{ log(txt+'>'+isfile);
"parent": txt.substring(0,txt.lastIndexOf("/")), dirlist.push({
"name": txt.substring(txt.lastIndexOf('/')+1), "parent": txt.substring(0,txt.lastIndexOf("/")),
"is_dir": true, "name": txt.substring(txt.lastIndexOf('/')+1),
"size": 0, "is_dir": true
"type": 1 })
}
)
}) })
addItemBefore('listloading', arrayAdd(dirlist,1,alistapi));
}catch(e){ }catch(e){
log(alistapi.name+' 偿试小雅搜索失败'); log(alistapi.name+' 偿试小雅搜索失败');
} }
} }
addItemBefore('listloading', arrayAdd(dirlist,1,alistapi));
filelist = filelist.filter(f => {
return !dirlist.some(d => d.parent+"/"+d.name==f.parent);
})
addItemBefore('listloading', arrayAdd(filelist,0,alistapi,json.data.provider));
if(dirlist.length==0&&filelist.length==0){
addItemBefore('listloading', {
title: alistapi.name+" 未搜索到 “"+input+"”",
url: "hiker://empty",
col_type: "text_center_1",
extra: {
cls: "loadlist"
}
});
}
return 1; return 1;
} }

Loading…
Cancel
Save