diff --git a/docs/anime.md b/docs/anime.md index f1e51af1e8..8b6991dbcd 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -110,14 +110,14 @@ pageClass: routes -## 嘀哩嘀哩-dilidili +## 嘀哩嘀哩 - dilidili ### 嘀哩嘀哩番剧更新 请打开对应番剧的纵览页(非具体某集),从 url 中最后一位查看番剧 id.(一般为英文) -除去超长的番剧(例如海贼)这种具有特殊页面的,绝大多数页面都可以解析. +除去'海贼'此类具有特殊页面的超长番剧,绝大多数页面都可以解析. 最适合用来追新番 diff --git a/docs/other.md b/docs/other.md index 020b8e950d..5fa8c85660 100644 --- a/docs/other.md +++ b/docs/other.md @@ -664,6 +664,10 @@ type 为 all 时,category 参数不支持 cost 和 free +### 作者 + + + ## 世界卫生组织 ### 媒体中心 diff --git a/lib/router.js b/lib/router.js index fbe8ff7c74..768d3f92ce 100644 --- a/lib/router.js +++ b/lib/router.js @@ -771,6 +771,7 @@ router.get('/sspai/series', require('./routes/sspai/series')); router.get('/sspai/shortcuts', require('./routes/sspai/shortcutsGallery')); router.get('/sspai/matrix', require('./routes/sspai/matrix')); router.get('/sspai/column/:id', require('./routes/sspai/column')); +router.get('/sspai/author/:id', require('./routes/sspai/author')); // 异次元软件世界 router.get('/iplay/home', require('./routes/iplay/home')); diff --git a/lib/routes/sspai/author.js b/lib/routes/sspai/author.js new file mode 100644 index 0000000000..11420247c9 --- /dev/null +++ b/lib/routes/sspai/author.js @@ -0,0 +1,51 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + const api_url = `https://sspai.com/api/v1/articles?offset=0&limit=20&author_ids=${id}&include_total=false`; + const resp = await axios({ + method: 'get', + url: api_url, + }); + const data = resp.data.list; + let author_nickname = ''; + let author_id = 0; + const items = await Promise.all( + data.map(async (item) => { + const link = `https://sspai.com/post/${item.id}`; + let description = ''; + + const key = `sspai: ${item.id}`; + const value = await ctx.cache.get(key); + + if (value) { + description = value; + } else { + const response = await axios({ method: 'get', url: link }); + const $ = cheerio.load(response.data); + description = $('div.content.wangEditor-txt.clock').html(); + ctx.cache.set(key, description); + } + + // 将作者名称和id赋值给nickname和id + author_nickname = item.author.nickname; + author_id = item.author.id; + + return { + title: item.title.trim(), + description: description, + link: link, + pubDate: new Date(item.released_at * 1000).toUTCString(), + author: item.author.nickname, + }; + }) + ); + + ctx.state.data = { + title: `${author_nickname} - 少数派作者`, + link: `https://sspai.com/user/${author_id}/posts`, + description: `${author_nickname} 更新推送 `, + item: items, + }; +}; diff --git a/lib/routes/sspai/matrix.js b/lib/routes/sspai/matrix.js index 6e0231c39e..12ae954696 100644 --- a/lib/routes/sspai/matrix.js +++ b/lib/routes/sspai/matrix.js @@ -21,7 +21,7 @@ module.exports = async (ctx) => { } else { const response = await axios({ method: 'get', url: link }); const $ = cheerio.load(response.data); - description = $('#article-content > div').html(); + description = $('div.content.wangEditor-txt.clock').html(); ctx.cache.set(key, description); }