Skip to content

Commit

Permalink
Merge branch 'DIYgod/master' into dependabot/npm_and_yarn/eslint-8.53.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL committed Nov 13, 2023
2 parents 9765b51 + 9d1b29f commit faf053b
Show file tree
Hide file tree
Showing 51 changed files with 1,449 additions and 369 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs-search-index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: sleep 2m
if: github.event_name == 'push'
- name: Run docs-scraper
timeout-minutes: 15
timeout-minutes: 30
env:
HOST_URL: ${{ secrets.MEILISEARCH_HOST_URL }}
API_KEY: ${{ secrets.MEILISEARCH_API_KEY }}
Expand Down
4 changes: 2 additions & 2 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2545,8 +2545,8 @@ router.get('/wanwansub/info/:id', lazyloadRouteHandler('./routes/wanwansub/info'
router.get('/wanwansub/:id?', lazyloadRouteHandler('./routes/wanwansub/index'));

// FIX 字幕侠
router.get('/zimuxia/portfolio/:id', lazyloadRouteHandler('./routes/zimuxia/portfolio'));
router.get('/zimuxia/:category?', lazyloadRouteHandler('./routes/zimuxia/index'));
// router.get('/zimuxia/portfolio/:id', lazyloadRouteHandler('./routes/zimuxia/portfolio'));
// router.get('/zimuxia/:category?', lazyloadRouteHandler('./routes/zimuxia/index'));

// Hugo 更新日志
router.get('/hugo/releases', lazyloadRouteHandler('./routes/hugo/releases'));
Expand Down
4 changes: 3 additions & 1 deletion lib/v2/cbc/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ module.exports = async (ctx) => {
author = head.author.map((author) => author.name).join(' & ');
}
const pubDate = head.datePublished;
const description = $('div[data-cy=storyWrapper]').html();
const descriptionDom = $('div[data-cy=storyWrapper]');
descriptionDom.find('div[class=share]').remove();
const description = descriptionDom.html();

return { title, author, pubDate, description, link };
})
Expand Down
24 changes: 15 additions & 9 deletions lib/v2/cnbeta/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);

const token = encodeURI($('meta[name="csrf-token"]').attr('content'));
const apiUrl = `${rootUrl}/home/more?&type=${$('div[data-type]').attr('data-type')}&page=1&_csrf=${token}&_=${new Date().getTime()}`;
const apiUrl = `${rootUrl}/home/more?&type=${$('div[data-type]').data('type')}&page=1&_csrf=${token}&_=${Date.now()}`;

response = await got(apiUrl);

const items = response.data.result.list.map((item) => ({
title: item.title,
description: item.hometext,
author: item.source.split('@http')[0],
pubDate: timezone(parseDate(item.inputtime), +8),
link: item.url_show.startsWith('//') ? `https:${item.url_show}` : item.url_show.replace('http:', 'https:'),
category: item.label.name,
}));
const items = type
? response.data.result.list.map((item) => ({
title: item.title,
description: item.hometext,
author: item.source.split('@http')[0],
pubDate: timezone(parseDate(item.inputtime), +8),
link: item.url_show.startsWith('//') ? `https:${item.url_show}` : item.url_show.replace('http:', 'https:'),
category: item.label.name,
}))
: response.data.result.map((item) => ({
title: item.title,
link: item.url_show.startsWith('//') ? `https:${item.url_show}` : item.url_show.replace('http:', 'https:'),
category: item.label.name,
}));

ctx.state.data = {
title: $('title').text(),
Expand Down
3 changes: 3 additions & 0 deletions lib/v2/cnbeta/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');

const rootUrl = 'https://www.cnbeta.com.tw';

Expand All @@ -17,6 +19,7 @@ module.exports = {

item.description = content('.article-summary').html() + content('.article-content').html();
item.author = content('header.title div.meta span.source').text();
item.pubDate ??= timezone(parseDate(content('.meta span').first().text(), 'YYYY年MM月DD日 HH:mm'), +8);

return item;
})
Expand Down
34 changes: 13 additions & 21 deletions lib/v2/dongqiudi/special.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const utils = require('./utils');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const id = ctx.params.id;
const response = await got(`https://www.dongqiudi.com/special/${id}`);
const { data: response } = await got(`https://www.dongqiudi.com/api/old/columns/${id}`);

const $ = cheerio.load(response.data);

const host = 'https://www.dongqiudi.com';

const list = $('.detail.special ul li h3')
.slice(0, ctx.query.limit ? Number(ctx.query.limit) : 5)
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('a').text(),
link: host + item.find('a').attr('href'),
};
});
const list = response.data.map((item) => ({
title: item.title,
link: `https://www.dongqiudi.com/articles/${item.aid}.html`,
mobileLink: `https://m.dongqiudi.com/article/${item.aid}.html`,
pubDate: parseDate(item.show_time, 'X'),
}));

const out = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const { data: response } = await got(item.mobileLink);

utils.ProcessFeedType2(item, response);
utils.ProcessFeedType3(item, response);

return item;
})
)
);

ctx.state.data = {
title: `懂球帝专题-${$('.detail.special h1').text()}`,
description: $('.detail.special h4').text(),
title: `懂球帝专题-${response.title}`,
description: response.description,
link: `https://www.dongqiudi.com/special/${id}`,
item: out.filter((e) => e !== undefined),
item: out.filter((e) => e),
};
};
26 changes: 25 additions & 1 deletion lib/v2/dongqiudi/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const ProcessFeedType2 = (item, response) => {
}

if (Object.keys(data).length > 0) {
const body = ProcessVideo(cheerio.load(data.body));
const body = ProcessVideo(cheerio.load(data.body, null, false));
ProcessHref(body('a'));
ProcessImg(body('img'));
item.description = body.html();
Expand All @@ -138,10 +138,34 @@ const ProcessFeedType2 = (item, response) => {
}
};

const ProcessFeedType3 = (item, response) => {
const $ = cheerio.load(response);
const initialState = JSON.parse(
$('script:contains("window.__INITIAL_STATE__")')
.text()
.match(/window\.__INITIAL_STATE__\s*=\s*(.*?);\(/)[1]
);

// filter out undefined item
if (!initialState) {
return;
}

if (Object.keys(initialState.articleContent).length) {
const data = Object.values(initialState.articleContent)[0];
const body = ProcessVideo(cheerio.load(data.body, null, false));
ProcessHref(body('a'));
ProcessImg(body('img'));
item.description = body.html();
item.author = data.writer;
}
};

module.exports = {
ProcessVideo,
ProcessFeed,
ProcessFeedType2,
ProcessFeedType3,
ProcessHref,
ProcessImg,
};
2 changes: 1 addition & 1 deletion lib/v2/douban/people/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function tryFixStatus(status) {
isFixSuccess: false,
why: status.msg ? status.msg : '[ 内容已被设为不可见 ]',
};
} else if (!status.activity || status.text === undefined || status.text === null || !status.uri) {
} else if (status.text === undefined || status.text === null || !status.uri) {
result = {
isFixSuccess: false,
why: status.msg ? status.msg : '[ 内容已不可访问 ]',
Expand Down
4 changes: 3 additions & 1 deletion lib/v2/ehentai/ehapi.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const got = require('@/utils/got');
const logger = require('@/utils/logger');
const timezone = require('@/utils/timezone');
const cheerio = require('cheerio');
const path = require('path');
const config = require('@/config').value.ehentai;
Expand Down Expand Up @@ -76,7 +77,8 @@ async function parsePage(cache, data, get_bittorrent = false, embed_thumb = fals
async function parseElement(cache, element) {
const el = $(element);
const title = el.find('div.glink').html();
const pubDate = el.find('div[id^="posted_"]').html();
const rawDate = el.find('div[id^="posted_"]').text();
const pubDate = rawDate ? timezone(rawDate, 0) : rawDate;
let el_a;
let el_img;
// match layout
Expand Down
25 changes: 25 additions & 0 deletions lib/v2/fuliba/latest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const { data: response } = await got(`https://fuliba2023.net/wp-json/wp/v2/posts`, {
searchParams: {
per_page: ctx.query.limit ?? 100,
_embed: 1,
},
});
const items = response.map((item) => ({
title: item.title.rendered,
link: item.link,
guid: item.guid.rendered,
description: item.content.rendered,
pubDate: parseDate(item.date_gmt),
author: item._embedded.author[0].name,
}));

ctx.state.data = {
title: '福利吧',
link: `https://fuliba2023.net`,
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/fuliba/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/latest': ['shinemoon'],
};
15 changes: 15 additions & 0 deletions lib/v2/fuliba/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const fuliba = {
_name: '福利吧',
'.': [
{
title: '最新',
docs: 'https://docs.rsshub.app/routes/new-media#fuliba',
source: '/',
target: '/fuliba/latest',
},
],
};

module.exports = {
'fuliba2023.net': fuliba,
};
3 changes: 3 additions & 0 deletions lib/v2/fuliba/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/latest', require('./latest'));
};
91 changes: 91 additions & 0 deletions lib/v2/hostmonit/cloudflareyes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');

const lines = {
CM: '中国移动',
CU: '中国联通',
CT: '中国电信',
};

module.exports = async (ctx) => {
const { type = 'v4' } = ctx.params;
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;

const domain = 'hostmonit.com';
const title = `CloudFlareYes${type === 'v6' ? type.toUpperCase() : ''}`;

const rootUrl = `https://stock.${domain}`;
const rootApiUrl = `https://api.${domain}`;
const apiUrl = new URL('get_optimization_ip', rootApiUrl).href;
const currentUrl = new URL(title, rootUrl).href;

const key = 'iDetkOys';

const { data: response } = await got.post(apiUrl, {
json: {
key,
...(type === 'v6'
? {
type: 'v6',
}
: {}),
},
});

const items = response.info.slice(0, limit).map((item) => {
const ip = item.ip;
const latency = item.latency === undefined ? undefined : `${item.latency}ms`;
const line = item.line === undefined ? undefined : lines.hasOwnProperty(item.line) ? lines[item.line] : item.line;
const loss = item.loss === undefined ? undefined : `${item.loss}%`;
const node = item.node;
const speed = item.speed === undefined ? undefined : `${item.speed} KB/s`;
const pubDate = timezone(parseDate(item.time), +8);

return {
title: art(path.join(__dirname, 'templates/title.art'), {
line,
latency,
loss,
speed,
node,
ip,
}),
link: currentUrl,
description: art(path.join(__dirname, 'templates/description.art'), {
line,
node,
ip,
latency,
loss,
speed,
}),
author: node,
category: [line, latency, loss, node].filter((c) => c),
guid: `${domain}-${title}-${ip}#${pubDate.toISOString()}`,
pubDate,
};
});

const { data: currentResponse } = await got(currentUrl);

const $ = cheerio.load(currentResponse);

const icon = new URL($('link[rel="icon"]').prop('href'), rootUrl).href;

ctx.state.data = {
item: items,
title: $('title').text().replace(/- .*$/, `- ${title}`),
link: currentUrl,
description: $('meta[name="description"]').prop('content'),
language: $('html').prop('lang'),
icon,
logo: icon,
subtitle: title,
author: $('title').text().split(/\s-/)[0],
allowEmpty: true,
};
};
3 changes: 3 additions & 0 deletions lib/v2/hostmonit/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/cloudflareyes/:type?': ['nczitzk'],
};
17 changes: 17 additions & 0 deletions lib/v2/hostmonit/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
'hostmonit.com': {
_name: '全球主机监控',
stock: [
{
title: 'CloudFlareYes',
docs: 'https://docs.rsshub.app/routes/other#quan-qiu-zhu-ji-jian-kong-cloudflareyes',
source: ['/:type'],
target: (params) => {
const type = params.type;

return `/hostmonit/${type}`;
},
},
],
},
};
8 changes: 8 additions & 0 deletions lib/v2/hostmonit/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const redirectToV6 = (ctx) => ctx.redirect('/hostmonit/cloudflareyes/v6');

module.exports = (router) => {
router.get('/cloudflareyes/:type?', require('./cloudflareyes'));
router.get('/cloudflareyesv6', (ctx) => redirectToV6(ctx));
router.get('/CloudFlareYes/:type?', require('./cloudflareyes'));
router.get('/CloudFlareYesv6', (ctx) => redirectToV6(ctx));
};
Loading

0 comments on commit faf053b

Please sign in to comment.