Add files via upload

This commit is contained in:
潇洒 2024-07-06 12:08:03 +08:00 committed by GitHub
parent 1eb3a7e709
commit 1b4f9b2f89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,7 +4,7 @@ globalThis.getRandomItem = function (items) {
var rule = {
title: '采集之王[合]',
author: '道长',
version: '20240705 beta12',
version: '20240705 beta16',
update_info: ``.trim(),
host: '',
homeTid: '',
@ -26,6 +26,7 @@ var rule = {
play_parse: true,
parse_url: '',
search_match: false,
search_pic: true,
预处理: $js.toString(() => {
function getClasses(item) {
let classes = [];
@ -55,11 +56,15 @@ var rule = {
log('当前程序支持批量请求[batchFetch],搜索限制已设置为16');
}
let _url = rule.params;
log(`传入参数:${_url}`);
if (_url && typeof(_url) === 'string' && /^(http|file)/.test(_url)) {
if (_url.includes('#')) {
let _url_params = _url.split('#');
if (_url.includes('$')) {
let _url_params = _url.split('$');
_url = _url_params[0];
rule.search_match = !!(_url_params[1]);
if (_url_params.length > 2) {
rule.search_pic = !!(_url_params[2]);
}
}
let html = request(_url);
let json = JSON.parse(html);
@ -202,6 +207,7 @@ var rule = {
log('start:' + start);
log('end:' + end);
log('搜索模式:' + searchMode);
log('精准搜索:' + rule.search_match);
if (start < canSearch.length) {
let search_classes = canSearch.slice(start, end);
let urls = [];
@ -213,6 +219,7 @@ var rule = {
_url = _url.replace("#TruePage#", "" + truePage);
urls.push(_url);
});
let results_list = [];
let results = [];
if (typeof(batchFetch) === 'function') {
let reqUrls = urls.map(it => {
@ -224,6 +231,8 @@ var rule = {
}
});
let rets = batchFetch(reqUrls);
let detailUrls = [];
let detailUrlCount = 0;
rets.forEach((ret, idx) => {
let it = search_classes[idx];
if (ret) {
@ -231,6 +240,7 @@ var rule = {
let json = JSON.parse(ret);
let data = json.list;
data.forEach(i => {
i.site_name = it.type_name;
i.vod_id = it.type_id + '$' + i.vod_id;
i.vod_remarks = i.vod_remarks + '|' + it.type_name;
});
@ -238,13 +248,57 @@ var rule = {
data = data.filter(item => item.vod_name && (new RegExp(KEY, 'i')).test(item.vod_name))
}
if (data.length > 0) {
results = results.concat(data);
if (rule.search_pic && !data[0].vod_pic) {
log(`当前搜索站点【${it.type_name}】没图片,尝试访问二级去获取图片`);
let detailUrl = urls[idx].split('wd=')[0] + 'ac=detail&ids=' + data.map(k => k.vod_id.split('$')[1]).join(',');
detailUrls.push(detailUrl);
results_list.push({
data: data,
has_pic: false,
detailUrlCount: detailUrlCount
});
detailUrlCount++;
} else {
results_list.push({
data: data,
has_pic: true
});
}
}
} catch (e) {
log(`请求:${it.type_id}发生错误:${e.message}`)
}
}
});
let reqUrls2 = detailUrls.map(it => {
return {
url: it,
options: {
timeout: rule.timeout
}
}
});
let rets2 = batchFetch(reqUrls2);
for (let k = 0; k < results_list.length; k++) {
let result_data = results_list[k].data;
if (!results_list[k].has_pic) {
try {
let detailJson = JSON.parse(rets2[results_list[k].detailUrlCount]);
log('二级数据列表元素数:' + detailJson.list.length);
result_data.forEach((d, _seq) => {
let detailVodPic = detailJson.list.find(vod => vod.vod_id.toString() === d.vod_id.split('$')[1]);
if (detailVodPic) {
Object.assign(d, {
vod_pic: detailVodPic.vod_pic
});
}
});
} catch (e) {
log(`强制获取网站${result_data[0].site_name}的搜索图片失败:${e.message}`);
}
}
results = results.concat(result_data);
}
} else {
urls.forEach((_url, idx) => {
let it = search_classes[idx];
@ -260,6 +314,24 @@ var rule = {
data = data.filter(item => item.vod_name && (new RegExp(KEY, 'i')).test(item.vod_name))
}
if (data.length > 0) {
if (rule.search_pic && !data[0].vod_pic) {
log(`当前搜索站点【${it.type_name}】没图片,尝试访问二级去获取图片`);
let detailUrl = urls[idx].split('wd=')[0] + 'ac=detail&ids=' + data.map(k => k.vod_id.split('$')[1]).join(',');
try {
let detailJson = JSON.parse(request(detailUrl));
log('二级数据列表元素数:' + detailJson.list.length);
data.forEach((d, _seq) => {
let detailVodPic = detailJson.list.find(vod => vod.vod_id.toString() === d.vod_id.split('$')[1]);
if (detailVodPic) {
Object.assign(d, {
vod_pic: detailVodPic.vod_pic
});
}
});
} catch (e) {
log(`强制获取网站${it.type_id}的搜索图片失败:${e.message}`);
}
}
results = results.concat(data);
}
results = results.concat(data);
@ -300,4 +372,6 @@ var rule = {
} else {
input = parse_url + input;
}
}
}),
}