diff --git a/docs/en/journal.md b/docs/en/journal.md index 7b7c86129..240cf8fae 100644 --- a/docs/en/journal.md +++ b/docs/en/journal.md @@ -200,6 +200,10 @@ Return results from 2020 +### Early Access Journal + + + ## INFORMS ### Category diff --git a/docs/journal.md b/docs/journal.md index 6e0723020..9599479f1 100644 --- a/docs/journal.md +++ b/docs/journal.md @@ -194,6 +194,11 @@ pageClass: routes +### 预印版 + + + + ## INFORMS ### 类型 diff --git a/lib/v2/ieee/earlyaccess.js b/lib/v2/ieee/earlyaccess.js new file mode 100644 index 000000000..71b228d23 --- /dev/null +++ b/lib/v2/ieee/earlyaccess.js @@ -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, + }; +}; diff --git a/lib/v2/ieee/maintainer.js b/lib/v2/ieee/maintainer.js index 8660f9ff5..cc226aeab 100644 --- a/lib/v2/ieee/maintainer.js +++ b/lib/v2/ieee/maintainer.js @@ -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'], }; diff --git a/lib/v2/ieee/radar.js b/lib/v2/ieee/radar.js index 19bd316c9..903dc50f0 100644 --- a/lib/v2/ieee/radar.js +++ b/lib/v2/ieee/radar.js @@ -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`, + }, ], }, }; diff --git a/lib/v2/ieee/router.js b/lib/v2/ieee/router.js index 791848d98..a584fb48f 100644 --- a/lib/v2/ieee/router.js +++ b/lib/v2/ieee/router.js @@ -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')); };