feat(route): add IEEE xplore early access journal (#12230)

* feat(route): add IEEE xplore early access journal

* Update maintaner.js

* Update earlyaccess.js
---------
This commit is contained in:
Hengyu
2023-04-05 20:44:29 +08:00
committed by GitHub
parent e304b0ed49
commit be3515b01e
6 changed files with 95 additions and 1 deletions
+4
View File
@@ -200,6 +200,10 @@ Return results from 2020
<RouteEn author="Derekmini auto-bot-ty" example="/ieee/journal/78/recent" path="/ieee/journal/:journal/recent/:sortType?" :paramsDesc="['Journal code, the number of the `punumber` in the URL','Sort Type, default: `vol-only-seq`, the part of the URL after `sortType`']" radar="1" rssbud="1"/>
### Early Access Journal
<RouteEn author="5upernova-heng" example="/ieee/journal/5306045/earlyaccess" path="/ieee/journal/:journal/earlyaccess/:sortType?" :paramsDesc="['Issue code, the number of the `isnumber` in the URL','Sort Type, default: `vol-only-seq`, the part of the URL after `sortType`']" radar="1" rssbud="1"/>
## INFORMS
### Category
+5
View File
@@ -194,6 +194,11 @@ pageClass: routes
<Route author="Derekmini auto-bot-ty" example="/ieee/journal/78/recent" path="/ieee/journal/:journal/recent/:sortType?" :paramsDesc="['期刊代码,URL 中 `punumber` 部分','排序方式,默认`vol-only-seq`,URL 中 `sortType` 部分']" radar="1" rssbud="1"/>
### 预印版
<Route author="5upernova-heng" example="/ieee/journal/5306045/earlyaccess" path="/ieee/journal/:journal/earlyaccess/:sortType?" :paramsDesc="['发布代码,URL 中 `isnumber` 部分','排序方式,默认`vol-only-seq`,URL 中 `sortType` 部分']" radar="1" rssbud="1"/>
## INFORMS
### 类型
+77
View File
@@ -0,0 +1,77 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const path = require('path');
const { art } = require('@/utils/render');
const { CookieJar } = require('tough-cookie');
const cookieJar = new CookieJar();
module.exports = async (ctx) => {
const isnumber = ctx.params.journal;
const sortType = ctx.params.sortType ?? 'vol-only-seq';
const host = 'https://ieeexplore.ieee.org';
const jrnlUrl = `${host}/xpl/tocresult.jsp?isnumber=${isnumber}`;
const response = await got(`${host}/rest/publication/home/metadata?issueid=${isnumber}`, {
cookieJar,
}).json();
const punumber = response.publicationNumber;
const volume = response.currentIssue.volume;
const jrnlName = response.displayTitle;
const response2 = await got
.post(`${host}/rest/search/pub/${punumber}/issue/${isnumber}/toc`, {
cookieJar,
json: {
punumber,
isnumber,
sortType,
rowsPerPage: '100',
},
})
.json();
let list = response2.records.map((item) => {
const $2 = cheerio.load(item.articleTitle);
const title = $2.text();
const link = item.htmlLink;
const doi = item.doi;
let authors = 'Do not have author';
if (item.hasOwnProperty('authors')) {
authors = item.authors.map((itemAuth) => itemAuth.preferredName).join('; ');
}
const abstract = item.hasOwnProperty('abstract') ? item.abstract : '';
return {
title,
link,
authors,
doi,
volume,
abstract,
};
});
const renderDesc = (item) =>
art(path.join(__dirname, 'templates/description.art'), {
item,
});
list = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
if (item.abstract !== '') {
const response3 = await got(`${host}${item.link}`);
const { abstract } = JSON.parse(response3.body.match(/metadata=(.*);/)[1]);
const $3 = cheerio.load(abstract);
item.abstract = $3.text();
item.description = renderDesc(item);
}
return item;
})
)
);
ctx.state.data = {
title: jrnlName,
link: jrnlUrl,
item: list,
};
};
+1
View File
@@ -1,4 +1,5 @@
module.exports = {
'/journal/:journal/:sortType?': ['Derekmini', 'auto-bot-ty'],
'/journal/:journal/recent/:sortType?': ['Derekmini', 'auto-bot-ty'],
'/journal/:journal/earlyaccess/:sortType?': ['5upernova-heng'],
};
+6
View File
@@ -14,6 +14,12 @@ module.exports = {
source: '/*',
target: (params, url) => `/ieee/journal/${new URL(url).searchParams.get('punumber')}/recent`,
},
{
title: 'Early Access Journal',
docs: 'https://docs.rsshub.app/journal.html#ieee-xplore',
source: '/*',
target: (params, url) => `/ieee/journal/${new URL(url).searchParams.get('isnumber')}/earlyaccess`,
},
],
},
};
+2 -1
View File
@@ -1,6 +1,7 @@
module.exports = function (router) {
router.get('/:journal/latest/vol/:sortType?', require('./journal')); // deprecated
router.get('/:journal/latest/date/:sortType?', require('./recent')); // deprecated
router.get('/journal/:journal/:sortType?', require('./journal'));
router.get('/journal/:journal/earlyaccess/:sortType?', require('./earlyaccess'));
router.get('/journal/:journal/recent/:sortType?', require('./recent'));
router.get('/journal/:journal/:sortType?', require('./journal'));
};