Merge remote-tracking branch 'upstream/master' into add-unit-image

This commit is contained in:
user
2020-04-27 13:16:01 +08:00
19 changed files with 241 additions and 120 deletions
+1
View File
@@ -40,6 +40,7 @@ const calculateValue = () => {
requestRetry: parseInt(envs.REQUEST_RETRY) || 2, // 请求失败重试次数
// 是否显示 Debug 信息,取值 boolean 'false' 'key' ,取值为 'false' false 时永远不显示,取值为 'key' 时带上 ?debug=key 显示
debugInfo: envs.DEBUG_INFO || true,
disallowRobot: envs.DISALLOW_ROBOT !== '0' && envs.DISALLOW_ROBOT !== 'false',
titleLengthLimit: parseInt(envs.TITLE_LENGTH_LIMIT) || 150,
redis: {
url: envs.REDIS_URL || 'redis://localhost:6379/',
+26 -11
View File
@@ -1,4 +1,5 @@
const Router = require('@koa/router');
const config = require('@/config').value;
const router = new Router();
// 遍历整个 routes 文件夹,导入模块路由 router.js 和 router-custom.js 文件
@@ -24,13 +25,23 @@ router.get('/', require('./routes/index'));
// test
router.get('/test/:id', require('./routes/test'));
router.get('/robots.txt', async (ctx, next) => {
if (config.disallowRobot) {
ctx.set('Content-Type', 'text/plain');
ctx.body = 'User-agent: *\nDisallow: /';
} else {
ctx.throw(404, 'Not Found');
}
await next();
});
// RSSHub
router.get('/rsshub/rss', require('./routes/rsshub/routes')); // 弃用
router.get('/rsshub/routes', require('./routes/rsshub/routes'));
router.get('/rsshub/sponsors', require('./routes/rsshub/sponsors'));
// 1draw
router.get('/1draw/', require('./routes/1draw/index'));
router.get('/1draw', require('./routes/1draw/index'));
// 1X Magazine
router.get('/1x/magazine', require('./routes/1x/magazine'));
@@ -143,7 +154,7 @@ router.get('/mzitu/tag/:tag', require('./routes/mzitu/tag'));
// pixiv
router.get('/pixiv/user/bookmarks/:id', require('./routes/pixiv/bookmarks'));
router.get('/pixiv/user/illustfollows', require('./routes/pixiv/illustfollow'));
router.get('/pixiv/user/:id/', require('./routes/pixiv/user'));
router.get('/pixiv/user/:id', require('./routes/pixiv/user'));
router.get('/pixiv/ranking/:mode/:date?', require('./routes/pixiv/ranking'));
router.get('/pixiv/search/:keyword/:order?/:r18?', require('./routes/pixiv/search'));
@@ -528,7 +539,7 @@ router.get('/novel/ptwxz/:id1/:id2', require('./routes/novel/ptwxz'));
router.get('/novel/zhaishuyuan/:id', require('./routes/novel/zhaishuyuan'));
// 中国气象网
router.get('/weatheralarm', require('./routes/weatheralarm'));
router.get('/weatheralarm/:province?', require('./routes/weatheralarm'));
// Gitlab
router.get('/gitlab/explore/:type', require('./routes/gitlab/explore'));
@@ -694,8 +705,8 @@ router.get('/whu/news/:type?', require('./routes/universities/whu/news'));
// 华中科技大学
router.get('/hust/auto/notice/:type?', require('./routes/universities/hust/aia/notice'));
router.get('/hust/auto/news/', require('./routes/universities/hust/aia/news'));
router.get('/hust/aia/news/', require('./routes/universities/hust/aia/news'));
router.get('/hust/auto/news', require('./routes/universities/hust/aia/news'));
router.get('/hust/aia/news', require('./routes/universities/hust/aia/news'));
router.get('/hust/aia/notice/:type?', require('./routes/universities/hust/aia/notice'));
// 井冈山大学
@@ -778,7 +789,7 @@ router.get('/guokr/:channel', require('./routes/guokr/calendar'));
// 联合早报
router.get('/zaobao/realtime/:section?', require('./routes/zaobao/realtime'));
router.get('/zaobao/znews/:section?', require('./routes/zaobao/znews'));
router.get('/zaobao/:type/:section', require('./routes/zaobao/'));
router.get('/zaobao/:type/:section', require('./routes/zaobao/index'));
// Apple
router.get('/apple/exchange_repair/:country?', require('./routes/apple/exchange_repair'));
@@ -1228,7 +1239,7 @@ router.get('/wenku8/chapter/:id', require('./routes/wenku8/chapter'));
// 鲸跃汽车
router.get('/whalegogo/home', require('./routes/whalegogo/home'));
router.get('/whalegogo/portal/:type_id/:tagid?/', require('./routes/whalegogo/portal'));
router.get('/whalegogo/portal/:type_id/:tagid?', require('./routes/whalegogo/portal'));
// 爱思想
router.get('/aisixiang/column/:id', require('./routes/aisixiang/column'));
@@ -1379,7 +1390,7 @@ router.get('/zju/cst/:type', require('./routes/universities/zju/cst'));
// 浙江大学城市学院
router.get('/zucc/news/latest', require('./routes/universities/zucc/news'));
router.get('/zucc/cssearch/latest/:webVpn/:key/', require('./routes/universities/zucc/cssearch'));
router.get('/zucc/cssearch/latest/:webVpn/:key', require('./routes/universities/zucc/cssearch'));
// 华中师范大学
router.get('/ccnu/career', require('./routes/universities/ccnu/career'));
@@ -1898,11 +1909,11 @@ router.get('/latexstudio/home', require('./routes/latexstudio/home'));
// 上证债券信息网 - 可转换公司债券公告
router.get('/sse/convert/:query?', require('./routes/sse/convert'));
router.get('/sse/renewal/', require('./routes/sse/renewal'));
router.get('/sse/inquire/', require('./routes/sse/inquire'));
router.get('/sse/renewal', require('./routes/sse/renewal'));
router.get('/sse/inquire', require('./routes/sse/inquire'));
// 深圳证券交易所——上市公告
router.get('/szse/notice/', require('./routes/szse/notice'));
router.get('/szse/notice', require('./routes/szse/notice'));
router.get('/szse/inquire/:type', require('./routes/szse/inquire'));
// 前端艺术家每日整理&&飞冰早报
@@ -2555,6 +2566,10 @@ router.get('/51voa/:channel', require('./routes/51voa/channel'));
// zhuixinfan
router.get('/zhuixinfan/list', require('./routes/zhuixinfan/list'));
// scoresaber
router.get('/scoresaber/user/:id', require('./routes/scoresaber/user'));
// unit-image
router.get('/unit-image/films/:type?', require('./routes/unit-image/films'));
module.exports = router;
+3 -2
View File
@@ -80,9 +80,10 @@ module.exports = async (ctx) => {
const html = await fetchPageHtml(linkPath, pageId, ctx.cache);
const $ = cheerio.load(html);
const itemLinks = $('div[role=article] > div:nth-child(2) > div:nth-child(2)')
const itemLinks = $('footer > div:nth-child(2) > a:nth-child(1)')
.toArray()
.map((div) => $(div).find('a').last().attr('href'));
.map((a) => $(a).attr('href'));
const items = await Promise.all(
itemLinks.map(async (itemLink) => {
if (new RegExp(`^/.+/photos/`).test(itemLink)) {
+1 -1
View File
@@ -10,7 +10,7 @@ module.exports = async (ctx) => {
switch (gchannel) {
case 'paimai':
channelName = '拍卖信息';
link = `http://www.customs.gov.cn/customs/302249/2476857/302309/index.html`;
link = `http://www.customs.gov.cn/customs/302249/302309/index.html`;
break;
case 'fagui':
+2
View File
@@ -61,11 +61,13 @@ module.exports = async (ctx) => {
} else {
showDebug = config.debugInfo === true || config.debugInfo === ctx.query.debug;
}
const { disallowRobot } = config;
const stats = await pidusage(process.pid);
ctx.body = art(path.resolve(__dirname, '../views/welcome.art'), {
showDebug,
disallowRobot,
debug: [
config.nodeName
? {
+44
View File
@@ -0,0 +1,44 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const id = ctx.params.id;
const hostname = 'https://scoresaber.com';
const response = await got({
method: 'get',
url: `${hostname}/u/${id}&sort=2`,
});
const $ = cheerio.load(response.data);
const username = $('.is-5 a').text();
const list = $('tbody tr').reverse();
const result1 = list
.map((index, item) => {
item = $(item);
const song = item.find('.songTop.pp').text();
const mapper = item.find('.songTop.mapper').text();
const rank = item.find('.rank').text();
const time = new Date(item.find('.time').attr('title')).toLocaleString();
const ppValue = item.find('.ppValue').text();
const ppWeightedValue = item.find('.ppWeightedValue').text();
const scoreBottom = item.find('.scoreBottom').text();
return {
title: `【${song}】${mapper} ${time} ${rank} PP:${ppValue}${ppWeightedValue} - ${scoreBottom}`,
description: $('.box:first-child').html(),
link: hostname + item.find('a').attr('href') + '?search=' + username,
pubDate: time,
author: 'scoresaber',
};
})
.get();
ctx.state.data = {
title: `${username}的ScoreSaber动态`,
link: `https://scoresaber.com/u/${id}&sort=2`,
item: result1,
};
};
+15 -13
View File
@@ -1,23 +1,25 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const date = require('@/utils/date');
module.exports = async (ctx) => {
const alarmInfoURL = 'http://www.nmc.cn/f/alarm.html';
const html = (await got.get(alarmInfoURL)).data;
const $ = cheerio.load(html);
const alarmElements = $('.alarmlist > div:not(.pagination)').toArray();
const province = ctx.params.province || '&';
const alarmInfoURL = `http://www.nmc.cn/rest/findAlarm?pageNo=1&pageSize=20&signaltype=&signallevel=&province=${province}`;
const response = await got({
method: 'get',
url: alarmInfoURL,
});
const data = response.data.data;
const list = data.page.list;
ctx.state.data = {
title: '中央气象台全国气象预警',
link: alarmInfoURL,
item: alarmElements.map((el) => {
const $el = $(el);
const $aEl = $el.find('a');
link: `http://www.nmc.cn/publish/alarm.html`,
item: list.map((item) => {
const title = item.title;
const url = item.url;
return {
title: $aEl.text(),
link: `http://www.nmc.cn${$aEl.attr('href')}`,
pubDate: date($el.find('.date').text(), 8),
title: `${title}`,
link: `http://www.nmc.cn${url}`,
pubDate: `${item.issuetime}`,
};
}),
};
+1
View File
@@ -29,6 +29,7 @@ const youtubeUtils = {
const res = await getYoutube().playlistItems.list({
part,
playlistId: id,
maxResults: 50, // youtube api param value default is 5
});
return res;
},
+3
View File
@@ -3,6 +3,9 @@
<head>
<title>Welcome to RSSHub!</title>
{{ if disallowRobot }}
<meta name="robots" content="noindex">
{{ /if }}
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;