feat(route): add CnGal (#11203)

* feat(route): add CnGal

* refactor: sort path
This commit is contained in:
Harry Cheng 2022-11-03 02:18:57 +08:00 committed by GitHub
parent 0a4b2c9175
commit d725ab5bda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 90 additions and 0 deletions

View File

@ -252,6 +252,16 @@ pageClass: routes
<Route author="TonyRL" example="/creative-comic/book/117" path="/creative-comic/book/:id/:coverOnly?/:quality?" :paramsDesc="['漫畫 ID可在 URL 中找到', '僅獲取封面,非 `true` 時將獲取**全部**頁面,預設 `true`', '閱讀品質,標準畫質 `1`,高畫質 `2`,預設 `1`']" radar="1" rssbud="1"/>
## CnGal
### 每周速报
<Route author="chengyuhui" example="/cngal/weekly" path="/cngal/weekly" radar="1" rssbud="1"/>
### 制作者 / 游戏新闻
<Route author="chengyuhui" example="/cngal/entry/2693" path="/cngal/entry/:id" :paramsDesc="['词条ID游戏或制作者页面URL的最后一串数字']" radar="1" rssbud="1"/>
## DLsite
### 当前日期发售的新产品

25
lib/v2/cngal/entry.js Normal file
View File

@ -0,0 +1,25 @@
const got = require('@/utils/got');
const { art } = require('@/utils/render');
const path = require('path');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
module.exports = async (ctx) => {
const entryId = ctx.params.id;
const response = await got(`https://www.cngal.org/api/entries/GetEntryView/${entryId}`);
const data = response.data;
ctx.state.data = {
title: `CnGal - ${data.name} 的动态`,
link: `https://www.cngal.org/entries/index/${entryId}`,
item: data.newsOfEntry.map((item) => ({
title: item.title,
description: art(path.join(__dirname, 'templates/entry-description.art'), item),
pubDate: timezone(parseDate(item.happenedTime), +8),
link: item.link,
})),
};
ctx.state.json = response.data;
};

View File

@ -0,0 +1,4 @@
module.exports = {
'/entry/:id': ['chengyuhui'],
'/weekly': ['chengyuhui'],
};

19
lib/v2/cngal/radar.js Normal file
View File

@ -0,0 +1,19 @@
module.exports = {
'cngal.org': {
_name: 'CnGal',
www: [
{
title: '每周速报',
docs: 'https://docs.rsshub.app/anime.html#cngal-mei-zhou-su-bao',
source: ['/', '/weeklynews'],
target: '/cngal/weekly',
},
{
title: '制作者/游戏新闻',
docs: 'https://docs.rsshub.app/anime.html#cngal-zhi-zuo-zhe-you-xi-xin-wen',
source: ['/entries/index/:id'],
target: '/cngal/entry/:id',
},
],
},
};

4
lib/v2/cngal/router.js Normal file
View File

@ -0,0 +1,4 @@
module.exports = function (router) {
router.get('/entry/:id', require('./entry'));
router.get('/weekly', require('./weekly'));
};

View File

@ -0,0 +1,4 @@
<p>{{ briefIntroduction }}</p>
{{ if image }}
<img src="{{ image }}"/>
{{ /if }}

View File

@ -0,0 +1,4 @@
<p>{{ briefIntroduction }}</p>
{{ if mainImage }}
<img src="{{ mainImage }}"/>
{{ /if }}

20
lib/v2/cngal/weekly.js Normal file
View File

@ -0,0 +1,20 @@
const got = require('@/utils/got');
const { art } = require('@/utils/render');
const path = require('path');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const response = await got('https://www.cngal.org/api/news/GetWeeklyNewsOverview');
ctx.state.data = {
title: 'CnGal - 每周速报',
link: 'https://www.cngal.org/weeklynews',
item: response.data.map((item) => ({
title: item.name,
description: art(path.join(__dirname, 'templates/weekly-description.art'), item),
pubDate: parseDate(item.lastEditTime),
link: `https://www.cngal.org/articles/index/${item.id}`,
})),
};
ctx.state.json = response.data;
};