diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 198cb57dab..2791b13a19 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -302,6 +302,28 @@ category 对应的关键词有 +## 香港 01 + +### 热门 + + + +### 栏目 + + + +### 子栏目 + + + +### 专题 + + + +### 标签 + + + ## 新京报 ### 栏目 diff --git a/lib/router.js b/lib/router.js index ba2e643593..e810d3b666 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1874,6 +1874,13 @@ router.get('/mcbbs/post/:tid/:authorid?', require('./routes/mcbbs/post')); // Pocket router.get('/pocket/trending', require('./routes/pocket/trending')); +// HK01 +router.get('/hk01/zone/:id', require('./routes/hk01/zone')); +router.get('/hk01/channel/:id', require('./routes/hk01/channel')); +router.get('/hk01/issue/:id', require('./routes/hk01/issue')); +router.get('/hk01/tag/:id', require('./routes/hk01/tag')); +router.get('/hk01/hot', require('./routes/hk01/hot')); + // 码农周刊 router.get('/manong-weekly', require('./routes/manong-weekly/issues')); diff --git a/lib/routes/hk01/channel.js b/lib/routes/hk01/channel.js new file mode 100644 index 0000000000..253e10c2d4 --- /dev/null +++ b/lib/routes/hk01/channel.js @@ -0,0 +1,22 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const response = await got(`https://web-data.api.hk01.com/v2/page/category/${id}`); + const data = response.data; + const list = data.sections[0].items; + + ctx.state.data = { + title: `香港01 - ${data.category.publishName}`, + description: data.meta.metaDesc, + link: data.category.publishUrl, + item: list.map((item) => ({ + title: item.data.title, + author: item.data.authors.map((e) => e.publishName).join(', '), + description: `

${item.data.description}…

`, + pubDate: new Date(item.data.lastModifyTime * 1000), + link: item.data.canonicalUrl, + })), + }; +}; diff --git a/lib/routes/hk01/hot.js b/lib/routes/hk01/hot.js new file mode 100644 index 0000000000..9449667710 --- /dev/null +++ b/lib/routes/hk01/hot.js @@ -0,0 +1,20 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const response = await got('https://web-data.api.hk01.com/v2/page/hot/'); + const data = response.data; + const list = data.items; + + ctx.state.data = { + title: '香港01 - 熱門', + description: data.meta.metaDesc, + link: data.meta.canonicalUrl, + item: list.map((item) => ({ + title: item.data.title, + author: item.data.authors.map((e) => e.publishName).join(', '), + description: `

${item.data.description}

`, + pubDate: new Date(item.data.lastModifyTime * 1000), + link: item.data.canonicalUrl, + })), + }; +}; diff --git a/lib/routes/hk01/issue.js b/lib/routes/hk01/issue.js new file mode 100644 index 0000000000..1f079faf36 --- /dev/null +++ b/lib/routes/hk01/issue.js @@ -0,0 +1,22 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const response = await got(`https://web-data.api.hk01.com/v2/page/issue/${id}`); + const data = response.data; + const list = data.issue.blocks[0].articles; + + ctx.state.data = { + title: `香港01 - ${data.issue.title}`, + description: data.meta.metaDesc, + link: data.issue.publishUrl, + item: list.map((item) => ({ + title: item.data.title, + author: item.data.authors.map((e) => e.publishName).join(', '), + description: `

${item.data.description}…

`, + pubDate: new Date(item.data.lastModifyTime * 1000), + link: item.data.canonicalUrl, + })), + }; +}; diff --git a/lib/routes/hk01/tag.js b/lib/routes/hk01/tag.js new file mode 100644 index 0000000000..54691c952e --- /dev/null +++ b/lib/routes/hk01/tag.js @@ -0,0 +1,22 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const response = await got(`https://web-data.api.hk01.com/v2/page/tag/${id}`); + const data = response.data; + const list = data.articles; + + ctx.state.data = { + title: `香港01 - ${data.tag.tagName}`, + description: data.meta.metaDesc, + link: data.tag.publishUrl, + item: list.map((item) => ({ + title: item.data.title, + author: item.data.authors.map((e) => e.publishName).join(', '), + description: `

${item.data.description}

`, + pubDate: new Date(item.data.lastModifyTime * 1000), + link: item.data.canonicalUrl, + })), + }; +}; diff --git a/lib/routes/hk01/zone.js b/lib/routes/hk01/zone.js new file mode 100644 index 0000000000..3131d85842 --- /dev/null +++ b/lib/routes/hk01/zone.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const response = await got(`https://web-data.api.hk01.com/v2/page/zone/${id}`); + const data = response.data; + const list = data.sections[0].items; + + ctx.state.data = { + title: `香港01 - ${data.zone.publishName}`, + description: data.meta.metaDesc, + link: data.zone.publishUrl, + item: list.map((item) => { + let author; + let description; + let pubDate; + switch (item.type) { + case 1: + author = item.data.authors.map((e) => e.publishName).join(', '); + description = `

${item.data.description}

`; + pubDate = new Date(item.data.lastModifyTime * 1000); + break; + case 2: + author = item.data.zonePublishName; + description = `${item.data.teaser.map((e) => '

' + e + '

').join('')}`; + pubDate = new Date(); + break; + default: + break; + } + return { + title: item.data.title, + author: author, + description: description, + pubDate: pubDate, + link: item.data.canonicalUrl, + }; + }), + }; +};