提交 448e1db3 编写于 作者: H hjdhnx

alist增加搜索

上级 fd0e9068
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
}, },
# 缓存js # 缓存js
# {"key":"js_origin","name":"JS(原始)","type":3,"api":"{{host}}/txt/js/原始JS.js","searchable":1,"quickSearch":1,"filterable":1,"ext":""}, # {"key":"js_origin","name":"JS(原始)","type":3,"api":"{{host}}/txt/js/原始JS.js","searchable":1,"quickSearch":1,"filterable":1,"ext":""},
{"key":"Alist","name":"Alist","type":3,"api":"{{host}}/libs/alist.min.js","searchable":0,"quickSearch":0,"filterable":0,"ext":"{{host}}/txt/json/alist.json"}, {"key":"Alist","name":"Alist","type":3,"api":"{{host}}/libs/alist.min.js","searchable":2,"quickSearch":0,"filterable":0,"ext":"{{host}}/txt/json/alist.json"},
{"key":"js_origin_puto","name":"原始JS(pluto)","type":3,"api":"js_origin_test","searchable":1,"quickSearch":1,"filterable":1,"ext":"{{host}}/txt/js/原始JS/origin.js"}, {"key":"js_origin_puto","name":"原始JS(pluto)","type":3,"api":"js_origin_test","searchable":1,"quickSearch":1,"filterable":1,"ext":"{{host}}/txt/js/原始JS/origin.js"},
{"key":"js_origin_tvb","name":"原始JS(俊tvb)","type":3,"api":"{{host}}/txt/js/origin/原始JS.js","searchable":1,"quickSearch":1,"filterable":1,"ext":"{}"}, {"key":"js_origin_tvb","name":"原始JS(俊tvb)","type":3,"api":"{{host}}/txt/js/origin/原始JS.js","searchable":1,"quickSearch":1,"filterable":1,"ext":"{}"},
{"key":"drpy_zbk","name":"真不卡(drpy)","type":3,"api":"js_drpy_zbk","searchable":1,"quickSearch":1,"filterable":1,"ext":"{{host}}/txt/pluto/drpy.js"}, {"key":"drpy_zbk","name":"真不卡(drpy)","type":3,"api":"js_drpy_zbk","searchable":1,"quickSearch":1,"filterable":1,"ext":"{{host}}/txt/pluto/drpy.js"},
......
3.9.23 3.9.23beta1
\ No newline at end of file \ No newline at end of file
...@@ -23,6 +23,7 @@ String.prototype.rstrip = function (chars) { ...@@ -23,6 +23,7 @@ String.prototype.rstrip = function (chars) {
return this.replace(regex, ""); return this.replace(regex, "");
}; };
var showMode = 'single'; var showMode = 'single';
var searchDriver = '';
/** /**
* 打印日志 * 打印日志
* @param any 任意变量 * @param any 任意变量
...@@ -95,6 +96,7 @@ function get_drives(name) { ...@@ -95,6 +96,7 @@ function get_drives(name) {
function init(ext) { function init(ext) {
const data = http.get(ext).json(); const data = http.get(ext).json();
searchDriver = (data.find(x=>x.search)||{}).name||'';
data.forEach(item => { data.forEach(item => {
let _path_param = []; let _path_param = [];
if(item.params){ if(item.params){
...@@ -107,6 +109,7 @@ function init(ext) { ...@@ -107,6 +109,7 @@ function init(ext) {
server: item.server.endsWith("/") ? item.server.rstrip("/") : item.server, server: item.server.endsWith("/") ? item.server.rstrip("/") : item.server,
startPage: item.startPage || '/', //首页 startPage: item.startPage || '/', //首页
showAll: item.showAll === true, //默认只显示 视频和文件夹,如果想显示全部 showAll 设置true showAll: item.showAll === true, //默认只显示 视频和文件夹,如果想显示全部 showAll 设置true
search: !!item.search, //是否支持搜索,只有小丫的可以,多个可搜索只取最前面的一个
params: item.params || {}, params: item.params || {},
_path_param: _path_param, _path_param: _path_param,
settings: {}, settings: {},
...@@ -298,7 +301,7 @@ function category(tid, pg, filter, extend) { ...@@ -298,7 +301,7 @@ function category(tid, pg, filter, extend) {
}); });
} }
function getAll(tid,drives,path){ function getAll(otid,tid,drives,path){
try { try {
const content = category(tid, null, false, null); const content = category(tid, null, false, null);
const { list } = JSON.parse(content); const { list } = JSON.parse(content);
...@@ -311,7 +314,8 @@ function getAll(tid,drives,path){ ...@@ -311,7 +314,8 @@ function getAll(tid,drives,path){
const pl = path.split("/"); const pl = path.split("/");
const vod_name = pl[pl.length - 2] || drives.name; const vod_name = pl[pl.length - 2] || drives.name;
let vod = { let vod = {
vod_id: tid, // vod_id: tid,
vod_id: otid,
vod_name: vod_name, vod_name: vod_name,
type_name: "文件夹", type_name: "文件夹",
vod_pic: "https://avatars.githubusercontent.com/u/97389433?s=120&v=4", vod_pic: "https://avatars.githubusercontent.com/u/97389433?s=120&v=4",
...@@ -331,15 +335,25 @@ function getAll(tid,drives,path){ ...@@ -331,15 +335,25 @@ function getAll(tid,drives,path){
} }
function detail(tid) { function detail(tid) {
let isSearch = tid.endsWith('#search#');
let otid = tid;
tid = tid.replace('#search#','');
let { drives, path } = get_drives_path(tid); let { drives, path } = get_drives_path(tid);
if (path.endsWith("/")) { //长按文件夹可以 加载里面全部视频到详情 if (path.endsWith("/")) { //长按文件夹可以 加载里面全部视频到详情
return getAll(tid,drives,path); return getAll(otid,tid,drives,path);
} else { } else {
if(showMode!=='all'){ if(isSearch){
return getAll(otid,tid,drives,path);
}else if(showMode==='all'){
let new_tid = tid.split('/').slice(0,-1).join('/')+'/';
print(`全集模式 tid:${tid}=>tid:${new_tid}`);
let { drives, path } = get_drives_path(new_tid);
return getAll(otid,new_tid,drives,path);
} else{
let paths = path.split("@@@"); let paths = path.split("@@@");
let vod_name = paths[0].substring(paths[0].lastIndexOf("/") + 1); let vod_name = paths[0].substring(paths[0].lastIndexOf("/") + 1);
let vod = { let vod = {
vod_id: tid, vod_id: otid,
vod_name: vod_name, vod_name: vod_name,
type_name: "文件", type_name: "文件",
vod_pic: "https://avatars.githubusercontent.com/u/97389433?s=120&v=4", vod_pic: "https://avatars.githubusercontent.com/u/97389433?s=120&v=4",
...@@ -353,11 +367,6 @@ function detail(tid) { ...@@ -353,11 +367,6 @@ function detail(tid) {
return JSON.stringify({ return JSON.stringify({
'list': [vod] 'list': [vod]
}); });
}else{
let new_tid = tid.split('/').slice(0,-1).join('/')+'/';
print(`全集模式 tid:${tid}=>tid:${new_tid}`);
let { drives, path } = get_drives_path(new_tid);
return getAll(new_tid,drives,path);
} }
} }
} }
...@@ -380,9 +389,33 @@ function play(flag, id, flags) { ...@@ -380,9 +389,33 @@ function play(flag, id, flags) {
} }
function search(wd, quick) { function search(wd, quick) {
return JSON.stringify({ print(__drives);
'list': [] print('可搜索的alist驱动:'+searchDriver);
}); if(!searchDriver){
return JSON.stringify({
'list': []
});
}else{
let driver = __drives[searchDriver];
print(driver);
let html = http.get(driver.server + '/search?box='+wd+'&url=').text();
let lists = pdfa(html,'div&&ul&&a');
print(lists.length);
let vods = [];
lists.forEach(it=>{
let vid = searchDriver+'$'+pdfh(it,'a&&href')+'#search#';
vods.push({
vod_name:pdfh(it,'a&&Text'),
vod_id:vid,
vod_pic:'http://img1.3png.com/281e284a670865a71d91515866552b5f172b.png',
vod_remarks:searchDriver
});
});
print(vods);
return JSON.stringify({
'list': vods
});
}
} }
function get_size(sz) { function get_size(sz) {
......
此差异已折叠。
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
[获取本地设备信息](https://m.jb51.net/article/140716.htm) [获取本地设备信息](https://m.jb51.net/article/140716.htm)
###### 2022/11/22 ###### 2022/11/22
- [X] 增加了alist的api,版本号升级至 3.9.23 - [X] 增加了alist的api,版本号升级至 3.9.23
- [X] 支持alist搜索小雅的结构,配置里加 "search": true, 仅取前面第一个alist
- [X] 需要在custom.conf加一行自定义配置,例如: - [X] 需要在custom.conf加一行自定义配置,例如:
```json ```json
{"key":"Alist","name":"Alist","type":3,"api":"{{host}}/libs/alist.min.js","searchable":0,"quickSearch":0,"filterable":0,"ext":"{{host}}/txt/json/alist.json"}, {"key":"Alist","name":"Alist","type":3,"api":"{{host}}/libs/alist.min.js","searchable":0,"quickSearch":0,"filterable":0,"ext":"{{host}}/txt/json/alist.json"},
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"server": "http://alist.xiaoya.pro/", "server": "http://alist.xiaoya.pro/",
"startPage": "/", "startPage": "/",
"showAll": false, "showAll": false,
"search": true,
"params": { "params": {
"/abc": { "/abc": {
"password": "123" "password": "123"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册