-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 完成issues#7485,在每日一图-国家地理中增加每日精选节点 * 修改文档和router位置 * 对日期pubDate规范进行了调整 * 优化调整获取内容逻辑,修改pubDate字段的获取方式 * 调整pubDate参数 * 删除代码中多余的console * 调整parse-date引用 * 调整时区 * issues-#7471,解决国家地理每日一图获取失败问题,因为网站更改,并且网站对图片进行了处理,所以调整获取方式。 * 删除无用代码 * 调整代码,错删了代码 * refactor: migrate to v2 * fix: nat geo photo of the day * fix: natgeo parseDate * style: lint * feat: radar for natgeomedia.com Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
- Loading branch information
1 parent
e42bdf3
commit e61a90d
Showing
12 changed files
with
146 additions
and
64 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
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
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
const config = require('@/config').value; | ||
|
||
module.exports = async (ctx) => { | ||
const rootUrl = 'https://www.nationalgeographic.com'; | ||
const apiUrl = `${rootUrl}/photo-of-the-day`; | ||
const response = await ctx.cache.tryGet(apiUrl, async () => (await got(apiUrl)).data, config.cache.contentExpire, false); | ||
const $ = cheerio.load(response); | ||
|
||
const natgeo = JSON.parse($.html().match(/window\['__natgeo__'\]=(.*);/)[1]); | ||
const media = natgeo.page.content.mediaspotlight.frms[0].mods[0].edgs[1].media; | ||
|
||
const items = media.map((item) => ({ | ||
title: item.meta.title, | ||
description: art(path.join(__dirname, 'templates/dailyPhoto.art'), { | ||
img: item.img, | ||
}), | ||
link: rootUrl + item.locator, | ||
pubDate: parseDate(item.caption.preHeading), | ||
author: item.img.crdt, | ||
})); | ||
|
||
ctx.state.data = { | ||
title: 'Nat Geo Photo of the Day', | ||
link: apiUrl, | ||
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,41 @@ | ||
const got = require('@/utils/got'); | ||
const timezone = require('@/utils/timezone'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const host = 'http://dili.bdatu.com/jiekou/mains/p1.html'; | ||
const data = await got(host); | ||
|
||
let sort = 0; | ||
let addtime = ''; | ||
|
||
for (let i = 0; i < data.data.album.length; i++) { | ||
if (parseInt(data.data.album[i].ds) === 1) { | ||
sort = data.data.album[i].sort; | ||
addtime = data.data.album[i].addtime; | ||
break; | ||
} | ||
} | ||
const api = 'http://dili.bdatu.com/jiekou/albums/a' + sort + '.html'; | ||
const response = await got(api); | ||
const items = response.data.picture; | ||
const out = new Array(); | ||
|
||
items.map((item) => { | ||
const info = { | ||
title: item.title, | ||
link: item.url, | ||
description: `<img src="${item.url}"><br>` + item.content, | ||
pubDate: timezone(parseDate(addtime), +0), | ||
guid: item.id, | ||
}; | ||
out.push(info); | ||
return info; | ||
}); | ||
|
||
ctx.state.data = { | ||
title: 'Photo of the Daily Selection', | ||
link: api, | ||
item: out, | ||
}; | ||
}; |
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 = { | ||
'/dailyselection': ['OrangeEd1t'], | ||
'/dailyphoto': ['LogicJake', 'OrangeEd1t', 'TonyRL'], | ||
'/:cat/:type?': ['fengkx'], | ||
}; |
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,24 @@ | ||
module.exports = { | ||
'nationalgeographic.com': { | ||
_name: '国家地理', | ||
'.': [ | ||
{ | ||
title: '每日一图', | ||
docs: 'https://docs-rsshub.pages.dev/picture.html#guo-jia-di-li', | ||
source: ['/photo-of-the-day/*', '/'], | ||
target: '/natgeo/dailyphoto', | ||
}, | ||
], | ||
}, | ||
'natgeomedia.com': { | ||
_name: '国家地理', | ||
'.': [ | ||
{ | ||
title: '分类', | ||
docs: 'https://docs.rsshub.app/travel.html#guo-jia-di-li', | ||
source: ['/:cat/:type', '/'], | ||
target: '/natgeo/:cat/:type', | ||
}, | ||
], | ||
}, | ||
}; |
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('/dailyphoto', require('./dailyphoto')); | ||
router.get('/dailyselection', require('./dailyselection')); | ||
router.get('/:cat/:type?', require('./natgeo')); | ||
}; |
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 @@ | ||
<img src="{{@ img.src }}" alt="{{@ img.altText }}"> | ||
<br> | ||
<h3>{{@ img.ttl }}</h3> | ||
<p>{{@ img.dsc }}</p> | ||
<p>{{@ img.crdt }}</p> |