forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): add xkb 新快报(新快网) (DIYgod#12134)
* feat(route): add xkb 新快报(新快网) * fix(route): fix 新快报 * fix(route): fix 新快报 * fix: radar domain ---------
- Loading branch information
Showing
6 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const got = require('@/utils/got'); | ||
const timezone = require('@/utils/timezone'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
|
||
module.exports = async (ctx) => { | ||
const channel = ctx.params.channel ?? 1; | ||
const currentUrl = `https://www.xkb.com.cn/xkbapp/fundapi/article/api/articles?chnlId=${channel}&visibility=1&page=0&size=20&keyword=`; | ||
|
||
const { data: response } = await got({ | ||
method: 'get', | ||
url: currentUrl, | ||
headers: { | ||
siteId: '35', | ||
}, | ||
}); | ||
|
||
const list = response.data | ||
.filter((i) => i.contentUrl) // Remove "专题报道" (special report) | ||
.map((item) => ({ | ||
title: item.listTitle, | ||
description: art(path.join(__dirname, 'templates/description.art'), { | ||
thumb: item.metaInfo.thumbnails[0], | ||
}), | ||
pubDate: timezone(parseDate(item.operTime), +8), | ||
link: 'https://www.xkb.com.cn/#/detail?id=' + item.id, | ||
contentUrl: item.contentUrl, | ||
author: item.metaInfo.author, | ||
chnlName: item.metaInfo.chnlName, | ||
})); | ||
|
||
let chnlName = ''; | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
ctx.cache.tryGet(item.contentUrl, async () => { | ||
const detailResponse = await got({ | ||
method: 'get', | ||
url: item.contentUrl, | ||
}); | ||
item.description += detailResponse.data.htmlContent ?? ''; | ||
chnlName = chnlName === '' ? item.chnlName : chnlName; | ||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `新快报新快网 - ${chnlName}`, | ||
link: `https://www.xkb.com.cn/#/home?id=${channel}`, | ||
item: items, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/:channel': ['TimWu007'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
'xkb.com.cn': { | ||
_name: '新快报', | ||
'.': [ | ||
{ | ||
title: '新闻', | ||
docs: 'https://docs.rsshub.app/traditional-media.html#xin-kuai-bao', | ||
source: ['/'], | ||
target: (_, url) => `/xkb/${new URL(url).hash.match(/\?id=(\d+)/)[1]}`, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = (router) => { | ||
router.get('/:channel', require('./index')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{ if thumb }} | ||
<img src="{{ thumb }}"><br> | ||
{{ /if }} |