mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-15 01:30:33 +08:00
feat(route): add Netflix Newsroom (#8135)
Co-authored-by: SettingDust <settingdust@gmail.com> Co-authored-by: NeverBehave <gayhub@never.pet> Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
@@ -635,6 +635,20 @@ IPFS 网关有可能失效,那时候换成其他网关。
|
||||
|
||||
<Route author="emdoe" example="/nautilus/topic/Art" path="/nautilus/topic/:tid" :paramsDesc="['话题 id, 可在页面上方 TOPICS 栏目处找到']"/>
|
||||
|
||||
## Netflix
|
||||
|
||||
### Newsroom
|
||||
|
||||
<Route author="nczitzk" example="/netflix/newsroom" path="/netflix/newsroom/:category?/:region?" :paramsDesc="['分类,见下表,默认为 0 即 全部', '地区,可在地区页 URL 中找到,默认为 en 即 英语地区']">
|
||||
|
||||
分类
|
||||
|
||||
| 全部报道 | 业务 | 创新 | 娱乐 | 巴西制作 | 社会影响 |
|
||||
| -------- | -------- | ------------- | ---------- | -------- | -------- |
|
||||
| all | business | entertainment | innovation | brazil | impact |
|
||||
|
||||
</Route>
|
||||
|
||||
## Odaily 星球日报
|
||||
|
||||
### 活动
|
||||
|
||||
@@ -4234,6 +4234,9 @@ router.get('/now/news/rank', lazyloadRouteHandler('./routes/now/rank'));
|
||||
// s-hentai
|
||||
router.get('/s-hentai/:id?', lazyloadRouteHandler('./routes/s-hentai'));
|
||||
|
||||
// Netflix
|
||||
router.get('/netflix/newsroom/:category?/:region?', lazyloadRouteHandler('./routes/netflix/newsroom'));
|
||||
|
||||
// SBS
|
||||
router.get('/sbs/chinese/:category?/:id?/:dialect?/:language?', lazyloadRouteHandler('./routes/sbs/chinese'));
|
||||
|
||||
|
||||
82
lib/routes/netflix/newsroom.js
Normal file
82
lib/routes/netflix/newsroom.js
Normal file
@@ -0,0 +1,82 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const languages = {
|
||||
zh_cn: 'zh-hans',
|
||||
zh_tw: 'zh-hant',
|
||||
};
|
||||
|
||||
const categories = {
|
||||
all: {
|
||||
title: 'All News',
|
||||
id: '0',
|
||||
},
|
||||
business: {
|
||||
title: 'Business',
|
||||
id: '1GnkLu7bxeOTxTRNCeu5qm',
|
||||
},
|
||||
entertainment: {
|
||||
title: 'Entertainment',
|
||||
id: '3SGbaxYYG5U05Z0G4piPV7',
|
||||
},
|
||||
innovation: {
|
||||
title: 'Innovation',
|
||||
id: '5TzuQELMABTu9jOPjXXlFU',
|
||||
},
|
||||
brazil: {
|
||||
title: 'Made in Brazil',
|
||||
id: '2tOmcnQB8PgkQSoQ1K4hfD',
|
||||
},
|
||||
impact: {
|
||||
title: 'Social Impact',
|
||||
id: '2bUcGjE2800LAsk3JDurGA',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'all';
|
||||
const region = ctx.params.region ?? 'en';
|
||||
|
||||
const rootUrl = 'https://about.netflix.com';
|
||||
const currentUrl = `${rootUrl}/api/data/articles?language=${languages.hasOwnProperty(region) ? languages[region] : region.replace(/_/g, '-')}${category === 'all' ? '' : `&category=${categories[category].id}`}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const list = response.data.entities.articles.slice(0, ctx.params.limit ? parseInt(ctx.params.limit) : 15).map((item) => ({
|
||||
title: item.title,
|
||||
link: `${rootUrl}/${region}/news/${item.slug}`,
|
||||
pubDate: parseDate(item.rawPublishedDate),
|
||||
category: item.categories.map((category) => category.label),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
if (!content('.article-contentstyles__ArticleCopy-pei0rm-6 ul li')) {
|
||||
content('.article-contentstyles__ArticleCopy-pei0rm-6 p').slice(-3).remove();
|
||||
}
|
||||
|
||||
item.description = content('.article-contentstyles__ArticleCopy-pei0rm-6').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${categories[category].title} - Newsroom - Netflix`,
|
||||
link: `${rootUrl}/${region}/newsroom`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user