Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from diygod:master #2309

Merged
merged 5 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ const calculateValue = () => {
lastfm: {
api_key: envs.LASTFM_API_KEY,
},
lightnovel: {
cookie: envs.SECURITY_KEY,
},
manhuagui: {
cookie: envs.MHGUI_COOKIE,
},
Expand Down
87 changes: 87 additions & 0 deletions lib/v2/imiker/jinghua.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');

module.exports = async (ctx) => {
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 50;

const rootUrl = 'https://ask.imiker.com';
const apiUrl = new URL('explore/main/list/', rootUrl).href;
const currentUrl = new URL(``, rootUrl).href;

const { data: response } = await got(apiUrl, {
searchParams: {
page: 1,
page_size: limit,
type: 'jinghua',
types: 'json',
},
});

let items = response.slice(0, limit).map((item) => ({
title: item.question_content,
link: new URL(`question/${item.id}`, rootUrl).href,
description: art(path.join(__dirname, 'templates/description.art'), {
headImage: item.headimage,
author: item.nick_name,
question: item.question_detail,
}),
author: item.nick_name,
guid: `imiker-${item.id}`,
pubDate: parseDate(item.add_time_timestamp * 1000),
upvotes: item.count?.vote_count ?? 0,
comments: item.count?.answer_count ?? 0,
}));

items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);

const content = cheerio.load(detailResponse);

content('h5.img-for-lazyload').each((_, e) => {
const image = content(e).find('img');

content(e).replaceWith(
art(path.join(__dirname, 'templates/description.art'), {
image: {
src: image.prop('data-original'),
alt: image.prop('alt'),
width: image.prop('data-width'),
height: image.prop('data-height'),
},
})
);
});

item.title = content('div.title h1').text();
item.description += art(path.join(__dirname, 'templates/description.art'), {
description: content('div#warp').html(),
});
item.author = content('div.name').text();

return item;
})
)
);

const author = '米课圈';
const description = '精华';
const icon = new URL('favicon.ico', rootUrl).href;

ctx.state.data = {
item: items,
title: `${author} - ${description}`,
link: currentUrl,
description,
language: 'zh',
icon,
logo: icon,
subtitle: description,
author,
allowEmpty: true,
};
};
3 changes: 3 additions & 0 deletions lib/v2/imiker/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/ask/jinghua': ['nczitzk'],
};
13 changes: 13 additions & 0 deletions lib/v2/imiker/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'imiker.com': {
_name: '米课',
'.': [
{
title: '米课圈精华',
docs: 'https://docs.rsshub.app/routes/new-media#mi-ke-mi-ke-quan-jing-hua',
source: ['/explore/find'],
target: '/imiker/ask/jinghua',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/imiker/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/ask/jinghua', require('./jinghua'));
};
32 changes: 32 additions & 0 deletions lib/v2/imiker/templates/description.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{ if image?.src }}
<figure>
<img
{{ if image.alt }}
alt="{{ image.alt }}"
{{ /if }}
{{ if image.width }}
alt="{{ image.width }}"
{{ /if }}
{{ if image.height }}
alt="{{ image.height }}"
{{ /if }}
src="{{ image.src }}">
</figure>
{{ /if }}

{{ if headImage }}
<figure>
<img src="{{ headImage }}">
{{ if author }}
<figcaption>{{ author }}</figcaption>
{{ /if }}
</figure>
{{ /if }}

{{ if question }}
<blockquote>{{ question }}</blockquote>
{{ /if }}

{{ if description }}
{{@ description }}
{{ /if }}
62 changes: 62 additions & 0 deletions lib/v2/lightnovel/lightNovel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const { parseDate } = require('@/utils/parse-date');
const got = require('@/utils/got');
const cheerio = require('cheerio');
const config = require('@/config').value;

module.exports = async (ctx) => {
const baseUrl = 'https://www.lightnovel.us';
const { type, keywords, security_key = config.lightnovel.cookie } = ctx.params;
const { data: response } = await got({
method: 'POST',
url: `${baseUrl}/proxy/api/search/search-result`,
headers: {
// 此处是为什么
'User-Agent': config.trueUA,
},
json: {
is_encrypted: 0,
platform: 'pc',
client: 'web',
sign: '',
gz: 0,
d: {
q: keywords,
type: 0,
page: 1,
security_key,
},
},
});
const list = response.data.articles
.map((item) => ({
title: item.title,
link: `${baseUrl}/cn/detail/${item.aid}`,
pubDate: parseDate(item.time),
author: item.author,
}))
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 5);

const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got({
method: 'GET',
url: item.link,
headers: {
'User-Agent': config.trueUA,
},
});

const $ = cheerio.load(response);
item.description = $('#article-main-contents').html();
return item;
})
)
);

ctx.state.data = {
title: `轻之国度-追踪${keywords}更新-${type} `,
link: baseUrl,
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/lightnovel/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/:keywords/:security_key?': ['nightmare-mio'],
};
13 changes: 13 additions & 0 deletions lib/v2/lightnovel/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'lightNovel.us': {
_name: '轻之国度',
'.': [
{
title: '文章更新阅读',
docs: 'https://docs.rsshub.app/routes/anime#qing-zhi-guo-du',
source: '/',
target: '/lightnovel/:keywords/:security_key',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/lightnovel/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:keywords/:security_key?', require('./lightNovel'));
};
7 changes: 4 additions & 3 deletions lib/v2/sse/disclosure.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const query = ctx.params.query ?? ''; // beginDate=2018-08-18&endDate=2020-09-01&productId=600696
const host = 'https://www.sse.com.cn';
const queries = query.split('&').reduce((acc, cur) => {
const [key, value] = cur.split('=');
acc[key] = value;
Expand All @@ -30,11 +29,13 @@ module.exports = async (ctx) => {
},
});

const pdfHost = 'https://static.sse.com.cn';

const items = response.data.result.map((item) => ({
title: item.TITLE,
description: `${host}${item.URL}`,
description: `${pdfHost}${item.URL}`,
pubDate: parseDate(item.ADDDATE),
link: `${host}${item.URL}`,
link: `${pdfHost}${item.URL}`,
author: item.SECURITY_NAME,
}));

Expand Down
1 change: 1 addition & 0 deletions lib/v2/xsijishe/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
'/forum/:fid': ['akynazh'],
'/rank/:type': ['akynazh'],
};
12 changes: 12 additions & 0 deletions lib/v2/xsijishe/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ module.exports = {
}
},
},
{
title: '周排行榜',
docs: 'https://docs.rsshub.app/routes/bbs#si-ji-she',
source: ['/*'],
target: '/xsijishe/rank/weekly',
},
{
title: '月排行榜',
docs: 'https://docs.rsshub.app/routes/bbs#si-ji-she',
source: ['/*'],
target: '/xsijishe/rank/monthly',
},
],
},
};
60 changes: 60 additions & 0 deletions lib/v2/xsijishe/rank.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const baseUrl = 'https://xsijishe.com';

module.exports = async (ctx) => {
const rankType = ctx.params.type;
let title;
let rankId;
if (rankType === 'weekly') {
title = '司机社综合周排行榜';
rankId = 'nex_recons_demens';
} else if (rankType === 'monthly') {
title = '司机社综合月排行榜';
rankId = 'nex_recons_demens1';
} else {
throw Error('Invalid rank type');
}
const url = `${baseUrl}/portal.php`;
const resp = await got(url);
const $ = cheerio.load(resp.data);
let items = $(`#${rankId} dd`)
.toArray()
.map((item) => {
item = $(item);
const title = item.find('h5').text().trim();
const link = item.find('a').attr('href');
return {
title,
link: `${baseUrl}/${link}`,
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const resp = await got(item.link);
const $ = cheerio.load(resp.data);
const firstViewBox = $('.t_f').first();

firstViewBox.find('img').each((_, img) => {
img = $(img);
if (img.attr('zoomfile')) {
img.attr('src', img.attr('zoomfile'));
img.removeAttr('zoomfile');
img.removeAttr('file');
}
img.removeAttr('onmouseover');
});

item.description = firstViewBox.html();
return item;
})
)
);
ctx.state.data = {
title,
link: url,
description: title,
item: items,
};
};
1 change: 1 addition & 0 deletions lib/v2/xsijishe/router.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = function (router) {
router.get('/forum/:fid', require('./forum'));
router.get('/rank/:type', require('./rank'));
};
5 changes: 5 additions & 0 deletions website/docs/install/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ Warning: Two Factor Authentication is **not** supported.

- `LASTFM_API_KEY`: Last.fm API Key


### LightNovel.us

- `SECURITY_KEY`: security_key in the token,please remove %22,example `{%22security_key%22:%223cXXXX%22}`,only need 3cXXXX

### Email

- `EMAIL_CONFIG_{email}`: Mail setting, replace `{email}` with the email account, replace `@` and `.` in email account with `_`, e.g. `EMAIL_CONFIG_xxx_gmail_com`. The value is in the format of `password=password&host=server&port=port`, eg:
Expand Down
6 changes: 6 additions & 0 deletions website/docs/routes/anime.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,12 @@ You can use some RSS parsing libraries (like `feedpraser` in `Python`) to receiv

<Route author="junfengP" path="/manxiaosi/book/:id" example="/manxiaosi/book/90" paramsDesc={['漫画id,漫画主页的地址栏中']} radar="1"/>

## 轻之国度 {#qing-zhi-guo-du}

### 文章更新阅读 {#qing-zhi-guo-du-wen-zhang-geng-xin-yue-du}

<Route author="nightmare-mio" path="/lightnovel/:keywords/:security_key" example="/lightnovel/歡迎來到實力至上主義的教室/3cfc2dc63f3575ee42e12823188ad1b5:1709125:0" paramsDesc={['关键字,可以模糊匹配,但最好精确匹配。默认为文章类型','cookie,由于文章有防爬,所以必须携带cookie请求。route中的cookie优先级高于环境变量cookie,取token中的security_key值']} radar="1"/>

## 三界异次元 {#san-jie-yi-ci-yuan}

### 三界异次元 {#san-jie-yi-ci-yuan-san-jie-yi-ci-yuan}
Expand Down
4 changes: 4 additions & 0 deletions website/docs/routes/bbs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,10 @@ When accessing Joeyray's Bar, `SCBOY_BBS_TOKEN` needs to be filled in `environme

## 司机社 {#si-ji-she}

### 排行榜 {#si-ji-she-pai-hang-bang}

<Route author="akynazh" example="/xsijishe/rank/weekly" path="/xsijishe/rank/:type" paramsDesc={['排行榜类型: weekly | monthly']} radar="1"/>

### 论坛 {#si-ji-she-lun-tan}

<Route author="akynazh" example="/xsijishe/forum/51" path="/xsijishe/forum/:fid" paramsDesc={['子论坛 id']} radar="1">
Expand Down
Loading
Loading