Skip to content

Commit

Permalink
Merge pull request #501 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Sep 22, 2023
2 parents ae1bb99 + 217b0e9 commit 195de7f
Show file tree
Hide file tree
Showing 99 changed files with 4,440 additions and 1,767 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
REDIS_URL: redis://localhost:${{ job.services.redis.ports[6379] }}/
- name: Upload coverage to Codecov
if: ${{ matrix.node-version == '18' }}
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos as documented, but seems broken

Expand Down
2 changes: 1 addition & 1 deletion lib/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const toSource = require('tosource');
const { join } = require('path');

// Namespaces that do not require radar.js
const allowNamespace = ['discourse', 'discuz', 'ehentai', 'mail', 'test'];
const allowNamespace = ['discourse', 'discuz', 'ehentai', 'lemmy', 'mail', 'test'];
// Check if a radar.js file is exist under each folder of dirname
for (const dir of fs.readdirSync(dirname)) {
const dirPath = join(dirname, dir);
Expand Down
10 changes: 5 additions & 5 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ router.get('/dekudeals/:type', lazyloadRouteHandler('./routes/dekudeals'));
router.get('/metacritic/release/:platform/:type/:sort?', lazyloadRouteHandler('./routes/metacritic/release'));

// 快科技(原驱动之家)
router.get('/kkj/news', lazyloadRouteHandler('./routes/kkj/news'));
// router.get('/kkj/news', lazyloadRouteHandler('./routes/kkj/news'));

// sixthtone
router.get('/sixthtone/news', lazyloadRouteHandler('./routes/sixthtone/news'));
Expand Down Expand Up @@ -1443,7 +1443,7 @@ router.get('/xinquji/today/internal', lazyloadRouteHandler('./routes/xinquji/int
router.get('/gbcc/trust', lazyloadRouteHandler('./routes/gbcc/trust'));

// CBC
router.get('/cbc/topics/:topic?', lazyloadRouteHandler('./routes/cbc/topics'));
// router.get('/cbc/topics/:topic?', lazyloadRouteHandler('./routes/cbc/topics'));

// discuz
// router.get('/discuz/:ver([7|x])/:cid([0-9]{2})/:link(.*)', lazyloadRouteHandler('./routes/discuz/discuz'));
Expand Down Expand Up @@ -1868,9 +1868,9 @@ router.get('/gov/chongqing/ljxq/zwgk/:caty', lazyloadRouteHandler('./routes/gov/
router.get('/12379', lazyloadRouteHandler('./routes/12379/index'));

// 鸟哥笔记
router.get('/ngbj', lazyloadRouteHandler('./routes/niaogebiji/index'));
router.get('/ngbj/today', lazyloadRouteHandler('./routes/niaogebiji/today'));
router.get('/ngbj/cat/:cat', lazyloadRouteHandler('./routes/niaogebiji/cat'));
// router.get('/ngbj', lazyloadRouteHandler('./routes/niaogebiji/index'));
// router.get('/ngbj/today', lazyloadRouteHandler('./routes/niaogebiji/today'));
// router.get('/ngbj/cat/:cat', lazyloadRouteHandler('./routes/niaogebiji/cat'));

// 梅花网
router.get('/meihua/shots/:caty', lazyloadRouteHandler('./routes/meihua/shots'));
Expand Down
52 changes: 0 additions & 52 deletions lib/routes/kkj/news.js

This file was deleted.

86 changes: 0 additions & 86 deletions lib/routes/niaogebiji/cat.js

This file was deleted.

40 changes: 0 additions & 40 deletions lib/routes/niaogebiji/index.js

This file was deleted.

29 changes: 0 additions & 29 deletions lib/routes/niaogebiji/today.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/utils/rand-user-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = ({ browser = 'chrome', os = 'mac os', device = 'desktop' }) =>
let UA = randUserAgent(device, browser, os);

if (browser === 'chrome') {
while (UA.includes('Chrome-Lighthouse') || UA.includes('Gener8') || UA.includes('HeadlessChrome') || UA.includes('SMTBot')) {
while (UA.includes('Chrome-Lighthouse') || UA.includes('Gener8') || UA.includes('HeadlessChrome') || UA.includes('SMTBot') || UA.includes('Electron') || UA.includes('Code')) {
UA = randUserAgent(device, browser, os);
}
}
Expand Down
42 changes: 42 additions & 0 deletions lib/v2/ainvest/article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const { getHeaders, randomString, encryptAES, decryptAES } = require('./utils');

module.exports = async (ctx) => {
const key = randomString(16);

const { data: response } = await got.post('https://api.ainvest.com/gw/socialcenter/v1/edu/article/listArticle', {
headers: getHeaders(key),
searchParams: {
timestamp: Date.now(),
},
data: encryptAES(
JSON.stringify({
batch: ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30,
startId: null,
tags: {
in: ['markettrends', 'premarket', 'companyinsights', 'macro'],
and: ['web', 'creationplatform'],
},
}),
key
),
});

const { data } = JSON.parse(decryptAES(response, key));

const items = data.map((item) => ({
title: item.title,
description: item.content,
link: item.sourceUrl,
pubDate: parseDate(item.postDate, 'x'),
category: [item.nickName, ...item.tags.map((tag) => tag.code)],
}));

ctx.state.data = {
title: 'AInvest - Latest Articles',
link: 'https://www.ainvest.com/news',
language: 'en',
item: items,
};
};
4 changes: 4 additions & 0 deletions lib/v2/ainvest/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'/article': ['TonyRL'],
'/news': ['TonyRL'],
};
39 changes: 39 additions & 0 deletions lib/v2/ainvest/news.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const { getHeaders, randomString, decryptAES } = require('./utils');

module.exports = async (ctx) => {
const key = randomString(16);

const { data: response } = await got('https://api.ainvest.com/gw/news_f10/v1/newsFlash/getNewsData', {
headers: getHeaders(key),
searchParams: {
terminal: 'web',
tab: 'all',
page: 1,
size: ctx.query.limit ? parseInt(ctx.query.limit, 10) : 50,
lastId: '',
timestamp: Date.now(),
},
});

const { data } = JSON.parse(decryptAES(response, key));

const items = data.content.map((item) => ({
title: item.title,
description: item.content,
link: item.sourceUrl,
pubDate: parseDate(item.publishTime, 'x'),
category: item.tagList.map((tag) => tag.nameEn),
author: item.userInfo.nickname,
upvotes: item.likeCount,
comments: item.commentCount,
}));

ctx.state.data = {
title: 'AInvest - Latest News',
link: 'https://www.ainvest.com/news',
language: 'en',
item: items,
};
};
19 changes: 19 additions & 0 deletions lib/v2/ainvest/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
'ainvest.com': {
_name: 'AInvest',
'.': [
{
title: 'Latest Article',
docs: 'https://docs.rsshub.app/finance#ainvest',
source: ['/news'],
target: '/ainvest/article',
},
{
title: 'Latest News',
docs: 'https://docs.rsshub.app/finance#ainvest',
source: ['/news'],
target: '/ainvest/news',
},
],
},
};
4 changes: 4 additions & 0 deletions lib/v2/ainvest/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = (router) => {
router.get('/article', require('./article'));
router.get('/news', require('./news'));
};
Loading

1 comment on commit 195de7f

@vercel
Copy link

@vercel vercel bot commented on 195de7f Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.