diff --git a/docs/other.md b/docs/other.md index 2a868d5d9..01ac95f3a 100644 --- a/docs/other.md +++ b/docs/other.md @@ -528,64 +528,6 @@ type 为 all 时,category 参数不支持 cost 和 free 1. 显示单个污染成分,例如「pm25」, 2. 逗号分隔显示多个污染成分,例如「pm25,pm10」,[https://rsshub.app/aqicn/beijing/pm25,pm10](https://rsshub.app/aqicn/beijing/pm25.pm10) -## 酷安 - -### 图文 - - - -| 参数名称 | 编辑精选 | 最新 | -| ---- | ---- | ------ | -| type | hot | latest | - - - -### 头条 - - - -| 参数名称 | 历史头条 | 最新 | -| ---- | ------- | ------ | -| type | history | latest | - - - -### 看看号 - - - -::: tip -仅限于采集**站内订阅**的看看号的内容。看看号 ID 可在看看号界面右上分享 - 复制链接得到。 -::: - - - -### 话题 - - - -### 用户 - - - -### 热榜 - - - -| 参数名称 | 今日热门 | 点赞榜 | 评论榜 | 收藏榜 | 酷图榜 | -| ---- | ---- | --- | --- | --- | --- | -| type | jrrm | dzb | plb | scb | ktb | - -| 参数名称 | 日榜 | 周榜 | -| ------ | ----- | ------ | -| period | daily | weekly | - -::: tip -今日热门没有周榜,酷图榜日榜的参数会变成周榜,周榜的参数会变成月榜。 -::: - - - ## 快递 100 ### 快递订单追踪 diff --git a/docs/social-media.md b/docs/social-media.md index 3c69c016b..7ca29bb58 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -1211,6 +1211,64 @@ YouTube 官方亦有提供频道 RSS,形如 +## 酷安 + +### 图文 + + + +| 参数名称 | 编辑精选 | 最新 | +| ---- | ---- | ------ | +| type | hot | latest | + + + +### 头条 + + + +| 参数名称 | 历史头条 | 最新 | +| ---- | ------- | ------ | +| type | history | latest | + + + +### 看看号 + + + +::: tip +仅限于采集**站内订阅**的看看号的内容。看看号 ID 可在看看号界面右上分享 - 复制链接得到。 +::: + + + +### 话题 + + + +### 用户 + + + +### 热榜 + + + +| 参数名称 | 今日热门 | 点赞榜 | 评论榜 | 收藏榜 | 酷图榜 | +| ---- | ---- | --- | --- | --- | --- | +| type | jrrm | dzb | plb | scb | ktb | + +| 参数名称 | 日榜 | 周榜 | +| ------ | ----- | ------ | +| period | daily | weekly | + +::: tip +今日热门没有周榜,酷图榜日榜的参数会变成周榜,周榜的参数会变成月榜。 +::: + + + ## 美拍 ### 用户动态 diff --git a/lib/router.js b/lib/router.js index 204ac341f..50d1ec257 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1894,14 +1894,14 @@ router.get('/keyakizaka46/blog', lazyloadRouteHandler('./routes/keyakizaka46/blo router.get('/hinatazaka46/blog', lazyloadRouteHandler('./routes/hinatazaka46/blog')); // router.get('/sakurazaka46/blog', lazyloadRouteHandler('./routes/sakurazaka46/blog')); -// 酷安 -router.get('/coolapk/tuwen/:type?', lazyloadRouteHandler('./routes/coolapk/tuwen')); -router.get('/coolapk/tuwen-xinxian', lazyloadRouteHandler('./routes/coolapk/tuwen')); -router.get('/coolapk/toutiao/:type?', lazyloadRouteHandler('./routes/coolapk/toutiao')); -router.get('/coolapk/huati/:tag', lazyloadRouteHandler('./routes/coolapk/huati')); -router.get('/coolapk/user/:uid/dynamic', lazyloadRouteHandler('./routes/coolapk/userDynamic')); -router.get('/coolapk/dyh/:dyhId', lazyloadRouteHandler('./routes/coolapk/dyh')); -router.get('/coolapk/hot/:type?/:period?', lazyloadRouteHandler('./routes/coolapk/hot')); +// 酷安 migrated to v2 +// router.get('/coolapk/tuwen/:type?', lazyloadRouteHandler('./routes/coolapk/tuwen')); +// router.get('/coolapk/tuwen-xinxian', lazyloadRouteHandler('./routes/coolapk/tuwen')); +// router.get('/coolapk/toutiao/:type?', lazyloadRouteHandler('./routes/coolapk/toutiao')); +// router.get('/coolapk/huati/:tag', lazyloadRouteHandler('./routes/coolapk/huati')); +// router.get('/coolapk/user/:uid/dynamic', lazyloadRouteHandler('./routes/coolapk/userDynamic')); +// router.get('/coolapk/dyh/:dyhId', lazyloadRouteHandler('./routes/coolapk/dyh')); +// router.get('/coolapk/hot/:type?/:period?', lazyloadRouteHandler('./routes/coolapk/hot')); // 模型网 router.get('/moxingnet', lazyloadRouteHandler('./routes/moxingnet')); diff --git a/lib/routes/coolapk/dyh.js b/lib/v2/coolapk/dyh.js similarity index 85% rename from lib/routes/coolapk/dyh.js rename to lib/v2/coolapk/dyh.js index 1c4bd41d0..97c0fda0e 100644 --- a/lib/routes/coolapk/dyh.js +++ b/lib/v2/coolapk/dyh.js @@ -4,16 +4,12 @@ const utils = require('./utils'); module.exports = async (ctx) => { const dyhId = ctx.params.dyhId; const full_url = utils.base_url + `/v6/dyhArticle/list?dyhId=${dyhId}&type=all&page=1`; - const r = await got({ - method: 'get', - url: utils.base_url + `/v6/dyh/detail?dyhId=${dyhId}`, + const r = await got(`${utils.base_url}/v6/dyh/detail?dyhId=${dyhId}`, { headers: utils.getHeaders(), }); let targetTitle = r.data.data.title; const feedDescription = r.data.data.description; - const response = await got({ - method: 'get', - url: full_url, + const response = await got(full_url, { headers: utils.getHeaders(), }); const data = response.data.data; diff --git a/lib/routes/coolapk/hot.js b/lib/v2/coolapk/hot.js similarity index 97% rename from lib/routes/coolapk/hot.js rename to lib/v2/coolapk/hot.js index 827f66d02..4aeef30cd 100644 --- a/lib/routes/coolapk/hot.js +++ b/lib/v2/coolapk/hot.js @@ -69,9 +69,7 @@ module.exports = async (ctx) => { const type = ctx.params.type || 'jrrm'; const period = ctx.params.period || 'daily'; const { link, title } = getLinkAndTitle(type, period); - const r = await got({ - method: 'get', - url: link, + const r = await got(link, { headers: utils.getHeaders(), }); const data = r.data.data; diff --git a/lib/routes/coolapk/huati.js b/lib/v2/coolapk/huati.js similarity index 91% rename from lib/routes/coolapk/huati.js rename to lib/v2/coolapk/huati.js index aca3ff7dc..ccbcef116 100644 --- a/lib/routes/coolapk/huati.js +++ b/lib/v2/coolapk/huati.js @@ -4,9 +4,7 @@ const utils = require('./utils'); module.exports = async (ctx) => { const tag = ctx.params.tag; const full_url = utils.base_url + `/v6/page/dataList?url=%23%2Ffeed%2FmultiTagFeedList%3FlistType%3Ddateline_desc%26tag=${tag}&title=%E6%9C%80%E6%96%B0%E5%8F%91%E5%B8%83&subTitle=&page=1`; - const response = await got({ - method: 'get', - url: full_url, + const response = await got(full_url, { headers: utils.getHeaders(), }); const data = response.data.data; diff --git a/lib/v2/coolapk/maintainer.js b/lib/v2/coolapk/maintainer.js new file mode 100644 index 000000000..de66a7981 --- /dev/null +++ b/lib/v2/coolapk/maintainer.js @@ -0,0 +1,9 @@ +module.exports = { + '/dyh/:dyhId': ['xizeyoupan'], + '/huati/:tag': ['xizeyoupan'], + '/hot/:type?/:period?': ['xizeyoupan'], + '/toutiao/:type?': ['xizeyoupan'], + '/tuwen/:type?': ['xizeyoupan'], + '/tuwen-xinxian': ['xizeyoupan'], + '/user/:uid/dynamic': ['xizeyoupan'], +}; diff --git a/lib/v2/coolapk/radar.js b/lib/v2/coolapk/radar.js new file mode 100644 index 000000000..ed5662ef1 --- /dev/null +++ b/lib/v2/coolapk/radar.js @@ -0,0 +1,31 @@ +module.exports = { + 'coolapk.com': { + _name: '酷安', + '.': [ + { + title: '图文', + docs: 'https://docs.rsshub.app/social-media.html#ku-an', + }, + { + title: '头条', + docs: 'https://docs.rsshub.app/social-media.html#ku-an', + }, + { + title: '看看号', + docs: 'https://docs.rsshub.app/social-media.html#ku-an', + }, + { + title: '话题', + docs: 'https://docs.rsshub.app/social-media.html#ku-an', + }, + { + title: '用户', + docs: 'https://docs.rsshub.app/social-media.html#ku-an', + }, + { + title: '热榜', + docs: 'https://docs.rsshub.app/social-media.html#ku-an', + }, + ], + }, +}; diff --git a/lib/v2/coolapk/router.js b/lib/v2/coolapk/router.js new file mode 100644 index 000000000..58251b2f3 --- /dev/null +++ b/lib/v2/coolapk/router.js @@ -0,0 +1,9 @@ +module.exports = (router) => { + router.get('/dyh/:dyhId', require('./dyh')); + router.get('/huati/:tag', require('./huati')); + router.get('/hot/:type?/:period?', require('./hot')); + router.get('/toutiao/:type?', require('./toutiao')); + router.get('/tuwen/:type?', require('./tuwen')); + router.get('/tuwen-xinxian', require('./tuwen')); + router.get('/user/:uid/dynamic', require('./userDynamic')); +}; diff --git a/lib/routes/coolapk/toutiao.js b/lib/v2/coolapk/toutiao.js similarity index 92% rename from lib/routes/coolapk/toutiao.js rename to lib/v2/coolapk/toutiao.js index dcf13060c..4e7d61a9b 100644 --- a/lib/routes/coolapk/toutiao.js +++ b/lib/v2/coolapk/toutiao.js @@ -13,9 +13,7 @@ module.exports = async (ctx) => { title: '最新动态', }, }; - const response = await got({ - method: 'get', - url: urls[type].url, + const response = await got(urls[type].url, { headers: utils.getHeaders(), }); const data = response.data.data; diff --git a/lib/routes/coolapk/tuwen.js b/lib/v2/coolapk/tuwen.js similarity index 92% rename from lib/routes/coolapk/tuwen.js rename to lib/v2/coolapk/tuwen.js index 0c546125b..7eec255aa 100644 --- a/lib/routes/coolapk/tuwen.js +++ b/lib/v2/coolapk/tuwen.js @@ -12,12 +12,10 @@ module.exports = async (ctx) => { feedTitle = `酷安 - 新鲜图文`; } else if (ctx.originalUrl.startsWith(`/coolapk/tuwen`)) { // 精选 - full_url = utils.base_url + '/v6/page/dataList?url=%23%2Ffeed%2FdigestList%3Ftype%3D12%26is_html_article%3D1%26recommend%3D3&title=%E5%9B%BE%E6%96%87&page=1'; + full_url = utils.base_url + '/v6/page/dataList?url=%23%2Ffeed%2FdigestList%3Ftype%3D12%26is_html_article%3D1%26recommend%3D3%252C4&title=%E5%9B%BE%E6%96%87&page=1'; feedTitle = `酷安图文 - 编辑精选`; } - const response = await got({ - method: 'get', - url: full_url, + const response = await got(full_url, { headers: utils.getHeaders(), }); const data = response.data.data; diff --git a/lib/routes/coolapk/userDynamic.js b/lib/v2/coolapk/userDynamic.js similarity index 92% rename from lib/routes/coolapk/userDynamic.js rename to lib/v2/coolapk/userDynamic.js index 47ab7990e..d7840d5a8 100644 --- a/lib/routes/coolapk/userDynamic.js +++ b/lib/v2/coolapk/userDynamic.js @@ -5,9 +5,7 @@ module.exports = async (ctx) => { const uid = ctx.params.uid; const full_url = utils.base_url + `/v6/user/feedList?uid=${uid}&page=1&showAnonymous=0&isIncludeTop=1&showDoing=1`; let username; - const response = await got({ - method: 'get', - url: full_url, + const response = await got(full_url, { headers: utils.getHeaders(), }); const data = response.data.data; diff --git a/lib/routes/coolapk/utils.js b/lib/v2/coolapk/utils.js similarity index 91% rename from lib/routes/coolapk/utils.js rename to lib/v2/coolapk/utils.js index dad6365a0..3aae4fedd 100644 --- a/lib/routes/coolapk/utils.js +++ b/lib/v2/coolapk/utils.js @@ -1,6 +1,7 @@ const md5 = require('@/utils/md5'); const cheerio = require('cheerio'); const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); const dynamicTpye = { 0: '基本动态', 8: '酷图', 9: '评论', 10: '提问', 11: '回答', 12: '图文', 15: '二手', 17: '观点', 20: '交易动态' }; @@ -49,13 +50,13 @@ const parseTuwenFromRaw = (raw) =>

${i.description}

`; } else { - // console.log(i) + // console.log(i); return `Unkown type`; } }); const parseDynamic = async (item, ctx) => { - const pubDate = new Date(item.lastupdate * 1000).toUTCString(); + const pubDate = parseDate(item.lastupdate, 'X'); if (item.entityType === 'sponsorCard') { return; } else if (item.shareUrl === undefined) { @@ -66,6 +67,7 @@ const parseDynamic = async (item, ctx) => { const type = parseInt(item.type); switch (type) { case 0: + case 5: case 8: case 9: case 10: @@ -77,12 +79,10 @@ const parseDynamic = async (item, ctx) => { if (item.issummary) { // 需要爬内容 description = await ctx.cache.tryGet(itemUrl, async () => { - const result = await got({ - method: 'get', - url: itemUrl, + const result = await got(itemUrl, { headers: getHeaders(), }); - const message = `

` + result.data.data.message.split('\n').join('
') + `

`; + const message = `

` + result.data.data?.message.split('\n').join('
') + `

`; const picArr = item.picArr.filter((i) => i).map((i) => ``); // 若无图片,item.picArr=[""] return message + picArr.join(''); }); @@ -112,9 +112,7 @@ const parseDynamic = async (item, ctx) => { case 12: { title = item.title; description = await ctx.cache.tryGet(itemUrl, async () => { - const result = await got({ - method: 'get', - url: itemUrl, + const result = await got(itemUrl, { headers: getHeaders(), });