Skip to content

Commit

Permalink
feat: recover /ft/myft, close #14096
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jan 4, 2024
1 parent 6a1f53d commit b8f7b38
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/v2/ft/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
'/myft/:key': ['HenryQW'],
'/:language/:channel?': ['HenryQW', 'xyqfer'],
};
51 changes: 51 additions & 0 deletions lib/v2/ft/myft.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const got = require('@/utils/got');
const parser = require('@/utils/rss-parser');
const cheerio = require('cheerio');

module.exports = async (ctx) => {
const ProcessFeed = (content) => {
// clean up the article
content.find('div.o-share, aside, div.o-ads').remove();

return content.html();
};

const link = `https://www.ft.com/myft/following/${ctx.params.key}.rss`;

const feed = await parser.parseURL(link);

const items = await Promise.all(
feed.items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
url: item.link,
headers: {
Referer: 'https://www.facebook.com',
},
});

const $ = cheerio.load(response.data);

item.description = ProcessFeed($('article.js-article__content-body'));
item.category = [$('.n-content-tag--with-follow').text()].concat(
$('.article__right-bottom a.concept-list__concept')
.map((i, e) => $(e).text().trim())
.get()
);
item.author = $('a.n-content-tag--author')
.map((i, e) => $(e).text())
.get();

return item;
})
)
);

ctx.state.data = {
title: `FT.com - myFT`,
link,
description: `FT.com - myFT`,
item: items,
};
};
13 changes: 13 additions & 0 deletions lib/v2/ft/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ module.exports = {
title: 'FT 中文网',
docs: 'https://docs.rsshub.app/routes/traditional-media#financial-times',
},
{
title: 'myFT 个人 RSS',
docs: 'https://docs.rsshub.app/routes/traditional-media#financial-times',
},
],
},
'ft.com': {
_name: 'Financial Times',
'.': [
{
title: 'myFT personal RSS',
docs: 'https://docs.rsshub.app/routes/en/traditional-media#financial-times',
},
],
},
};
1 change: 1 addition & 0 deletions lib/v2/ft/router.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = function (router) {
router.get('/myft/:key', require('./myft'));
router.get('/:language/:channel?', require('./channel'));
};
9 changes: 9 additions & 0 deletions website/docs/routes/traditional-media.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@
- 频道包含多重路径,如 `http://www.ftchinese.com/rss/column/007000002` 则替换 `/``-` `/ft/chinese/column-007000002`.
</Route>

### myFT personal RSS {#financial-times-myft-personal-rss}

<Route author="HenryQW" example="/ft/myft/rss-key" path="/ft/myft/:key" paramsDesc={['the last part of myFT personal RSS address']} configRequired="1">
:::tip
- Visit ft.com -> myFT -> Contact Preferences to enable personal RSS feed, see [help.ft.com](https://help.ft.com/faq/email-alerts-and-contact-preferences/what-is-myft-rss-feed/)
- Obtain the key from the personal RSS address, it looks like `12345678-abcd-4036-82db-vdv20db024b8`
:::
</Route>

## Korean Central News Agency (KCNA) 朝鲜中央通讯社 {#korean-central-news-agency-kcna-chao-xian-zhong-yang-tong-xun-she}

### News {#korean-central-news-agency-kcna-chao-xian-zhong-yang-tong-xun-she-news}
Expand Down

0 comments on commit b8f7b38

Please sign in to comment.