fix(route)(wechat/feeddd) (#8918)
Signed-off-by: Rongrong <15956627+Rongronggg9@users.noreply.github.com>
This commit is contained in:
parent
322089d762
commit
c9d8450688
|
|
@ -3105,7 +3105,7 @@ column 为 third 时可选的 category:
|
|||
|
||||
### 公众号 (feeddd 来源)
|
||||
|
||||
<Route author="TonyRL" example="/wechat/feeddd/6131e1441269c358aa0e2141" path="/wechat/feeddd/:id" :paramsDesc="['公众号 id, 打开 `https://feeddd.org/feeds` 或 `https://cdn.jsdelivr.net/gh/feeddd/feeds/feeds_all_rss.txt`, 在 URL 中找到 id']"/>
|
||||
<Route author="TonyRL Rongronggg9" example="/wechat/feeddd/6131e1441269c358aa0e2141" path="/wechat/feeddd/:id" :paramsDesc="['公众号 id, 打开 `https://feeddd.org/feeds` 或 `https://cdn.jsdelivr.net/gh/feeddd/feeds/feeds_all_rss.txt`, 在 URL 中找到 id; 注意不是公众号页的 id, 而是订阅的 id']"/>
|
||||
|
||||
### 公众号栏目 (非推送 & 历史消息)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,15 +12,10 @@ module.exports = async (ctx) => {
|
|||
|
||||
const response = await got(apiUrl);
|
||||
|
||||
if (response.data.items.length === 0) {
|
||||
throw Error('Empty feed');
|
||||
}
|
||||
|
||||
let items = response.data.items.map((item) => ({
|
||||
title: item.title,
|
||||
pubDate: parseDate(item.date_modified),
|
||||
link: item.url,
|
||||
author: item.title,
|
||||
guid: item.id,
|
||||
}));
|
||||
|
||||
|
|
@ -51,6 +46,18 @@ module.exports = async (ctx) => {
|
|||
desc: $('#js_content').html(),
|
||||
});
|
||||
|
||||
item.author = $('meta[name=author]').attr('content');
|
||||
|
||||
// another way to get publish timestamp:
|
||||
// const publish_time_script = $('script[nonce][type="text/javascript"]:contains("var ct")').html();
|
||||
// const publish_time_match = publish_time_script && publish_time_script.match(/var ct *= *"(\d{10})"/);
|
||||
const publish_time_script = $('script[nonce][type="text/javascript"]:contains("publish_time")').html();
|
||||
const publish_time_match = publish_time_script && publish_time_script.match(/var.*[ ,]n *= *"(\d{10})"/);
|
||||
const publish_timestamp = publish_time_match && publish_time_match[1];
|
||||
if (publish_timestamp) {
|
||||
item.pubDate = parseDate(publish_timestamp * 1000);
|
||||
}
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
|
|
@ -61,6 +68,7 @@ module.exports = async (ctx) => {
|
|||
link: response.data.feed_url,
|
||||
description: response.data.title,
|
||||
item: items,
|
||||
allowEmpty: true,
|
||||
};
|
||||
|
||||
ctx.state.json = {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
module.exports = {
|
||||
'/feeddd/:id': ['TonyRL'],
|
||||
'/feeddd/:id': ['TonyRL', 'Rongronggg9'],
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue