diff --git a/docs/new-media.md b/docs/new-media.md index b1889efc0..8775a7fb5 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -2781,6 +2781,12 @@ column 为 third 时可选的 category: +## 沃草 + +### 文件列表 + + + ## 无产者评论 ### 分类 diff --git a/lib/v2/watchout/index.js b/lib/v2/watchout/index.js new file mode 100644 index 000000000..5b84d648d --- /dev/null +++ b/lib/v2/watchout/index.js @@ -0,0 +1,51 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const rootUrl = 'https://watchout.tw'; + const currentUrl = `${rootUrl}/docs`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + let items = $('.title .a-text') + .toArray() + .map((item) => { + item = $(item); + + return { + title: item.text(), + link: item.attr('href'), + pubDate: parseDate(item.parent().parent().find('.date').text()), + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + item.author = content('.name').eq(0).text(); + item.description = content('.content').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/watchout/maintainer.js b/lib/v2/watchout/maintainer.js new file mode 100644 index 000000000..ca7cf1eb1 --- /dev/null +++ b/lib/v2/watchout/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['nczitzk'], +}; diff --git a/lib/v2/watchout/radar.js b/lib/v2/watchout/radar.js new file mode 100644 index 000000000..d12fb4174 --- /dev/null +++ b/lib/v2/watchout/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'watchout.tw': { + _name: '沃草', + '.': [ + { + title: '文件列表', + docs: 'https://docs.rsshub.app/new-media.html#wo-cao-wen-jian-lie-biao', + source: ['/'], + target: '/watchout', + }, + ], + }, +}; diff --git a/lib/v2/watchout/router.js b/lib/v2/watchout/router.js new file mode 100644 index 000000000..20c52b09d --- /dev/null +++ b/lib/v2/watchout/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/', require('./index')); +};