feat(route): 增加对南京艺术学院图书馆新闻的支持 (#11164)

* 南京艺术学院研究生院

* Update lib/v2/nua/gra.js

* Update lib/v2/nua/gra.js

* Update lib/v2/nua/gra.js

* Update lib/v2/nua/radar.js

* Update lib/v2/nua/radar.js

* Update lib/v2/nua/gra.js

* Update lib/v2/nua/gra.js

* Update docs/university.md

* Update docs/university.md

* 优化代码

* 优化

* update

* 补充南京艺术学院

* fix

* fix

* fix

* 更新南京艺术学院数据源。

* 更新南京艺术学院数据源。

* fix

* fix

* update

* fix doc

* fix

* Update lib/v2/nua/radar.js

* fix: yarn.lock permission

* style: auto format

* fix double fetch same page

* Update dc.js

* Revert "Merge branch 'master' of https://github.com/evnydd0sf/RSS-Hub"

This reverts commit dd56f9469b5b2462d482c202ae798b3f159f243e, reversing
changes made to d900050eb8271d0f566070eb58c2c9d87ccd6e53.

* fix

* Revert "fix"

This reverts commit 820ff88120d4fb4fc2bdcd8ee52229d1bfb83c17.

* Revert "Revert "Merge branch 'master' of https://github.com/evnydd0sf/RSS-Hub""

This reverts commit ce67e0b53c231a8a8527b7407211aff1ab7e50d4.

* 增加微信公众号解析引导。

* 修正url

* 适配微信公众号内容。

* 适配站内文章、微信公号号文章和未知文章引导。

* Update wechat-mp.js

* fix fetch wechat bug

* 增加设计学院研创、后浪模块

* bugfix

* Revert "Merge branch 'DIYgod:master' into master"

This reverts commit 102cb48db6990fd5a699d2e46bf05d58be2e5ba5, reversing
changes made to ccac4be5180ff7c2d81763efa7c09cf0b752ddc4.

* Update university.md

* Revert "Revert "Merge branch 'DIYgod:master' into master""

This reverts commit c8841910b83ec4a07e0d92d2d65feb192af9e5e3.

* fix fetch listname

* 优设网

* 优设网

* fix: switch default case

* Update lib/v2/uisdc/utils.js

* Update lib/v2/uisdc/utils.js

* Update docs/design.md

* 更新 hunter 细节猎手内容提取

* 精简代码

* 增加南京艺术学院图书馆的信息

* update

* update doc

* update

* Revert "update"

This reverts commit 87289de180c438f2b081733cc4671c8a3537f5eb.

* fix doc

* fix docs

* docs: remove extra tag

* refactor: do not ignore eslint

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
evnydd0sf 2022-11-16 00:55:47 +08:00 committed by GitHub
parent 4fa3faa597
commit 6c2277d59b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 136 additions and 12 deletions

View File

@ -40,6 +40,73 @@ Note: [Source website](https://gs.bjtu.edu.cn/) only provides articles in Chines
<RouteEn author="nczitzk" example="/mit/csail/news" path="/mit/csail/news"/>
## Nanjing University of the Arts
### Official Information
<RouteEn author="evnydd0sf" example="/nua/index/346" path="/nua/index/:type" :paramsDesc="['News Type']" radar="1">
| News Type | Parameters |
| ---- | --- |
| 公告 | 346 |
| 南艺要闻 | 332 |
</RouteEn>
### Shuangxing Information
<RouteEn author="evnydd0sf" example="/nua/sxw/230" path="/nua/sxw/:type" :paramsDesc="['News Type']" radar="1">
| News Type | Parameters |
| ---- | --- |
| 校园电视 | 230 |
| 院部动态 | 232 |
| 动感校园 | 233 |
| 招就指南 | 234 |
| 南艺院报 | 236 |
</RouteEn>
### School of Design
<RouteEn author="evnydd0sf" example="/nua/dc/news" path="/nua/dc/:type" :paramsDesc="['News Type']" radar="1">
| News Type | Parameters |
| ---------------------- | ---------- |
| 学院新闻 NEWS | news |
| 展览 EXHIBITION | exhibition |
| 研创 RESEARCH & CREATION | rc |
| 项目 PROJECT | project |
| 党团 PARTY | party |
| 后浪 YOUTH | youth |
</RouteEn>
### Graduate Institute
<RouteEn author="evnydd0sf" example="/nua/gra/1959" path="/nua/gra/:type" :paramsDesc="['News Type']" radar="1">
| News Type | Parameters |
| ---- | ---- |
| 招生工作 | 1959 |
| 培养工作 | 1962 |
| 学位工作 | 1958 |
</RouteEn>
### Library
<RouteEn author="evnydd0sf" example="/nua/lib/xwdt" path="/nua/lib/:type" :paramsDesc="['News Type']" radar="1">
| News Type | Parameters |
| ---- | ---- |
| 新闻动态 | xwdt |
| 党建动态 | djdt |
| 资源动态 | zydt |
| 服务动态 | fwdt |
</RouteEn>
## Polimi
### News

View File

@ -2155,6 +2155,19 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
</Route>
### 图书馆
<Route author="evnydd0sf" example="/nua/lib/xwdt" path="/nua/lib/:type" :paramsDesc="['新闻模块,见下表']" radar="1">
| 新闻模块 | 参数 |
| ---- | ---- |
| 新闻动态 | xwdt |
| 党建动态 | djdt |
| 资源动态 | zydt |
| 服务动态 | fwdt |
</Route>
## 南京邮电大学
### 教务处通知与新闻

39
lib/v2/nua/lib.js Normal file
View File

@ -0,0 +1,39 @@
const util = require('./utils');
const baseUrl = 'https://lib.nua.edu.cn';
module.exports = async (ctx) => {
const type = ctx.params.type;
let webPageName;
switch (type) {
case 'xwdt':
webPageName = '.wp_column.column-1.selected';
break;
case 'djdt':
webPageName = '.wp_column.column-2.selected';
break;
case 'zydt':
webPageName = '.wp_column.column-3.selected';
break;
case 'fwdt':
webPageName = '.wp_column.column-4.selected';
break;
default:
throw Error(`暂不支持对${type}的订阅`);
}
const newsUrl = `${baseUrl}/${type}/list.htm`;
const listName = 'div.news_con';
const artiContent = '.wp_articlecontent';
const listDate = '.news_date';
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
const results = await util.ProcessFeed(items[0], artiContent, ctx);
ctx.state.data = {
title: 'NUA-图书馆-' + items[1],
link: `${baseUrl}/${type}/list.htm`,
description: '南京艺术学院 图书馆 ' + items[1],
item: results,
};
};

View File

@ -2,5 +2,6 @@ module.exports = {
'/dc/:type': ['evnydd0sf'],
'/gra/:type': ['evnydd0sf'],
'/index/:type': ['evnydd0sf'],
'/lib/:type': ['evnydd0sf'],
'/sxw/:type': ['evnydd0sf'],
};

View File

@ -33,5 +33,13 @@ module.exports = {
target: '/nua/gra/:type',
},
],
lib: [
{
title: '图书馆',
docs: 'https://docs.rsshub.app/university.html#nan-jing-yi-shu-xue-yuan',
source: ['/:type/list.htm'],
target: '/nua/lib/:type',
},
],
},
};

View File

@ -2,5 +2,6 @@ module.exports = function (router) {
router.get('/dc/:type', require('./dc'));
router.get('/gra/:type', require('./gra'));
router.get('/index/:type', require('./index'));
router.get('/lib/:type', require('./lib'));
router.get('/sxw/:type', require('./sxw'));
};

View File

@ -23,26 +23,21 @@ function arti_link(text, href) {
}
async function ProcessList(newsUrl, baseUrl, listName, listDate, webPageName) {
const result = await got(newsUrl, {
https: {
rejectUnauthorized: false,
},
});
const result = await got(newsUrl, { https: { rejectUnauthorized: false } });
const $ = cheerio.load(result.data);
const pageName = $(webPageName).text();
const pageName = $(webPageName).text().trim();
const items = $(listName)
.toArray()
.map((item) => {
item = $(item);
const href = $(item).find('a').attr('href');
const type = pageType(href);
return {
link: type === 'in-nua' ? baseUrl + href : href,
title: item.find('a').attr('title'),
pubDate: timezone(parseDate(item.find(listDate).first().text(), 'YYYY-MM-DD'), +8),
title: $(item).find('a').attr('title'),
pubDate: timezone(parseDate($(item).find(listDate).first().text(), 'YYYY-MM-DD'), +8),
type,
};
});
@ -55,14 +50,14 @@ const ProcessFeed = async (items, artiContent, ctx) =>
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
switch (item.type) {
case 'in-nua' || 'nua':
// eslint-disable-next-line no-case-declarations
case 'in-nua':
case 'nua': {
const result = await got(item.link, { https: { rejectUnauthorized: false } });
// eslint-disable-next-line no-case-declarations
const $ = cheerio.load(result.data);
item.author = $('.arti_publisher').text() + ' ' + $('.arti_views').text();
item.description = $(artiContent).html();
return item;
}
case 'wechat-mp':
return fetchArticle(ctx, item.link);
case 'unknown':