feat(route): add SBS中文 (#8149)
Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
parent
4f73390bdc
commit
3ff3cef03e
|
|
@ -238,6 +238,60 @@ This route adds the missing photo and Link element. (Offical RSS doesn't have Li
|
|||
|
||||
</RouteEn>
|
||||
|
||||
## SBS
|
||||
|
||||
### Chinese
|
||||
|
||||
<RouteEn author="nczitzk" example="/sbs/chinese" path="/sbs/chinese/:category?/:id?/:dialect?/:language?" :paramsDesc="['Category, `news` or `podcast`, `news` by default', 'Id, see below, can be found in URL, `news` by default', 'Dialect, `mandarin` or `cantonese`, `mandarin` by default', 'Language, `zh-hans` or `zh-hant`, `zh-hans` by default']">
|
||||
|
||||
::: tip Tip
|
||||
|
||||
When subscribing to podcasts, fill `category` with **podcast**. For example, URL to [SBS 普通话电台](https://www.sbs.com.au/chinese/mandarin/zh-hans/podcast/sbs-mandarin) is <https://www.sbs.com.au/chinese/mandarin/zh-hans/podcast/sbs-mandarin>, with **sbs-mandarin** as `id`, **mandarin** as `dialect`, `language` as **zh-hans**, and the route is [`/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans`](https://rsshub.app/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans).
|
||||
|
||||
:::
|
||||
|
||||
| 新闻 | 澳大利亚新闻 | 国际新闻 | 商业与财经 |
|
||||
| ---- | --------------- | ------------------ | ---------------- |
|
||||
| news | australian-news | international-news | business-finance |
|
||||
|
||||
| 澳中关系 | 移民与签证 | Stories in English |
|
||||
| ------------------------- | ----------- | ------------------ |
|
||||
| australia-china-relations | immigration | english |
|
||||
|
||||
| COVID-19 专题报道 | 澳大利亚华人 | 澳大利亚生活 | 教育 |
|
||||
| ----------------- | ------------------ | ----------------- | --------- |
|
||||
| coronavirus | australian-chinese | life-in-australia | education |
|
||||
|
||||
| 健康 | 吃喝玩乐 | 艺术人文 | 澳洲定居指南 |
|
||||
| ------ | ------------------------- | --------------- | ---------------- |
|
||||
| health | food-travel-entertainment | cultural-events | settlement-guide |
|
||||
|
||||
SBS Mandarin Programs:
|
||||
|
||||
| SBS 普通话播客 | 解读澳洲 | 疫苗快报 |
|
||||
| -------------- | ------------------- | -------------------------- |
|
||||
| sbs-mandarin | australia-explained | covid-vaccine-daily-update |
|
||||
|
||||
SBS Cantonese Programs:
|
||||
|
||||
| SBS 廣東話節目 Podcast | 疫苗快報 | 美食速遞 | 我不是名人 |
|
||||
| ---------------------- | ------------------- | --------------- | ------------------- |
|
||||
| sbs-cantonese | covid-vaccine-daily | gourmet-express | my-australian-story |
|
||||
|
||||
| 健康快樂人 | 園藝趣談 | 寰宇金融 | 文化 360 | 科技世界 |
|
||||
| ------------------ | -------------- | -------------- | ----------- | ---------------- |
|
||||
| healthy-happy-life | gardening-tips | global-finance | culture-360 | technology-world |
|
||||
|
||||
::: tip Tip
|
||||
|
||||
Mostly, you can omit `language`, for the reason that **madarin** is with **zh-hans** and **cantonese** is with **zh-hant** by default. For example, the route of [SBS 普通话电台](https://www.sbs.com.au/chinese/mandarin/zh-hans/podcast/sbs-mandarin) is [`/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans`](https://rsshub.app/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans), which can also be [`/sbs/chinese/podcast/sbs-mandarin/mandarin`](https://rsshub.app/sbs/chinese/podcast/sbs-mandarin/mandarin).
|
||||
|
||||
You still can customize `language`, however, it is important to note that not all pages are available in bilingual versions.
|
||||
|
||||
:::
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## SCMP
|
||||
|
||||
### News
|
||||
|
|
|
|||
|
|
@ -242,6 +242,60 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
## SBS
|
||||
|
||||
### 中文
|
||||
|
||||
<Route author="nczitzk" example="/sbs/chinese" path="/sbs/chinese/:category?/:id?/:dialect?/:language?" :paramsDesc="['分类,可选 `news` 和 `podcast`,默认为 `news`', 'id,见下表,可在对应页地址栏中找到,默认为 `news`', '方言,可选 `mandarin` 和 `cantonese`,默认为 `mandarin`', '语言,可选 `zh-hans` 和 `zh-hant`,默认为 `zh-hans`']">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
当订阅播客时,请为 `category` 填入 **podcast**。如 [SBS 普通话电台](https://www.sbs.com.au/chinese/mandarin/zh-hans/podcast/sbs-mandarin) 的 URL 为 <https://www.sbs.com.au/chinese/mandarin/zh-hans/podcast/sbs-mandarin>,其中 `id` 为 **sbs-mandarin**,`dialect` 为 **mandarin**,`language` 为 **zh-hans**,其路由即为 [`/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans`](https://rsshub.app/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans)。
|
||||
|
||||
:::
|
||||
|
||||
| 新闻 | 澳大利亚新闻 | 国际新闻 | 商业与财经 |
|
||||
| ---- | --------------- | ------------------ | ---------------- |
|
||||
| news | australian-news | international-news | business-finance |
|
||||
|
||||
| 澳中关系 | 移民与签证 | Stories in English |
|
||||
| ------------------------- | ----------- | ------------------ |
|
||||
| australia-china-relations | immigration | english |
|
||||
|
||||
| COVID-19 专题报道 | 澳大利亚华人 | 澳大利亚生活 | 教育 |
|
||||
| ----------------- | ------------------ | ----------------- | --------- |
|
||||
| coronavirus | australian-chinese | life-in-australia | education |
|
||||
|
||||
| 健康 | 吃喝玩乐 | 艺术人文 | 澳洲定居指南 |
|
||||
| ------ | ------------------------- | --------------- | ---------------- |
|
||||
| health | food-travel-entertainment | cultural-events | settlement-guide |
|
||||
|
||||
SBS 普通话节目:
|
||||
|
||||
| SBS 普通话播客 | 解读澳洲 | 疫苗快报 |
|
||||
| -------------- | ------------------- | -------------------------- |
|
||||
| sbs-mandarin | australia-explained | covid-vaccine-daily-update |
|
||||
|
||||
SBS 廣東話節目:
|
||||
|
||||
| SBS 廣東話節目 Podcast | 疫苗快報 | 美食速遞 | 我不是名人 |
|
||||
| ---------------------- | ------------------- | --------------- | ------------------- |
|
||||
| sbs-cantonese | covid-vaccine-daily | gourmet-express | my-australian-story |
|
||||
|
||||
| 健康快樂人 | 園藝趣談 | 寰宇金融 | 文化 360 | 科技世界 |
|
||||
| ------------------ | -------------- | -------------- | ----------- | ---------------- |
|
||||
| healthy-happy-life | gardening-tips | global-finance | culture-360 | technology-world |
|
||||
|
||||
::: tip 提示
|
||||
|
||||
大部分时候你可以省略 `language` 字段,因为默认搭配 madarin 为 zh-hans,cantonese 为 zh-hant。如 [SBS 普通话电台](https://www.sbs.com.au/chinese/mandarin/zh-hans/podcast/sbs-mandarin) 路由为 [`/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans`](https://rsshub.app/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans),你可以省略为 [`/sbs/chinese/podcast/sbs-mandarin/mandarin`](https://rsshub.app/sbs/chinese/podcast/sbs-mandarin/mandarin)。
|
||||
|
||||
你仍可以自定义 `language`,但需要注意的是,并非所有页面都有对应的双语版本。
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## Solidot
|
||||
|
||||
### 最新消息
|
||||
|
|
|
|||
|
|
@ -4234,6 +4234,9 @@ router.get('/now/news/rank', lazyloadRouteHandler('./routes/now/rank'));
|
|||
// s-hentai
|
||||
router.get('/s-hentai/:id?', lazyloadRouteHandler('./routes/s-hentai'));
|
||||
|
||||
// SBS
|
||||
router.get('/sbs/chinese/:category?/:id?/:dialect?/:language?', lazyloadRouteHandler('./routes/sbs/chinese'));
|
||||
|
||||
// Asian to lick
|
||||
router.get('/asiantolick/:category?/:keyword?', lazyloadRouteHandler('./routes/asiantolick'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id ?? 'news';
|
||||
const dialect = ctx.params.dialect ?? 'mandarin';
|
||||
const category = ctx.params.category ?? 'news';
|
||||
const language = ctx.params.language ?? dialect === 'mandarin' ? 'zh-hans' : 'zh-hant';
|
||||
|
||||
const rootUrl = 'https://www.sbs.com.au';
|
||||
const currentUrl = `${rootUrl}/language/${dialect}/${category === 'podcast' ? `${language}/podcast/${id}` : `${id}/${language}`}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.headline, .audio-playlist__item-more')
|
||||
.find('a')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
link: `${rootUrl}${item.attr('href')}`,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
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);
|
||||
|
||||
content('.block__container').remove();
|
||||
|
||||
const audio = content('a[download]')?.attr('href') ?? '';
|
||||
const image = content('meta[itemprop="image"]')?.attr('content').split('/crop/')[0] ?? '';
|
||||
|
||||
item.title = content('meta[property="og:title"]').attr('content');
|
||||
item.author = content('.article__meta-author').text().trim().replace('By', '');
|
||||
item.pubDate = parseDate(content('meta[itemprop="datePublished"]').attr('content'));
|
||||
item.description = `${image ? `<img src="${image}"><br>` : ''}${audio ? `<audio src="${audio}" controls></audio><br>` : ''}${content('.text-body').html()}`;
|
||||
|
||||
if (audio) {
|
||||
item.itunes_item_image = image;
|
||||
item.enclosure_url = audio;
|
||||
item.enclosure_type = 'audio/mpeg';
|
||||
}
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${$('meta[property="og:title"]').attr('content')} - SBS中文`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
itunes_author: 'SBS中文',
|
||||
image: `${rootUrl}/language/img/logos/in-language/logo_chinese.svg`,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue