-
-
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 NDDaily 南方都市报 (#12370)
* feat(route): add NDDaily 南方都市报 * fix(route): fix empty pubDate of NDDaily * fix(route): fix pubDate of NDDaily * fix(route): rename nddaily to oeeee * fix(route): rename nddaily to oeeee
- Loading branch information
Showing
9 changed files
with
199 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,36 @@ | ||
const got = require('@/utils/got'); | ||
const timezone = require('@/utils/timezone'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const { parseArticle } = require('../utils'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
|
||
module.exports = async (ctx) => { | ||
const id = ctx.params.id ?? 50; | ||
const currentUrl = `https://api-ndapp.oeeee.com/friends.php?m=Zone&a=SpaceDoclist&uid=${id}&type=doc`; | ||
|
||
const { data: response } = await got(currentUrl); | ||
|
||
const list = response.data | ||
.filter((i) => i.url) // Remove banner and sticky articles. | ||
.map((item) => ({ | ||
title: item.title, | ||
description: art(path.join(__dirname, '../templates/description.art'), { | ||
thumb: item.titleimg.replace(/\?x-oss-process=.*/g, ''), | ||
description: item.summary, | ||
}), | ||
pubDate: timezone(parseDate(item.ptime * 1000), +8), | ||
link: item.url, | ||
channel: item.author, | ||
})); | ||
|
||
const channel = list[1] ? list[1].channel : ''; | ||
|
||
const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet))); | ||
|
||
ctx.state.data = { | ||
title: `南方都市报客户端 - ${channel}`, | ||
link: `https://m.mp.oeeee.com/u/${id}.html`, | ||
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,30 @@ | ||
const got = require('@/utils/got'); | ||
const { parseArticle } = require('../utils'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
|
||
module.exports = async (ctx) => { | ||
const id = ctx.params.id ?? 0; | ||
const currentUrl = `https://m.mp.oeeee.com/show.php?m=Doc&a=getAuthorInfo&id=${id}`; | ||
|
||
const { data: response } = await got(currentUrl); | ||
|
||
const list = response.data.list.map((item) => ({ | ||
title: '【' + item.media_nickname + '】' + item.title, | ||
description: art(path.join(__dirname, '../templates/description.art'), { | ||
thumb: item.titleimg, | ||
description: item.summary, | ||
}), | ||
link: item.url, | ||
})); | ||
|
||
const author = response.data.info ? response.data.info.name : ''; | ||
|
||
const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet))); | ||
|
||
ctx.state.data = { | ||
title: `南方都市报奥一网 - ${author}`, | ||
link: `https://m.mp.oeeee.com/w/${id}.html`, | ||
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,5 @@ | ||
module.exports = { | ||
'/web/:channel': ['TimWu007'], | ||
'/app/channel/:id': ['TimWu007'], | ||
'/app/reporter/:id': ['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,12 @@ | ||
module.exports = { | ||
'oeeee.com': { | ||
_name: '奥一网', | ||
'.': [ | ||
{ | ||
title: '新闻', | ||
docs: 'https://docs.rsshub.app/traditional-media.html#nan-fang-du-shi-bao', | ||
source: ['/'], | ||
}, | ||
], | ||
}, | ||
}; |
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,5 @@ | ||
module.exports = (router) => { | ||
router.get('/web/:channel', require('./web')); | ||
router.get('/app/channel/:id', require('./app/channel')); | ||
router.get('/app/reporter/:id', require('./app/reporter')); | ||
}; |
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,7 @@ | ||
{{ if thumb }} | ||
<img src="{{ thumb }}"><br> | ||
{{ /if }} | ||
{{ if description }} | ||
<blockquote><p>{{ description }}</p></blockquote> | ||
<br> | ||
{{ /if }} |
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,41 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const timezone = require('@/utils/timezone'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
const parseArticle = (item, tryGet) => | ||
tryGet(item.link, async () => { | ||
const detailResponse = await got({ | ||
method: 'get', | ||
url: item.link, | ||
}); | ||
|
||
const content = cheerio.load(detailResponse.data); | ||
|
||
// nfapp page: | ||
if (content('.post-cont') && content('.post-cont').html()) { | ||
content('img').removeAttr('data-width').removeAttr('data-height').removeAttr('class').removeAttr('title').removeAttr('referrerpolicy'); | ||
content('.taglist, .J_ndlogo, .zan-shang, .sourcelist-box, #shareContain, .buyCopyright, .article-info, .icon, .special').remove(); | ||
item.description += | ||
content('.post-cont') | ||
.html() | ||
.replace(/data:image\S*=="\s*\n*\s*original="/g, '') ?? ''; | ||
if (!item.pubDate) { | ||
item.pubDate = timezone(parseDate(content('.introduce').text().split()), +8); | ||
} | ||
} | ||
// oeeee news page: | ||
else if (content('.content') && content('.content').html()) { | ||
item.description += content('.content').html() ?? ''; | ||
} | ||
// oeeee news page #2: | ||
else if (content('.article-conten') && content('.article-conten').html()) { | ||
item.description += content('.article-conten').html() ?? ''; | ||
} | ||
|
||
return item; | ||
}); | ||
|
||
module.exports = { | ||
parseArticle, | ||
}; |
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,36 @@ | ||
const got = require('@/utils/got'); | ||
const timezone = require('@/utils/timezone'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const { parseArticle } = require('./utils'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
|
||
module.exports = async (ctx) => { | ||
const channel = ctx.params.channel ?? 0; | ||
const currentUrl = `https://www.oeeee.com/api/channel.php?m=Js4channelNews&a=newLatest&cid=${channel}`; | ||
|
||
const { data: response } = await got(currentUrl); | ||
|
||
const list = response.data.map((item) => ({ | ||
title: '【' + item.channel_name + '】' + item.title, | ||
description: art(path.join(__dirname, 'templates/description.art'), { | ||
thumb: item.img, | ||
description: item.summary, | ||
}), | ||
pubDate: timezone(parseDate(item.datetime), +8), | ||
link: item.linkurl, | ||
author: item.author, | ||
// channelName: item.channel_name, | ||
channelEname: item.channel_ename, | ||
})); | ||
|
||
const channelEname = list[1] ? list[1].channelEname : ''; | ||
|
||
const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet))); | ||
|
||
ctx.state.data = { | ||
title: `南方都市报奥一网`, | ||
link: `https://www.oeeee.com/api/channel.php?s=/index/index/channel/${channelEname}`, | ||
item: items, | ||
}; | ||
}; |