Add files via upload
This commit is contained in:
parent
af7c20b99f
commit
90e27579ab
246
JS/采集之王.js
246
JS/采集之王.js
@ -1,35 +1,29 @@
|
||||
/**
|
||||
* 强烈推荐静态分类。可以加快速度!!!
|
||||
* 传参 ?type=url¶ms=../json/采集.json
|
||||
* 传参 ?type=url¶ms=../json/采集静态.json
|
||||
* [{"name":"暴风资源","url":"https://bfzyapi.com","parse_url":""},{"name":"飞刀资源","url":"http://www.feidaozy.com","parse_url":""},{"name":"黑木耳资源","url":"https://www.heimuer.tv","parse_url":""}]
|
||||
*/
|
||||
globalThis.getRandomItem = function (items) {
|
||||
return items[Math.random() * items.length | 0];
|
||||
}
|
||||
var rule = {
|
||||
title: '采集之王[合]',
|
||||
author: '道长',
|
||||
version: '20240621 beta6',
|
||||
version: '20240624 beta8',
|
||||
host: '',
|
||||
homeTid: '', // 首页推荐。一般填写第一个资源站的想要的推荐分类的id.可以空
|
||||
homeTid: '',
|
||||
homeUrl: '/api.php/provide/vod/?ac=detail&t={{rule.homeTid}}',
|
||||
detailUrl: '/api.php/provide/vod/?ac=detail&ids=fyid',
|
||||
searchUrl: '/api.php/provide/vod/?wd=**&pg=#TruePage##page=fypage',
|
||||
classUrl: '/api.php/provide/vod/',
|
||||
url: '/api.php/provide/vod/?ac=detail&pg=fypage&t=fyfilter',
|
||||
filter_url: '{{fl.类型}}',
|
||||
headers: {'User-Agent': 'MOBILE_UA'},
|
||||
timeout: 5000, // class_name: '电影&电视剧&综艺&动漫',
|
||||
headers: {
|
||||
'User-Agent': 'MOBILE_UA'
|
||||
},
|
||||
timeout: 5000,
|
||||
limit: 20,
|
||||
search_limit: 5, // 搜索限制取前5个,可以注释掉,就不限制搜索
|
||||
searchable: 1,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 1,//是否启用分类筛选,
|
||||
search_limit: 5,
|
||||
searchable: 1,
|
||||
quickSearch: 0,
|
||||
filterable: 1,
|
||||
play_parse: true,
|
||||
parse_url: '', // 这个参数暂时不起作用。聚合类的每个资源应该有自己独立的解析口。单独配置在采集.json里的parse_url有效
|
||||
// params: 'http://127.0.0.1:5707/files/json/%E9%87%87%E9%9B%86.json',
|
||||
// params: 'http://127.0.0.1:5707/files/json/采集静态.json',
|
||||
// hostJs:$js.toString(()=>{
|
||||
//
|
||||
// }),
|
||||
parse_url: '',
|
||||
预处理: $js.toString(() => {
|
||||
function getClasses(item) {
|
||||
let classes = [];
|
||||
@ -54,9 +48,12 @@ var rule = {
|
||||
}
|
||||
return classes
|
||||
}
|
||||
|
||||
if (typeof(batchFetch) === 'function') {
|
||||
rule.search_limit = 16;
|
||||
log('当前程序支持批量请求[batchFetch],搜索限制已设置为16');
|
||||
}
|
||||
let _url = rule.params;
|
||||
if (_url && typeof (_url) === 'string' && /^(http|file)/.test(_url)) {
|
||||
if (_url && typeof(_url) === 'string' && /^(http|file)/.test(_url)) {
|
||||
let html = request(_url);
|
||||
let json = JSON.parse(html);
|
||||
let _classes = [];
|
||||
@ -69,8 +66,6 @@ var rule = {
|
||||
parse_url: it.parse_url || '',
|
||||
api: it.api || '',
|
||||
cate_exclude: it.cate_exclude || '',
|
||||
// class_name: it.class_name || '',
|
||||
// class_url: it.class_url || '',
|
||||
};
|
||||
_classes.push(_obj);
|
||||
try {
|
||||
@ -84,82 +79,64 @@ var rule = {
|
||||
json1 = json1.filter(cl => !new RegExp(_obj.cate_exclude, 'i').test(cl.type_name));
|
||||
}
|
||||
rule.filter[_obj.type_id] = [{
|
||||
"key": "类型", "name": "类型", "value": json1.map(i => {
|
||||
return {"n": i.type_name, 'v': i.type_id}
|
||||
})
|
||||
}];
|
||||
"key": "类型",
|
||||
"name": "类型",
|
||||
"value": json1.map(i => {
|
||||
return {
|
||||
"n": i.type_name,
|
||||
'v': i.type_id
|
||||
}
|
||||
})
|
||||
}
|
||||
];
|
||||
if (json1.length > 0) {
|
||||
rule.filter_def[it.url] = {"类型": json1[0].type_id};
|
||||
rule.filter_def[it.url] = {
|
||||
"类型": json1[0].type_id
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
rule.filter[it.url] = [{"key": "类型", "name": "类型", "value": [{"n": "全部", "v": ""}]}];
|
||||
rule.filter[it.url] = [{
|
||||
"key": "类型",
|
||||
"name": "类型",
|
||||
"value": [{
|
||||
"n": "全部",
|
||||
"v": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
}
|
||||
});
|
||||
rule.classes = _classes;
|
||||
}
|
||||
}),
|
||||
// class_parse: $js.toString(() => {
|
||||
// let _url = rule.params;
|
||||
// if (_url && typeof (_url) === 'string' && _url.startsWith('http')) {
|
||||
// let html = request(_url);
|
||||
// let json = JSON.parse(html);
|
||||
// let _classes = [];
|
||||
// homeObj.filter = {};
|
||||
// rule.filter_def = {};
|
||||
// json.forEach(it => {
|
||||
// let _obj = {
|
||||
// type_name: it.name,
|
||||
// type_id: it.url,
|
||||
// parse_url: it.parse_url || '',
|
||||
// cate_exclude: it.cate_exclude || '',
|
||||
// };
|
||||
// _classes.push(_obj);
|
||||
// try {
|
||||
// let json1 = JSON.parse(request(urljoin(_obj.type_id, rule.classUrl))).class;
|
||||
// if (_obj.cate_exclude) {
|
||||
// json1 = json1.filter(cl => !new RegExp(_obj.cate_exclude, 'i').test(cl.type_name));
|
||||
// }
|
||||
// homeObj.filter[_obj.type_id] = [{
|
||||
// "key": "类型", "name": "类型", "value": json1.map(i => {
|
||||
// return {"n": i.type_name, 'v': i.type_id}
|
||||
// })
|
||||
// }];
|
||||
// if (json1.length > 0) {
|
||||
// rule.filter_def[it.url] = {"类型": json1[0].type_id};
|
||||
// }
|
||||
// } catch (e) {
|
||||
// homeObj.filter[it.url] = [{"key": "类型", "name": "类型", "value": [{"n": "全部", "v": ""}]}];
|
||||
// }
|
||||
// });
|
||||
// rule.classes = _classes;
|
||||
// input = _classes;
|
||||
// }
|
||||
// }),
|
||||
class_parse: $js.toString(() => {
|
||||
input = rule.classes;
|
||||
}),
|
||||
推荐: $js.toString(() => {
|
||||
VODS = [];
|
||||
if (rule.classes) {
|
||||
let _url = urljoin(rule.classes[0].type_id, input);
|
||||
if (rule.classes[0].api) {
|
||||
_url = _url.replace('/api.php/provide/vod/', rule.classes[0].api)
|
||||
let randomClass = getRandomItem(rule.classes);
|
||||
let _url = urljoin(randomClass.type_id, input);
|
||||
if (randomClass.api) {
|
||||
_url = _url.replace('/api.php/provide/vod/', randomClass.api)
|
||||
}
|
||||
try {
|
||||
let html = request(_url);
|
||||
let html = request(_url, {
|
||||
timeout: rule.timeout
|
||||
});
|
||||
let json = JSON.parse(html);
|
||||
VODS = json.list;
|
||||
VODS.forEach(it => {
|
||||
it.vod_id = rule.classes[0].type_id + '$' + it.vod_id
|
||||
it.vod_id = randomClass.type_id + '$' + it.vod_id;
|
||||
it.vod_remarks = it.vod_remarks + '|' + randomClass.type_name;
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}),
|
||||
一级: $js.toString(() => {
|
||||
VODS = [];
|
||||
if (rule.classes) {
|
||||
// log(input);
|
||||
let _url = urljoin(MY_CATE, input);
|
||||
let current_vod = rule.classes.find(item => item.type_id === MY_CATE);
|
||||
if (current_vod && current_vod.api) {
|
||||
@ -173,21 +150,32 @@ var rule = {
|
||||
});
|
||||
}
|
||||
}),
|
||||
// 一级: 'json:list;vod_name;vod_pic;vod_remarks;vod_id;vod_play_from',
|
||||
二级: $js.toString(() => {
|
||||
VOD = [];
|
||||
if (rule.classes) {
|
||||
let _url = urljoin(fyclass, input);
|
||||
let current_vod = rule.classes.find(item => item.type_id === fyclass);
|
||||
if (current_vod && current_vod.api) {
|
||||
_url = _url.replace('/api.php/provide/vod/', current_vod.api)
|
||||
}
|
||||
let html = request(_url);
|
||||
let json = JSON.parse(html);
|
||||
let data = json.list;
|
||||
VOD = data[0];
|
||||
if (current_vod && current_vod.type_name) {
|
||||
VOD.vod_play_from = VOD.vod_play_from.split('$$$').map(it => current_vod.type_name + '|' + it).join('$$$')
|
||||
VOD = {};
|
||||
if (orId === 'update_info') {
|
||||
VOD = {
|
||||
vod_content: rule.update_info.trim(),
|
||||
vod_name: '更新日志',
|
||||
type_name: '更新日志',
|
||||
vod_pic: 'https://resource-cdn.tuxiaobei.com/video/FtWhs2mewX_7nEuE51_k6zvg6awl.png',
|
||||
vod_remarks: `版本:${rule.version}`,
|
||||
vod_play_from: '道长在线',
|
||||
vod_play_url: '嗅探播放$https://resource-cdn.tuxiaobei.com/video/10/8f/108fc9d1ac3f69d29a738cdc097c9018.mp4'
|
||||
};
|
||||
} else {
|
||||
if (rule.classes) {
|
||||
let _url = urljoin(fyclass, input);
|
||||
let current_vod = rule.classes.find(item => item.type_id === fyclass);
|
||||
if (current_vod && current_vod.api) {
|
||||
_url = _url.replace('/api.php/provide/vod/', current_vod.api)
|
||||
}
|
||||
let html = request(_url);
|
||||
let json = JSON.parse(html);
|
||||
let data = json.list;
|
||||
VOD = data[0];
|
||||
if (current_vod && current_vod.type_name) {
|
||||
VOD.vod_play_from = VOD.vod_play_from.split('$$$').map(it => current_vod.type_name + '|' + it).join('$$$')
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
@ -200,38 +188,74 @@ var rule = {
|
||||
if (rule.search_limit) {
|
||||
let start = (page - 1) * rule.search_limit;
|
||||
let end = page * rule.search_limit;
|
||||
|
||||
let t1 = new Date().getTime();
|
||||
let searchMode = typeof(batchFetch) === 'function' ? '批量' : '单个';
|
||||
log('start:' + start);
|
||||
log('end:' + end);
|
||||
log('搜索模式:' + searchMode);
|
||||
if (start < rule.classes.length) {
|
||||
let search_classes = rule.classes.slice(start, end);
|
||||
let urls = [];
|
||||
search_classes.forEach(it => {
|
||||
let _url = urljoin(it.type_id, input);
|
||||
if (it.api) {
|
||||
_url = _url.replace('/api.php/provide/vod/', it.api)
|
||||
}
|
||||
_url = _url.replace("#TruePage#", "" + truePage);
|
||||
try {
|
||||
let html = request(_url);
|
||||
let json = JSON.parse(html);
|
||||
let data = json.list;
|
||||
data.forEach(i => {
|
||||
i.vod_id = it.type_id + '$' + i.vod_id;
|
||||
i.vod_remarks = i.vod_remarks + '|' + it.type_name;
|
||||
});
|
||||
VODS = VODS.concat(data);
|
||||
} catch (e) {
|
||||
log(`请求:${it.type_id}发生错误:${e.message}`)
|
||||
}
|
||||
|
||||
urls.push(_url);
|
||||
});
|
||||
|
||||
let results = [];
|
||||
if (typeof(batchFetch) === 'function') {
|
||||
let reqUrls = urls.map(it => {
|
||||
return {
|
||||
url: it,
|
||||
options: {
|
||||
timeout: rule.timeout
|
||||
}
|
||||
}
|
||||
});
|
||||
let rets = batchFetch(reqUrls);
|
||||
rets.forEach((ret, idx) => {
|
||||
let it = search_classes[idx];
|
||||
if (ret) {
|
||||
try {
|
||||
let json = JSON.parse(ret);
|
||||
let data = json.list;
|
||||
data.forEach(i => {
|
||||
i.vod_id = it.type_id + '$' + i.vod_id;
|
||||
i.vod_remarks = i.vod_remarks + '|' + it.type_name;
|
||||
});
|
||||
results = results.concat(data);
|
||||
} catch (e) {
|
||||
log(`请求:${it.type_id}发生错误:${e.message}`)
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
urls.forEach((_url, idx) => {
|
||||
let it = search_classes[idx];
|
||||
try {
|
||||
let html = request(_url);
|
||||
let json = JSON.parse(html);
|
||||
let data = json.list;
|
||||
data.forEach(i => {
|
||||
i.vod_id = it.type_id + '$' + i.vod_id;
|
||||
i.vod_remarks = i.vod_remarks + '|' + it.type_name;
|
||||
});
|
||||
results = results.concat(data);
|
||||
} catch (e) {
|
||||
log(`请求:${it.type_id}发生错误:${e.message}`)
|
||||
}
|
||||
});
|
||||
}
|
||||
VODS = results;
|
||||
let t2 = new Date().getTime();
|
||||
log(`${searchMode}搜索:${urls.length}个站耗时:${(Number(t2) - Number(t1))}ms`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
lazy: $js.toString(() => {
|
||||
// lazy想办法用对应的parse_url,但是有难度,暂未实现
|
||||
let parse_url = '';
|
||||
if (flag && flag.includes('|')) {
|
||||
let type_name = flag.split('|')[0];
|
||||
@ -241,15 +265,21 @@ var rule = {
|
||||
}
|
||||
}
|
||||
if (/\.(m3u8|mp4)/.test(input)) {
|
||||
input = {parse: 0, url: input}
|
||||
input = {
|
||||
parse: 0,
|
||||
url: input
|
||||
}
|
||||
} else {
|
||||
if (parse_url.startsWith('json:')) {
|
||||
let purl = parse_url.replace('json:', '') + input;
|
||||
let html = request(purl);
|
||||
input = {parse: 0, url: JSON.parse(html).url}
|
||||
input = {
|
||||
parse: 0,
|
||||
url: JSON.parse(html).url
|
||||
}
|
||||
} else {
|
||||
input = parse_url + input;
|
||||
}
|
||||
}
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user