Add files via upload

This commit is contained in:
潇洒 2024-10-14 11:49:15 +08:00 committed by GitHub
parent 34a2c0451f
commit b3cf262ba9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,377 +1,381 @@
globalThis.getRandomItem = function (items) { globalThis.getRandomItem = function (items) {
return items[Math.random() * items.length | 0]; return items[Math.random() * items.length | 0];
} }
var rule = { var rule = {
title: '采集之王[合]', title: '采集之王[合]',
author: '道长', author: '道长',
version: '20240705 beta16', version: '20240706 beta17',
update_info: ``.trim(), update_info: ``.trim(),
host: '', host: '',
homeTid: '', homeTid: '',
homeUrl: '/api.php/provide/vod/?ac=detail&t={{rule.homeTid}}', homeUrl: '/api.php/provide/vod/?ac=detail&t={{rule.homeTid}}',
detailUrl: '/api.php/provide/vod/?ac=detail&ids=fyid', detailUrl: '/api.php/provide/vod/?ac=detail&ids=fyid',
searchUrl: '/api.php/provide/vod/?wd=**&pg=#TruePage##page=fypage', searchUrl: '/api.php/provide/vod/?wd=**&pg=#TruePage##page=fypage',
classUrl: '/api.php/provide/vod/', classUrl: '/api.php/provide/vod/',
url: '/api.php/provide/vod/?ac=detail&pg=fypage&t=fyfilter', url: '/api.php/provide/vod/?ac=detail&pg=fypage&t=fyfilter',
filter_url: '{{fl.类型}}', filter_url: '{{fl.类型}}',
headers: { headers: {
'User-Agent': 'MOBILE_UA' 'User-Agent': 'MOBILE_UA'
}, },
timeout: 5000, timeout: 5000,
limit: 20, limit: 20,
search_limit: 10, search_limit: 10,
searchable: 1, searchable: 1,
quickSearch: 0, quickSearch: 0,
filterable: 1, filterable: 1,
play_parse: true, play_parse: true,
parse_url: '', parse_url: '',
search_match: false, search_match: false,
search_pic: true, search_pic: true,
预处理: $js.toString(() => { 预处理: $js.toString(() => {
function getClasses(item) { function getClasses(item) {
let classes = []; let classes = [];
if (item.class_name && item.class_url) { if (item.class_name && item.class_url) {
if (!/&|电影|电视剧|综艺|动漫[\u4E00-\u9FA5]+/.test(item.class_name)) { if (!/&|电影|电视剧|综艺|动漫[\u4E00-\u9FA5]+/.test(item.class_name)) {
try { try {
item.class_name = ungzip(item.class_name) item.class_name = ungzip(item.class_name)
} catch (e) { } catch (e) {
log(`不识别的class_name导致gzip解码失败:${e}`) log(`不识别的class_name导致gzip解码失败:${e}`)
return classes return classes
} }
} }
let names = item.class_name.split('&'); let names = item.class_name.split('&');
let urls = item.class_url.split('&'); let urls = item.class_url.split('&');
let cnt = Math.min(names.length, urls.length); let cnt = Math.min(names.length, urls.length);
for (let i = 0; i < cnt; i++) { for (let i = 0; i < cnt; i++) {
classes.push({ classes.push({
'type_id': urls[i], 'type_id': urls[i],
'type_name': names[i] 'type_name': names[i]
}); });
} }
} }
return classes return classes
} }
if (typeof(batchFetch) === 'function') { if (typeof(batchFetch) === 'function') {
rule.search_limit = 16; rule.search_limit = 16;
log('当前程序支持批量请求[batchFetch],搜索限制已设置为16'); log('当前程序支持批量请求[batchFetch],搜索限制已设置为16');
} }
let _url = rule.params; let _url = rule.params;
log(`传入参数:${_url}`); log(`传入参数:${_url}`);
if (_url && typeof(_url) === 'string' && /^(http|file)/.test(_url)) { if (_url && typeof(_url) === 'string' && /^(http|file)/.test(_url)) {
if (_url.includes('$')) { if (_url.includes('$')) {
let _url_params = _url.split('$'); let _url_params = _url.split('$');
_url = _url_params[0]; _url = _url_params[0];
rule.search_match = !!(_url_params[1]); rule.search_match = !!(_url_params[1]);
if (_url_params.length > 2) { if (_url_params.length > 2) {
rule.search_pic = !!(_url_params[2]); rule.search_pic = !!(_url_params[2]);
} }
} }
let html = request(_url); let html = request(_url);
let json = JSON.parse(html); let json = JSON.parse(html);
let _classes = []; let _classes = [];
rule.filter = {}; rule.filter = {};
rule.filter_def = {}; rule.filter_def = {};
json.forEach(it => { json.forEach(it => {
let _obj = { let _obj = {
type_name: it.name, type_name: it.name,
type_id: it.url, type_id: it.url,
parse_url: it.parse_url || '', parse_url: it.parse_url || '',
searchable: it.searchable !== 0, searchable: it.searchable !== 0,
api: it.api || '', api: it.api || '',
cate_exclude: it.cate_exclude || '', cate_exclude: it.cate_exclude || '',
}; cate_excludes: it.cate_excludes || [],
_classes.push(_obj); };
try { _classes.push(_obj);
let json1 = []; try {
if (it.class_name && it.class_url) { let json1 = [];
json1 = getClasses(it); if (it.class_name && it.class_url) {
} else { json1 = getClasses(it);
json1 = JSON.parse(request(urljoin(_obj.type_id, _obj.api || rule.classUrl))).class; } else {
} json1 = JSON.parse(request(urljoin(_obj.type_id, _obj.api || rule.classUrl))).class;
if (_obj.cate_exclude) { }
json1 = json1.filter(cl => !new RegExp(_obj.cate_exclude, 'i').test(cl.type_name)); if (_obj.cate_excludes && Array.isArray(_obj.cate_excludes) && _obj.cate_excludes.length > 0) {
} json1 = json1.filter(cl => !_obj.cate_excludes.includes(cl.type_name));
rule.filter[_obj.type_id] = [{ } else if (_obj.cate_exclude) {
"key": "类型", json1 = json1.filter(cl => !new RegExp(_obj.cate_exclude, 'i').test(cl.type_name));
"name": "类型", }
"value": json1.map(i => { rule.filter[_obj.type_id] = [{
return { "key": "类型",
"n": i.type_name, "name": "类型",
'v': i.type_id "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 ];
}; if (json1.length > 0) {
} rule.filter_def[it.url] = {
} catch (e) { "类型": json1[0].type_id
rule.filter[it.url] = [{ };
"key": "类型", }
"name": "类型", } catch (e) {
"value": [{ rule.filter[it.url] = [{
"n": "全部", "key": "类型",
"v": "" "name": "类型",
} "value": [{
] "n": "全部",
} "v": ""
]; }
} ]
}); }
rule.classes = _classes; ];
} }
}), });
class_parse: $js.toString(() => { rule.classes = _classes;
input = rule.classes; }
}), }),
推荐: $js.toString(() => { class_parse: $js.toString(() => {
VODS = []; input = rule.classes;
if (rule.classes) { }),
let randomClass = getRandomItem(rule.classes); 推荐: $js.toString(() => {
let _url = urljoin(randomClass.type_id, input); VODS = [];
if (randomClass.api) { if (rule.classes) {
_url = _url.replace('/api.php/provide/vod/', randomClass.api) let randomClass = getRandomItem(rule.classes);
} let _url = urljoin(randomClass.type_id, input);
try { if (randomClass.api) {
let html = request(_url, { _url = _url.replace('/api.php/provide/vod/', randomClass.api)
timeout: rule.timeout }
}); try {
let json = JSON.parse(html); let html = request(_url, {
VODS = json.list; timeout: rule.timeout
VODS.forEach(it => { });
it.vod_id = randomClass.type_id + '$' + it.vod_id; let json = JSON.parse(html);
it.vod_remarks = it.vod_remarks + '|' + randomClass.type_name; VODS = json.list;
}); VODS.forEach(it => {
} catch (e) {} it.vod_id = randomClass.type_id + '$' + it.vod_id;
} it.vod_remarks = it.vod_remarks + '|' + randomClass.type_name;
}), });
一级: $js.toString(() => { } catch (e) {}
VODS = []; }
if (rule.classes) { }),
let _url = urljoin(MY_CATE, input); 一级: $js.toString(() => {
let current_vod = rule.classes.find(item => item.type_id === MY_CATE); VODS = [];
if (current_vod && current_vod.api) { if (rule.classes) {
_url = _url.replace('/api.php/provide/vod/', current_vod.api) let _url = urljoin(MY_CATE, input);
} let current_vod = rule.classes.find(item => item.type_id === MY_CATE);
let html = request(_url); if (current_vod && current_vod.api) {
let json = JSON.parse(html); _url = _url.replace('/api.php/provide/vod/', current_vod.api)
VODS = json.list; }
VODS.forEach(it => { let html = request(_url);
it.vod_id = MY_CATE + '$' + it.vod_id let json = JSON.parse(html);
}); VODS = json.list;
} VODS.forEach(it => {
}), it.vod_id = MY_CATE + '$' + it.vod_id
二级: $js.toString(() => { });
VOD = {}; }
if (orId === 'update_info') { }),
VOD = { 二级: $js.toString(() => {
vod_content: rule.update_info.trim(), VOD = {};
vod_name: '更新日志', if (orId === 'update_info') {
type_name: '更新日志', VOD = {
vod_pic: 'https://resource-cdn.tuxiaobei.com/video/FtWhs2mewX_7nEuE51_k6zvg6awl.png', vod_content: rule.update_info.trim(),
vod_remarks: `版本:${rule.version}`, vod_name: '更新日志',
vod_play_from: '道长在线', type_name: '更新日志',
vod_play_url: '随机小视频$http://api.yujn.cn/api/zzxjj.php', vod_pic: 'https://resource-cdn.tuxiaobei.com/video/FtWhs2mewX_7nEuE51_k6zvg6awl.png',
}; vod_remarks: `版本:${rule.version}`,
} else { vod_play_from: '道长在线',
if (rule.classes) { vod_play_url: '随机小视频$http://api.yujn.cn/api/zzxjj.php',
let _url = urljoin(fyclass, input); };
let current_vod = rule.classes.find(item => item.type_id === fyclass); } else {
if (current_vod && current_vod.api) { if (rule.classes) {
_url = _url.replace('/api.php/provide/vod/', current_vod.api) let _url = urljoin(fyclass, input);
} let current_vod = rule.classes.find(item => item.type_id === fyclass);
let html = request(_url); if (current_vod && current_vod.api) {
let json = JSON.parse(html); _url = _url.replace('/api.php/provide/vod/', current_vod.api)
let data = json.list; }
VOD = data[0]; let html = request(_url);
if (current_vod && current_vod.type_name) { let json = JSON.parse(html);
VOD.vod_play_from = VOD.vod_play_from.split('$$$').map(it => current_vod.type_name + '|' + it).join('$$$') 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('$$$')
}), }
搜索: $js.toString(() => { }
VODS = []; }
if (rule.classes) { }),
let canSearch = rule.classes.filter(it => it.searchable); 搜索: $js.toString(() => {
let page = Number(MY_PAGE); VODS = [];
page = (MY_PAGE - 1) % Math.ceil(canSearch.length / rule.search_limit) + 1; if (rule.classes) {
let truePage = Math.ceil(MY_PAGE / Math.ceil(canSearch.length / rule.search_limit)); let canSearch = rule.classes.filter(it => it.searchable);
if (rule.search_limit) { let page = Number(MY_PAGE);
let start = (page - 1) * rule.search_limit; page = (MY_PAGE - 1) % Math.ceil(canSearch.length / rule.search_limit) + 1;
let end = page * rule.search_limit; let truePage = Math.ceil(MY_PAGE / Math.ceil(canSearch.length / rule.search_limit));
let t1 = new Date().getTime(); if (rule.search_limit) {
let searchMode = typeof(batchFetch) === 'function' ? '批量' : '单个'; let start = (page - 1) * rule.search_limit;
log('start:' + start); let end = page * rule.search_limit;
log('end:' + end); let t1 = new Date().getTime();
log('搜索模式:' + searchMode); let searchMode = typeof(batchFetch) === 'function' ? '批量' : '单个';
log('精准搜索:' + rule.search_match); log('start:' + start);
if (start < canSearch.length) { log('end:' + end);
let search_classes = canSearch.slice(start, end); log('搜索模式:' + searchMode);
let urls = []; log('精准搜索:' + rule.search_match);
search_classes.forEach(it => { log('强制获取图片:' + rule.search_pic);
let _url = urljoin(it.type_id, input); if (start < canSearch.length) {
if (it.api) { let search_classes = canSearch.slice(start, end);
_url = _url.replace('/api.php/provide/vod/', it.api) let urls = [];
} search_classes.forEach(it => {
_url = _url.replace("#TruePage#", "" + truePage); let _url = urljoin(it.type_id, input);
urls.push(_url); if (it.api) {
}); _url = _url.replace('/api.php/provide/vod/', it.api)
let results_list = []; }
let results = []; _url = _url.replace("#TruePage#", "" + truePage);
if (typeof(batchFetch) === 'function') { urls.push(_url);
let reqUrls = urls.map(it => { });
return { let results_list = [];
url: it, let results = [];
options: { if (typeof(batchFetch) === 'function') {
timeout: rule.timeout let reqUrls = urls.map(it => {
} return {
} url: it,
}); options: {
let rets = batchFetch(reqUrls); timeout: rule.timeout
let detailUrls = []; }
let detailUrlCount = 0; }
rets.forEach((ret, idx) => { });
let it = search_classes[idx]; let rets = batchFetch(reqUrls);
if (ret) { let detailUrls = [];
try { let detailUrlCount = 0;
let json = JSON.parse(ret); rets.forEach((ret, idx) => {
let data = json.list; let it = search_classes[idx];
data.forEach(i => { if (ret) {
i.site_name = it.type_name; try {
i.vod_id = it.type_id + '$' + i.vod_id; let json = JSON.parse(ret);
i.vod_remarks = i.vod_remarks + '|' + it.type_name; let data = json.list;
}); data.forEach(i => {
if (rule.search_match) { i.site_name = it.type_name;
data = data.filter(item => item.vod_name && (new RegExp(KEY, 'i')).test(item.vod_name)) i.vod_id = it.type_id + '$' + i.vod_id;
} i.vod_remarks = i.vod_remarks + '|' + it.type_name;
if (data.length > 0) { });
if (rule.search_pic && !data[0].vod_pic) { if (rule.search_match) {
log(`当前搜索站点【${it.type_name}】没图片,尝试访问二级去获取图片`); data = data.filter(item => item.vod_name && (new RegExp(KEY, 'i')).test(item.vod_name))
let detailUrl = urls[idx].split('wd=')[0] + 'ac=detail&ids=' + data.map(k => k.vod_id.split('$')[1]).join(','); }
detailUrls.push(detailUrl); if (data.length > 0) {
results_list.push({ if (rule.search_pic && !data[0].vod_pic) {
data: data, log(`当前搜索站点【${it.type_name}】没图片,尝试访问二级去获取图片`);
has_pic: false, let detailUrl = urls[idx].split('wd=')[0] + 'ac=detail&ids=' + data.map(k => k.vod_id.split('$')[1]).join(',');
detailUrlCount: detailUrlCount detailUrls.push(detailUrl);
}); results_list.push({
detailUrlCount++; data: data,
} else { has_pic: false,
results_list.push({ detailUrlCount: detailUrlCount
data: data, });
has_pic: true detailUrlCount++;
}); } else {
} results_list.push({
} data: data,
} catch (e) { has_pic: true
log(`请求:${it.type_id}发生错误:${e.message}`) });
} }
} }
}); } catch (e) {
let reqUrls2 = detailUrls.map(it => { log(`请求:${it.type_id}发生错误:${e.message}`)
return { }
url: it, }
options: { });
timeout: rule.timeout let reqUrls2 = detailUrls.map(it => {
} return {
} url: it,
}); options: {
let rets2 = batchFetch(reqUrls2); timeout: rule.timeout
for (let k = 0; k < results_list.length; k++) { }
let result_data = results_list[k].data; }
if (!results_list[k].has_pic) { });
try { let rets2 = reqUrls2.length > 0 ? batchFetch(reqUrls2) : [];
let detailJson = JSON.parse(rets2[results_list[k].detailUrlCount]); for (let k = 0; k < results_list.length; k++) {
log('二级数据列表元素数:' + detailJson.list.length); let result_data = results_list[k].data;
result_data.forEach((d, _seq) => { if (!results_list[k].has_pic) {
let detailVodPic = detailJson.list.find(vod => vod.vod_id.toString() === d.vod_id.split('$')[1]); try {
if (detailVodPic) { let detailJson = JSON.parse(rets2[results_list[k].detailUrlCount]);
Object.assign(d, { log('二级数据列表元素数:' + detailJson.list.length);
vod_pic: detailVodPic.vod_pic 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, {
} catch (e) { vod_pic: detailVodPic.vod_pic
log(`强制获取网站${result_data[0].site_name}的搜索图片失败:${e.message}`); });
} }
} });
results = results.concat(result_data); } catch (e) {
} log(`强制获取网站${result_data[0].site_name}的搜索图片失败:${e.message}`);
} else { }
urls.forEach((_url, idx) => { }
let it = search_classes[idx]; results = results.concat(result_data);
try { }
let html = request(_url); } else {
let json = JSON.parse(html); urls.forEach((_url, idx) => {
let data = json.list; let it = search_classes[idx];
data.forEach(i => { try {
i.vod_id = it.type_id + '$' + i.vod_id; let html = request(_url);
i.vod_remarks = i.vod_remarks + '|' + it.type_name; let json = JSON.parse(html);
}); let data = json.list;
if (rule.search_match) { data.forEach(i => {
data = data.filter(item => item.vod_name && (new RegExp(KEY, 'i')).test(item.vod_name)) i.vod_id = it.type_id + '$' + i.vod_id;
} i.vod_remarks = i.vod_remarks + '|' + it.type_name;
if (data.length > 0) { });
if (rule.search_pic && !data[0].vod_pic) { if (rule.search_match) {
log(`当前搜索站点【${it.type_name}】没图片,尝试访问二级去获取图片`); data = data.filter(item => item.vod_name && (new RegExp(KEY, 'i')).test(item.vod_name))
let detailUrl = urls[idx].split('wd=')[0] + 'ac=detail&ids=' + data.map(k => k.vod_id.split('$')[1]).join(','); }
try { if (data.length > 0) {
let detailJson = JSON.parse(request(detailUrl)); if (rule.search_pic && !data[0].vod_pic) {
log('二级数据列表元素数:' + detailJson.list.length); log(`当前搜索站点【${it.type_name}】没图片,尝试访问二级去获取图片`);
data.forEach((d, _seq) => { let detailUrl = urls[idx].split('wd=')[0] + 'ac=detail&ids=' + data.map(k => k.vod_id.split('$')[1]).join(',');
let detailVodPic = detailJson.list.find(vod => vod.vod_id.toString() === d.vod_id.split('$')[1]); try {
if (detailVodPic) { let detailJson = JSON.parse(request(detailUrl));
Object.assign(d, { log('二级数据列表元素数:' + detailJson.list.length);
vod_pic: detailVodPic.vod_pic data.forEach((d, _seq) => {
}); let detailVodPic = detailJson.list.find(vod => vod.vod_id.toString() === d.vod_id.split('$')[1]);
} if (detailVodPic) {
}); Object.assign(d, {
} catch (e) { vod_pic: detailVodPic.vod_pic
log(`强制获取网站${it.type_id}的搜索图片失败:${e.message}`); });
} }
} });
results = results.concat(data); } catch (e) {
} log(`强制获取网站${it.type_id}的搜索图片失败:${e.message}`);
results = results.concat(data); }
} catch (e) { }
log(`请求:${it.type_id}发生错误:${e.message}`) results = results.concat(data);
} }
}); results = results.concat(data);
} } catch (e) {
VODS = results; log(`请求:${it.type_id}发生错误:${e.message}`)
let t2 = new Date().getTime(); }
log(`${searchMode}搜索:${urls.length}个站耗时:${(Number(t2) - Number(t1))}ms`) });
} }
} VODS = results;
} let t2 = new Date().getTime();
}), log(`${searchMode}搜索:${urls.length}个站耗时:${(Number(t2) - Number(t1))}ms`)
lazy: $js.toString(() => { }
let parse_url = ''; }
if (flag && flag.includes('|')) { }
let type_name = flag.split('|')[0]; }),
let current_vod = rule.classes.find(item => item.type_name === type_name); lazy: $js.toString(() => {
if (current_vod && current_vod.parse_url) { let parse_url = '';
parse_url = current_vod.parse_url if (flag && flag.includes('|')) {
} let type_name = flag.split('|')[0];
} let current_vod = rule.classes.find(item => item.type_name === type_name);
if (/\.(m3u8|mp4)/.test(input)) { if (current_vod && current_vod.parse_url) {
input = { parse_url = current_vod.parse_url
parse: 0, }
url: input }
} if (/\.(m3u8|mp4)/.test(input)) {
} else { input = {
if (parse_url.startsWith('json:')) { parse: 0,
let purl = parse_url.replace('json:', '') + input; url: input
let html = request(purl); }
input = { } else {
parse: 0, if (parse_url.startsWith('json:')) {
url: JSON.parse(html).url let purl = parse_url.replace('json:', '') + input;
} let html = request(purl);
} else { input = {
input = parse_url + input; parse: 0,
} url: JSON.parse(html).url
} }
}), } else {
} input = parse_url + input;
}
}
}),
}