//本代码仅用于个人学习,请勿用于其他作用,下载后请24小时内删除,代码虽然是公开学习的,但请尊重作者,应留下说明 let alistfile = "hiker://files/rules/Src/Juying/Alist.json"; try{ eval("var alistData=" + fetch(alistfile)); var datalist = alistData.drives; }catch(e){ var datalist = []; } datalist = [ { "name": "小雅", "server": "http://alist.xiaoya.pro" }, { "name": "帅鹏", "server": "https://hi.shuaipeng.wang" },{ "name": "触光", "server": "https://pan.ichuguang.com" },{ "name": "七米蓝", "server": "https://al.chirmyram.com" },{ "name": "神族九帝", "server": "https://alist.shenzjd.com" } ]; let fileFilter = 1; let contain = /\.mp4|\.avi|\.mkv|\.rmvb|\.flv|\.mov|\.mp3|\.m4a|\.wma|\.flac/;//设置可显示的文件后缀 function gethtml(api,path,password) { try{ path = path || ""; password = password || ""; let html = fetch(api, {body: {"path":path,"password":password},method:'POST',timeout:10000}); return html; }catch(e){ return ""; } } function getlist(data,isdir) { try{ let list = data.filter(item => { return isdir ? item.is_dir : fileFilter?contain.test(item.name):item.is_dir==0; }) try{ list = list.sort((a,b)=>{ let oDate1 = new Date(a.modified); let oDate2 = new Date(b.modified); if(a.modified!=b.modified){ return oDate2.getTime() < oDate1.getTime() }else{ return a.name.replace(/[^\d]/g, " ") - b.name.replace(/[^\d]/g, " "); } }); }catch(e){} return list; }catch(e){ return []; } } function alistHome() { let alistapi = storage0.getItem('Alistapi',datalist.length>0?datalist[0]:{}); let d = []; datalist.forEach(item => { d.push({ title: alistapi.server==item.server?`““””`+item.name+``:item.name, url: $(item.server+'#noLoading#').lazyRule((item) => { storage0.setItem('Alistapi', item); refreshPage(false); return "hiker://empty"; }, item), col_type: 'scroll_button' }) }) d.push({ col_type: 'blank_block' }); d.push({ title: '⚙设置', url: "", col_type: 'scroll_button' }); d.push({ title: '🔍搜索', url: $().lazyRule(() => { require(config.依赖.match(/http(s)?:\/\/.*\//)[0] + 'SrcJyAlist.js'); }), col_type: 'scroll_button' }); d.push({ col_type: 'line' }); d.push({ title: "加载中,请稍后...", url: "hiker://empty", col_type: "text_center_1", extra: { id: "homeloading", lineVisible: false } }) setResult(d); if (datalist.length > 0) { setPageTitle("Alist网盘-" + alistapi.name); try{ let json = JSON.parse(gethtml(alistapi.server + "/api/fs/list", "", alistapi.password)); if(json.code==200){ let dirlist = getlist(json.data.content,1); addItemBefore('homeloading', arrayAdd(dirlist,1,alistapi)); let filelist = getlist(json.data.content,0); addItemBefore('homeloading', arrayAdd(filelist,0,alistapi)); } updateItem('homeloading', { title: "““””此规则仅限学习交流使用,请于导入后24小时内删除,任何团体或个人不得以任何方式方法传播此规则的整体或部分!" }); }catch(e){ updateItem('homeloading', { title: "超时或出错了,下拉刷新重试." }); } } else { setPageTitle("Alist网盘"); updateItem('homeloading', { title: "Alist列表为空" }); } } function alistList(alistapi){ setPageTitle("Alist网盘-" + alistapi.name); let d = []; let listid = base64Encode(MY_PARAMS.path); d.push({ title: "🏠"+ (MY_PARAMS.path||"") + "", col_type: 'rich_text' }) d.push({ title: "加载中,请稍后...", url: "hiker://empty", col_type: "text_center_1", extra: { id: listid, lineVisible: false } }) setResult(d); try{ let json = JSON.parse(gethtml(alistapi.server + "/api/fs/list", MY_PARAMS.path, alistapi.password)); if(json.code==200){ let dirlist = getlist(json.data.content,1); addItemBefore(listid, arrayAdd(dirlist,1,alistapi)); let filelist = getlist(json.data.content,0); addItemBefore(listid, arrayAdd(filelist,0,alistapi)); } updateItem(listid, { title: fileFilter?"““””已开启文件过滤,仅显示音视频文件":"" }); }catch(e){ updateItem(listid, { title: "超时或出错了,下拉刷新重试." }); } } function arrayAdd(list,isdir,alistapi){ let folderpath = (list.parent||MY_PARAMS.path||"") + "/" + item.name; let d = []; if(isdir){ list.forEach(item => { d.push({ title: item.name, img: item.thumb || config.依赖.match(/http(s)?:\/\/.*\//)[0] + "img/文件夹.svg", url: $("hiker://empty##" + alistapi.server + folderpath + "#noRecordHistory##noHistory#").rule((alistapi) => { require(config.依赖.match(/http(s)?:\/\/.*\//)[0] + 'SrcJyAlist.js'); alistList(alistapi); },alistapi), col_type: 'avatar', extra: { path: folderpath, cls: "alist" } }) }) }else{ list.forEach(item => { d.push({ title: item.name, img: item.thumb || "https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg@Referer=", url: $(alistapi.server+path).lazyRule((api,path,pwd,sign) => { require(config.依赖.match(/http(s)?:\/\/.*\//)[0] + 'SrcJyAlist.js'); return alistUrl(api,path,pwd,sign); }, alistapi.server, path, alistapi.password, item.sign), col_type: 'avatar', extra: { cls: "alist" } }) }) } return d; } function alistUrl(api,path,pwd,sign) { if(contain.test(path)){ try{ let json = JSON.parse(gethtml(api + "/api/fs/get", path, pwd)); if(json.code==200){ return json.data.raw_url + (/\.mp3|\.m4a|\.wav|\.flac/.test(path)?"#isMusic=true#":"#isVideo=true#"); } }catch(e){ return api + "/d"+ path + "?sign=" + sign; } return "toast://播放失败,网盘失效"; }else{ return "download://" + api + "/d"+ path + "?sign=" + sign; } } function alistSearch(api,key) { deleteItemByCls('alist'); try{ let json = JSON.parse(fetch(api + "/api/fs/search", {body:{"per_page":100,"page":1,"parent":"/","keywords":key},method:'POST',timeout:10000})); if(json.code==200){ let dirlist = getlist(json.data.content,1); addItemBefore('homeloading', arrayAdd(dirlist,1,alistapi)); let filelist = getlist(json.data.content,0); addItemBefore('homeloading', arrayAdd(filelist,0,alistapi)); } }catch(e){ } }