* bloomberg initial ok * add lede * add lede * video ok * video fix * video fix * fix some * fix some * change docs * anticrawler * fix deepscan * change async to 1 * fix null checking * fix audio * fix 404 api * bloomberg fix fallback html * Delete description.art Added by mistake * return fallback item * comply with reviews * change to some func * fix radar * fix video poster * merge into oneline * fix no-await-in-loop with for await ... of loop * add PX3 ok * fix deepscan error * fix features signle page * fix deepscan * docs: fix line break
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
const { rootUrl, parseNewsList, parseArticle } = require('./utils');
|
|
const asyncPool = require('tiny-async-pool');
|
|
const site_title_mapping = {
|
|
'/': 'News',
|
|
bpol: 'Politics',
|
|
bbiz: 'Business',
|
|
markets: 'Markets',
|
|
technology: 'Technology',
|
|
green: 'Green',
|
|
wealth: 'Wealth',
|
|
pursuits: 'Pursuits',
|
|
bview: 'Opinion',
|
|
equality: 'Equality',
|
|
businessweek: 'Businessweek',
|
|
citylab: 'CityLab',
|
|
};
|
|
|
|
const asyncPoolAll = async (...args) => {
|
|
const results = [];
|
|
for await (const result of asyncPool(...args)) {
|
|
results.push(result);
|
|
}
|
|
return results;
|
|
};
|
|
|
|
module.exports = async (ctx) => {
|
|
const { site } = ctx.params;
|
|
const currentUrl = site ? `${rootUrl}/${site}/sitemap_news.xml` : `${rootUrl}/sitemap_news.xml`;
|
|
|
|
const list = await parseNewsList(currentUrl, ctx);
|
|
const items = await asyncPoolAll(1, list, (item) => parseArticle(item, ctx));
|
|
ctx.state.data = {
|
|
title: `Bloomberg - ${site_title_mapping[site ?? '/']}`,
|
|
link: currentUrl,
|
|
item: items,
|
|
};
|
|
};
|