mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat: add wechat uread channel (#2515)
* feat: add wechat uread channel * feat: add wechat uread channel * feat: add wechat uread channel * Update social-media.md
This commit is contained in:
51
lib/routes/tencent/wechat/uread.js
Normal file
51
lib/routes/tencent/wechat/uread.js
Normal file
@@ -0,0 +1,51 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const userid = ctx.params.userid;
|
||||
const url = `http://119.29.146.143:8080/reading/subscription/account/recent?uid=${userid}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: url,
|
||||
});
|
||||
const data = response.data;
|
||||
|
||||
const ProcessFeed = (data) => {
|
||||
const $ = cheerio.load(data);
|
||||
return $('.rich_media_content').html();
|
||||
};
|
||||
|
||||
const items = await Promise.all(
|
||||
data.data.map(async (item) => {
|
||||
const link = item.url;
|
||||
|
||||
const cache = await ctx.cache.get(link);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
|
||||
const description = ProcessFeed(response.data);
|
||||
|
||||
const single = {
|
||||
title: item.title,
|
||||
description,
|
||||
link: link,
|
||||
author: item.official_account,
|
||||
pubDate: item.publish_time,
|
||||
};
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `优读 - ${userid}`,
|
||||
link: 'https://uread.ai/',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user